You are viewing a plain text version of this content. The canonical link for it is here.
Posted to surefire-commits@maven.apache.org by kr...@apache.org on 2010/12/22 18:01:02 UTC

svn commit: r1051986 - in /maven/surefire/trunk: maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ surefire-booter/src/main/java/org/apache/maven/surefire/booter/ surefire-integration-tests/src/test/java/org/apache/mave...

Author: krosenvold
Date: Wed Dec 22 17:01:02 2010
New Revision: 1051986

URL: http://svn.apache.org/viewvc?rev=1051986&view=rev
Log:
o Improved IT

Modified:
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java
    maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire674BuildFailingWhenErrorsIT.java

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java?rev=1051986&r1=1051985&r2=1051986&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java Wed Dec 22 17:01:02 2010
@@ -34,7 +34,6 @@ import org.apache.maven.surefire.booter.
 import org.apache.maven.surefire.booter.SurefireStarter;
 import org.apache.maven.surefire.booter.SystemPropertyManager;
 import org.apache.maven.surefire.providerapi.SurefireProvider;
-import org.apache.maven.surefire.suite.RunResult;
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.cli.CommandLineException;
 import org.codehaus.plexus.util.cli.CommandLineUtils;
@@ -95,8 +94,7 @@ public class ForkStarter
         if ( ForkConfiguration.FORK_NEVER.equals( requestedForkMode ) )
         {
             SurefireStarter surefireStarter = new SurefireStarter( startupConfiguration, providerConfiguration );
-            RunResult runResult = surefireStarter.runSuitesInProcess();
-            result = surefireStarter.processRunCount( runResult );
+            result = surefireStarter.runSuitesInProcess();
         }
         else if ( ForkConfiguration.FORK_ONCE.equals( requestedForkMode ) )
         {

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java?rev=1051986&r1=1051985&r2=1051986&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java Wed Dec 22 17:01:02 2010
@@ -19,8 +19,6 @@ package org.apache.maven.surefire.booter
  * under the License.
  */
 
-import org.apache.maven.surefire.suite.RunResult;
-
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
@@ -68,19 +66,9 @@ public class ForkedBooter
 
             Object forkedTestSet = booterConfiguration.getTestForFork();
             Properties p = booterConfiguration.getProviderProperties();
-            final int result;
-            final RunResult runResult;
-            if ( forkedTestSet != null )
-            {
-                runResult = booter.runSuitesInProcess( forkedTestSet );
-                booter.updateResultsProperties( runResult, p );
-                SystemPropertyManager.writePropertiesFile( surefirePropertiesFile, "surefire", p );
-            }
-            else
-            {
-                runResult = booter.runSuitesInProcess();
-            }
-            result = booter.processRunCount( runResult );
+            final int result = forkedTestSet != null
+                ? booter.runSuitesInProcess( forkedTestSet, surefirePropertiesFile, p )
+                : booter.runSuitesInProcess();
 
             // noinspection CallToSystemExit
             System.exit( result );

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java?rev=1051986&r1=1051985&r2=1051986&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java Wed Dec 22 17:01:02 2010
@@ -24,6 +24,8 @@ import org.apache.maven.surefire.report.
 import org.apache.maven.surefire.suite.RunResult;
 import org.apache.maven.surefire.testset.TestSetFailedException;
 
+import java.io.File;
+import java.io.IOException;
 import java.io.PrintStream;
 import java.util.Properties;
 
@@ -54,8 +56,8 @@ public class SurefireStarter
         this.startupConfiguration = startupConfiguration;
     }
 
-    public RunResult runSuitesInProcess( Object testSet )
-        throws SurefireExecutionException
+    public int runSuitesInProcess( Object testSet, File surefirePropertiesFile, Properties p )
+        throws SurefireExecutionException, IOException
     {
         final StartupConfiguration starterConfiguration = startupConfiguration;
         final ClasspathConfiguration classpathConfiguration = starterConfiguration.getClasspathConfiguration();
@@ -65,10 +67,13 @@ public class SurefireStarter
 
         ClassLoader surefireClassLoader = classpathConfiguration.createSurefireClassLoader( testsClassLoader );
 
-        return invokeProvider( testSet, testsClassLoader, surefireClassLoader );
+        final RunResult runResult = invokeProvider( testSet, testsClassLoader, surefireClassLoader );
+        updateResultsProperties( runResult, p );
+        SystemPropertyManager.writePropertiesFile( surefirePropertiesFile, "surefire", p );
+        return processRunCount( runResult );
     }
 
-    public RunResult runSuitesInProcess()
+    public int runSuitesInProcess()
         throws SurefireExecutionException
     {
         // The test classloader must be constructed first to avoid issues with commons-logging until we properly
@@ -79,7 +84,8 @@ public class SurefireStarter
 
         ClassLoader surefireClassLoader = classpathConfiguration.createSurefireClassLoader( testsClassLoader );
 
-        return invokeProvider( null, testsClassLoader, surefireClassLoader );
+        final RunResult runResult = invokeProvider( null, testsClassLoader, surefireClassLoader );
+        return processRunCount( runResult);
     }
 
     private ClassLoader createInProcessTestClassLoader()
@@ -116,7 +122,7 @@ public class SurefireStarter
     private static final String RESULTS_SKIPPED = "skipped";
 
 
-    public void updateResultsProperties( RunResult runResult, Properties results )
+    private void updateResultsProperties( RunResult runResult, Properties results )
     {
         results.setProperty( RESULTS_ERRORS, String.valueOf( runResult.getErrors() ) );
         results.setProperty( RESULTS_COMPLETED_COUNT, String.valueOf( runResult.getCompletedCount() ) );
@@ -160,7 +166,7 @@ public class SurefireStarter
      * @return The process result code
      * @throws SurefireExecutionException When an exception is found
      */
-    public int processRunCount( RunResult runCount )
+    private int processRunCount( RunResult runCount )
         throws SurefireExecutionException
     {
 

Modified: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire674BuildFailingWhenErrorsIT.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire674BuildFailingWhenErrorsIT.java?rev=1051986&r1=1051985&r2=1051986&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire674BuildFailingWhenErrorsIT.java (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire674BuildFailingWhenErrorsIT.java Wed Dec 22 17:01:02 2010
@@ -19,6 +19,7 @@ package org.apache.maven.surefire.its;
  */
 
 
+import junit.framework.Assert;
 import org.apache.maven.it.VerificationException;
 import org.apache.maven.it.Verifier;
 import org.apache.maven.it.util.ResourceExtractor;
@@ -41,11 +42,10 @@ public class Surefire674BuildFailingWhen
         try
         {
             this.executeGoal( verifier, "test" );
+            Assert.fail("The verifier should throw an exception");
         }
         catch ( VerificationException ignore )
         {
-            // We're supposed to fail and verifier does not allow us to ignore it. Maybe not the most convincing
-            // os solutions
         }
         verifier.resetStreams();
         verifier.verifyTextInLog( "BUILD FAILURE" );