bodewig     2003/09/17 01:20:54

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/junit
                        JUnitTask.java
  Log:
  Log tests that have timed out in the summary as well.
  
  PR: 23160
  Submitted by: Martijn Kruithof <ant at kruithof dot xs4all dot nl>
  
  Revision  Changes    Path
  1.80      +28 -16    
ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
  
  Index: JUnitTask.java
  ===================================================================
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java,v
  retrieving revision 1.79
  retrieving revision 1.80
  diff -u -r1.79 -r1.80
  --- JUnitTask.java    11 Sep 2003 14:04:16 -0000      1.79
  +++ JUnitTask.java    17 Sep 2003 08:20:54 -0000      1.80
  @@ -1118,26 +1118,38 @@
               if (outFile != null && formatter != null) {
                   try {
                       OutputStream out = new FileOutputStream(outFile);
  -                    formatter.setOutput(out);
  -                    formatter.startTestSuite(test);
  -                    test.setCounts(0, 0, 1);
  -                    Test t = new Test() {
  -                        public int countTestCases() { return 0; }
  -                        public void run(TestResult r) {
  -                            throw new AssertionFailedError("Timeout 
occurred");
  -                        }
  -                    };
  -                    formatter.startTest(t);
  -                    formatter
  -                        .addError(t,
  -                                  new AssertionFailedError("Timeout 
occurred"));
  -
  -                    formatter.endTestSuite(test);
  +                    addTimeout(test, formatter, out);
                   } catch (IOException e) {
                       // ignore
                   }
               }
           }
  +        if (summary) {
  +            SummaryJUnitResultFormatter f = new 
SummaryJUnitResultFormatter();
  +            
f.setWithOutAndErr("withoutanderr".equalsIgnoreCase(summaryValue));
  +            addTimeout(test, f, getDefaultOutput());
  +        }
  +    }
  +
  +    /**
  +     * Adds the actual timeout to the formatter. 
  +     * Only used from the logTimeout method.
  +     * @since Ant 1.6
  +     */
  +    private void addTimeout(JUnitTest test, JUnitResultFormatter formatter, 
  +                            OutputStream out) {
  +        formatter.setOutput(out);
  +        formatter.startTestSuite(test);
  +        test.setCounts(0, 0, 1);
  +        Test t = new Test() {
  +            public int countTestCases() { return 0; }
  +            public void run(TestResult r) {
  +                throw new AssertionFailedError("Timeout occurred");
  +            }
  +        };
  +        formatter.startTest(t);
  +        formatter.addError(t, new AssertionFailedError("Timeout occurred"));
  +        formatter.endTestSuite(test);
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to