git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@405524 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -47,7 +47,9 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| */ | */ | ||||
| public class Execute { | public class Execute { | ||||
| /** Invalid exit code. **/ | |||||
| /** Invalid exit code. | |||||
| * set to {@link Integer#MAX_VALUE} | |||||
| */ | |||||
| public static final int INVALID = Integer.MAX_VALUE; | public static final int INVALID = Integer.MAX_VALUE; | ||||
| private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | ||||
| @@ -586,6 +588,16 @@ public class Execute { | |||||
| ? (exitValue % 2 == 0) : (exitValue != 0); | ? (exitValue % 2 == 0) : (exitValue != 0); | ||||
| } | } | ||||
| /** | |||||
| * Did this execute return in a failure. | |||||
| * @see #isFailure(int) | |||||
| * @return true if and only if the exit code is interpreted as a failure | |||||
| * @since Ant1.7 | |||||
| */ | |||||
| public boolean isFailure() { | |||||
| return isFailure(getExitValue()); | |||||
| } | |||||
| /** | /** | ||||
| * Test for an untimely death of the process. | * Test for an untimely death of the process. | ||||
| * @return true if a watchdog had to kill the process. | * @return true if a watchdog had to kill the process. | ||||
| @@ -65,9 +65,8 @@ public class ForkingSunRmic extends DefaultRmicAdapter { | |||||
| exe.setAntRun(project); | exe.setAntRun(project); | ||||
| exe.setWorkingDirectory(project.getBaseDir()); | exe.setWorkingDirectory(project.getBaseDir()); | ||||
| exe.setCommandline(args); | exe.setCommandline(args); | ||||
| exe.execute(); | exe.execute(); | ||||
| return exe.getExitValue() == 0; | |||||
| return !exe.isFailure(); | |||||
| } catch (IOException exception) { | } catch (IOException exception) { | ||||
| throw new BuildException("Error running " + SunRmic.RMIC_EXECUTABLE | throw new BuildException("Error running " + SunRmic.RMIC_EXECUTABLE | ||||
| + " -maybe it is not on the path", exception); | + " -maybe it is not on the path", exception); | ||||
| @@ -27,12 +27,12 @@ import java.io.*; | |||||
| */ | */ | ||||
| public class ExecuteWatchdogTest extends TestCase { | public class ExecuteWatchdogTest extends TestCase { | ||||
| private final static int TIME_OUT = 5000; | |||||
| private final static long TIME_OUT = 5000; | |||||
| private final static String TEST_CLASSPATH = getTestClassPath(); | private final static String TEST_CLASSPATH = getTestClassPath(); | ||||
| private final static int CLOCK_ERROR=200; | private final static int CLOCK_ERROR=200; | ||||
| private final static int TIME_OUT_TEST=TIME_OUT-CLOCK_ERROR; | |||||
| private final static long TIME_OUT_TEST=TIME_OUT-CLOCK_ERROR; | |||||
| private ExecuteWatchdog watchdog; | private ExecuteWatchdog watchdog; | ||||
| @@ -58,7 +58,7 @@ public class ExecuteWatchdogTest extends TestCase { | |||||
| return classpath; | return classpath; | ||||
| } | } | ||||
| private Process getProcess(int timetorun) throws Exception { | |||||
| private Process getProcess(long timetorun) throws Exception { | |||||
| String[] cmdArray = { | String[] cmdArray = { | ||||
| JavaEnvUtils.getJreExecutable("java"), "-classpath", TEST_CLASSPATH, | JavaEnvUtils.getJreExecutable("java"), "-classpath", TEST_CLASSPATH, | ||||
| TimeProcess.class.getName(), String.valueOf(timetorun) | TimeProcess.class.getName(), String.valueOf(timetorun) | ||||
| @@ -94,7 +94,7 @@ public class ExecuteWatchdogTest extends TestCase { | |||||
| watchdog.start(process); | watchdog.start(process); | ||||
| int retCode = waitForEnd(process); | int retCode = waitForEnd(process); | ||||
| assertTrue("process should not have been killed", !watchdog.killedProcess()); | assertTrue("process should not have been killed", !watchdog.killedProcess()); | ||||
| assertEquals(0, retCode); | |||||
| assertFalse(Execute.isFailure(retCode)); | |||||
| } | } | ||||
| // test that the watchdog ends the process | // test that the watchdog ends the process | ||||