ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional/junit JUnitTask.java JUnitTestRunner.java ForkedVMWatcher.java
Date Wed, 13 Oct 2004 10:23:31 GMT
bodewig     2004/10/13 03:23:30

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/junit
                        JUnitTask.java JUnitTestRunner.java
  Removed:     src/main/org/apache/tools/ant/taskdefs/optional/junit
                        ForkedVMWatcher.java
  Log:
  The code that tries to detect a crashing forked VM in <junit> breaks
  down when the VM runs multiple tests.
  
  The old code used a TestFormatter and detected a crash if the expected
  output had not been written.  If multiple tests get run in one VM, the
  TestRunner ignores the filename that has been passed in - and the task
  doesn't find any output.
  
  Even if it didn't ignore the file name, a single non-crashing test
  would have made the task think, the VM finished in a healthy way.
  
  Make the crash-detection more explcit and let the TestRunner cooperate
  more than before.
  
  This bug has been presented by Gump in cooperation with the Hivemind
  build.
  
  Revision  Changes    Path
  1.109     +2 -4      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.108
  retrieving revision 1.109
  diff -u -r1.108 -r1.109
  --- JUnitTask.java	7 Oct 2004 16:15:36 -0000	1.108
  +++ JUnitTask.java	13 Oct 2004 10:23:30 -0000	1.109
  @@ -847,9 +847,7 @@
           }
   
           File vmWatcher = createTempPropertiesFile("junitvmwatcher");
  -        formatterArg.append("formatter=");
  -        formatterArg.append(ForkedVMWatcher.class.getName());
  -        formatterArg.append(",");
  +        formatterArg.append("nocrashfile=");
           formatterArg.append(vmWatcher);
           cmd.createArgument().setValue(formatterArg.toString());
   
  
  
  
  1.52      +23 -0     ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
  
  Index: JUnitTestRunner.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- JUnitTestRunner.java	6 Oct 2004 15:01:55 -0000	1.51
  +++ JUnitTestRunner.java	13 Oct 2004 10:23:30 -0000	1.52
  @@ -21,6 +21,7 @@
   import java.io.ByteArrayOutputStream;
   import java.io.File;
   import java.io.FileInputStream;
  +import java.io.FileOutputStream;
   import java.io.IOException;
   import java.io.PrintStream;
   import java.io.PrintWriter;
  @@ -475,6 +476,7 @@
           boolean stackfilter = true;
           Properties props = new Properties();
           boolean showOut = false;
  +        String noCrashFile = null;
   
           if (args.length == 0) {
               System.err.println("required argument TestClassName missing");
  @@ -493,6 +495,8 @@
                   haltFail = Project.toBoolean(args[i].substring(14));
               } else if (args[i].startsWith("filtertrace=")) {
                   stackfilter = Project.toBoolean(args[i].substring(12));
  +            } else if (args[i].startsWith("nocrashfile=")) {
  +                noCrashFile = args[i].substring(12);
               } else if (args[i].startsWith("formatter=")) {
                   try {
                       createAndStoreFormatter(args[i].substring(10));
  @@ -540,6 +544,7 @@
                       if (errorOccured || failureOccured ) {
                           if ((errorOccured && haltError) 
                               || (failureOccured && haltFail)) {
  +                            registerNonCrash(noCrashFile);
                               System.exit(code);
                           } else {
                               if (code > returnCode) {
  @@ -558,6 +563,7 @@
                                   stackfilter, haltFail, showOut, props);
           }
   
  +        registerNonCrash(noCrashFile);
           System.exit(returnCode);
       }
   
  @@ -655,4 +661,21 @@
           runner.run();
           return runner.getRetCode();
        }
  +
  +    /**
  +     * @since Ant 1.7
  +     */
  +    private static void registerNonCrash(String noCrashFile) 
  +        throws IOException {
  +        if (noCrashFile != null) {
  +            FileOutputStream out = null;
  +            try {
  +                out = new FileOutputStream(noCrashFile);
  +                out.write(0);
  +                out.flush();
  +            } finally {
  +                out.close();
  +            }
  +        }
  +    }
   } // JUnitTestRunner
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message