The JUnit task supports a timeout feature, but it doesn't give any
indication to the user that a timeout caused a test failure. I forgot I'd
put a timeout in, and this cost me a bit of time when I couldn't determine
immediately why the test failed. The code was mostly written to do this, but
doesn't actually give a message to the user. I guess that the authors wanted
to go back and do it right, but I'm submitting this very simple patch on the
chance it might save someone a bit of time.
Julian.
Index: src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/
junit/JUnitTask.java,v
retrieving revision 1.18
diff -u -r1.18 JUnitTask.java
--- src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
2001/05/03 15:03:58 1.18
+++ src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
2001/07/09 08:16:52
@@ -310,8 +310,7 @@
exitValue = executeAsForked(test, watchdog);
// null watchdog means no timeout, you'd better not check with
null
if (watchdog != null) {
- //info will be used in later version do nothing for now
- //wasKilled = watchdog.killedProcess();
+ wasKilled = watchdog.killedProcess();
}
}
@@ -321,10 +320,10 @@
boolean failureOccurredHere = exitValue != JUnitTestRunner.SUCCESS;
if (errorOccurredHere && test.getHaltonerror()
|| failureOccurredHere && test.getHaltonfailure()) {
- throw new BuildException("Test "+test.getName()+" failed",
+ throw new BuildException("Test "+test.getName()+"
failed"+(wasKilled ? " (timeout)" : ""),
location);
} else if (errorOccurredHere || failureOccurredHere) {
- log("TEST "+test.getName()+" FAILED", Project.MSG_ERR);
+ log("TEST "+test.getName()+" FAILED" + (wasKilled ? "
(timeout)" : ""), Project.MSG_ERR);
}
}