You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by jk...@apache.org on 2006/07/08 14:30:43 UTC
svn commit: r420102 - in
/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit:
JUnitTask.java JUnitTaskMirrorImpl.java
Author: jkf
Date: Sat Jul 8 05:30:43 2006
New Revision: 420102
URL: http://svn.apache.org/viewvc?rev=420102&view=rev
Log:
Give better information in case of timeout for JUnit test,as requested in Bug 39946.
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskMirrorImpl.java
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java?rev=420102&r1=420101&r2=420102&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java Sat Jul 8 05:30:43 2006
@@ -1336,7 +1336,7 @@
*/
private void logTimeout(FormatterElement[] feArray, JUnitTest test) {
- logVmExit(feArray, test, "Timeout occurred");
+ logVmExit(feArray, test, "Timeout occurred.");
}
/**
@@ -1347,7 +1347,7 @@
* @since Ant 1.7
*/
private void logVmCrash(FormatterElement[] feArray, JUnitTest test) {
- logVmExit(feArray, test, "forked Java VM exited abnormally");
+ logVmExit(feArray, test, "Forked Java VM exited abnormally.");
}
/**
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskMirrorImpl.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskMirrorImpl.java?rev=420102&r1=420101&r2=420102&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskMirrorImpl.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskMirrorImpl.java Sat Jul 8 05:30:43 2006
@@ -19,7 +19,7 @@
import java.io.OutputStream;
import junit.framework.AssertionFailedError;
-import junit.framework.Test;
+import junit.framework.TestCase;
import junit.framework.TestResult;
import org.apache.tools.ant.AntClassLoader;
@@ -31,28 +31,22 @@
* @since 1.7
*/
public final class JUnitTaskMirrorImpl implements JUnitTaskMirror {
-
+
private final JUnitTask task;
-
+
public JUnitTaskMirrorImpl(JUnitTask task) {
this.task = task;
}
-
+
public void addVmExit(JUnitTest test, JUnitTaskMirror.JUnitResultFormatterMirror _formatter,
OutputStream out, final String message) {
JUnitResultFormatter formatter = (JUnitResultFormatter) _formatter;
formatter.setOutput(out);
formatter.startTestSuite(test);
-
//the trick to integrating test output to the formatter, is to
//create a special test class that asserts an error
//and tell the formatter that it raised.
- Test t = new Test() {
- public int countTestCases() { return 1; }
- public void run(TestResult r) {
- throw new AssertionFailedError(message);
- }
- };
+ TestCase t = new VmExitErrorTest(message, test);
formatter.startTest(t);
formatter.addError(t, new AssertionFailedError(message));
formatter.endTestSuite(test);
@@ -68,5 +62,31 @@
public JUnitTaskMirror.SummaryJUnitResultFormatterMirror newSummaryJUnitResultFormatter() {
return new SummaryJUnitResultFormatter();
}
-
+
+ static class VmExitErrorTest extends TestCase {
+
+ private String message;
+ private JUnitTest test;
+
+ VmExitErrorTest(String aMessage, JUnitTest anOriginalTest) {
+ message = aMessage;
+ test = anOriginalTest;
+ }
+
+ public int countTestCases() {
+ return 1;
+ }
+
+ public void run(TestResult r) {
+ throw new AssertionFailedError(message);
+ }
+
+ public String getName() {
+ return test.getName();
+ }
+
+ public String toString() {
+ return test.getName();
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: svn commit: r420102 - in /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit:
JUnitTask.java JUnitTaskMirrorImpl.java
Posted by Martijn Kruithof <jm...@kruithof.xs4all.nl>.
I found it,
I changed the name of the command line property to pass on the file
name, but forgot to update the substring offset. I am testing on windows
currently and the resulting two off error has no consequences on windows
(if the current directory is at the same drive at least)
Fixed it in such way that the error is less likely to be made again.
Inline constants are evil.
Martijn Kruithof schreef:
> Well the further commit was committed yesterday, so it should be
> included in the gump run of today, I'll try to sort out what happened.
> The existing method already used the file to detect vm crashes, just
> using the same file in another way.
>
> The "funny" part is that the directory to which the test tries to
> write seems to be different from the directory from which the file is
> read back.
>
> The propsfile uses the getAbsolutePath method, now using that one as
> well on the crashfile.
>
> Martijn
>
> Steve Loughran wrote:
>
>> Martijn Kruithof wrote:
>>
>>> Sorry, somewhat too early, futher commit will follow.
>>
>>
>>
>> well, know we at least know which bits of Gump run junit with
>> fork=true, cos they all broke :)
>>
>> -steve
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>> For additional commands, e-mail: dev-help@ant.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: svn commit: r420102 - in /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit:
JUnitTask.java JUnitTaskMirrorImpl.java
Posted by Martijn Kruithof <jm...@kruithof.xs4all.nl>.
Well the further commit was committed yesterday, so it should be
included in the gump run of today, I'll try to sort out what happened.
The existing method already used the file to detect vm crashes, just
using the same file in another way.
The "funny" part is that the directory to which the test tries to write
seems to be different from the directory from which the file is read back.
The propsfile uses the getAbsolutePath method, now using that one as
well on the crashfile.
Martijn
Steve Loughran wrote:
> Martijn Kruithof wrote:
>
>> Sorry, somewhat too early, futher commit will follow.
>
>
> well, know we at least know which bits of Gump run junit with
> fork=true, cos they all broke :)
>
> -steve
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: svn commit: r420102 - in /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit:
JUnitTask.java JUnitTaskMirrorImpl.java
Posted by Steve Loughran <st...@apache.org>.
Martijn Kruithof wrote:
> Sorry, somewhat too early, futher commit will follow.
well, know we at least know which bits of Gump run junit with fork=true,
cos they all broke :)
-steve
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: svn commit: r420102 - in /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit:
JUnitTask.java JUnitTaskMirrorImpl.java
Posted by Martijn Kruithof <jk...@apache.org>.
Sorry, somewhat too early, futher commit will follow.
jkf@apache.org schreef:
>Author: jkf
>Date: Sat Jul 8 05:30:43 2006
>New Revision: 420102
>
>URL: http://svn.apache.org/viewvc?rev=420102&view=rev
>Log:
>Give better information in case of timeout for JUnit test,as requested in Bug 39946.
>
>Modified:
> ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
> ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskMirrorImpl.java
>
>Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
>URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java?rev=420102&r1=420101&r2=420102&view=diff
>==============================================================================
>--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java (original)
>+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java Sat Jul 8 05:30:43 2006
>@@ -1336,7 +1336,7 @@
> */
>
> private void logTimeout(FormatterElement[] feArray, JUnitTest test) {
>- logVmExit(feArray, test, "Timeout occurred");
>+ logVmExit(feArray, test, "Timeout occurred.");
> }
>
> /**
>@@ -1347,7 +1347,7 @@
> * @since Ant 1.7
> */
> private void logVmCrash(FormatterElement[] feArray, JUnitTest test) {
>- logVmExit(feArray, test, "forked Java VM exited abnormally");
>+ logVmExit(feArray, test, "Forked Java VM exited abnormally.");
> }
>
> /**
>
>Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskMirrorImpl.java
>URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskMirrorImpl.java?rev=420102&r1=420101&r2=420102&view=diff
>==============================================================================
>--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskMirrorImpl.java (original)
>+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskMirrorImpl.java Sat Jul 8 05:30:43 2006
>@@ -19,7 +19,7 @@
>
> import java.io.OutputStream;
> import junit.framework.AssertionFailedError;
>-import junit.framework.Test;
>+import junit.framework.TestCase;
> import junit.framework.TestResult;
> import org.apache.tools.ant.AntClassLoader;
>
>@@ -31,28 +31,22 @@
> * @since 1.7
> */
> public final class JUnitTaskMirrorImpl implements JUnitTaskMirror {
>-
>+
> private final JUnitTask task;
>-
>+
> public JUnitTaskMirrorImpl(JUnitTask task) {
> this.task = task;
> }
>-
>+
> public void addVmExit(JUnitTest test, JUnitTaskMirror.JUnitResultFormatterMirror _formatter,
> OutputStream out, final String message) {
> JUnitResultFormatter formatter = (JUnitResultFormatter) _formatter;
> formatter.setOutput(out);
> formatter.startTestSuite(test);
>-
> //the trick to integrating test output to the formatter, is to
> //create a special test class that asserts an error
> //and tell the formatter that it raised.
>- Test t = new Test() {
>- public int countTestCases() { return 1; }
>- public void run(TestResult r) {
>- throw new AssertionFailedError(message);
>- }
>- };
>+ TestCase t = new VmExitErrorTest(message, test);
> formatter.startTest(t);
> formatter.addError(t, new AssertionFailedError(message));
> formatter.endTestSuite(test);
>@@ -68,5 +62,31 @@
> public JUnitTaskMirror.SummaryJUnitResultFormatterMirror newSummaryJUnitResultFormatter() {
> return new SummaryJUnitResultFormatter();
> }
>-
>+
>+ static class VmExitErrorTest extends TestCase {
>+
>+ private String message;
>+ private JUnitTest test;
>+
>+ VmExitErrorTest(String aMessage, JUnitTest anOriginalTest) {
>+ message = aMessage;
>+ test = anOriginalTest;
>+ }
>+
>+ public int countTestCases() {
>+ return 1;
>+ }
>+
>+ public void run(TestResult r) {
>+ throw new AssertionFailedError(message);
>+ }
>+
>+ public String getName() {
>+ return test.getName();
>+ }
>+
>+ public String toString() {
>+ return test.getName();
>+ }
>+ }
> }
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>For additional commands, e-mail: dev-help@ant.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org