Author: krosenvold Date: Mon Aug 13 19:33:34 2012 New Revision: 1372564 URL: http://svn.apache.org/viewvc?rev=1372564&view=rev Log: o An exception in 'the wrong place' could cause plugin to not wait for proper termination of forked process
Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java maven/surefire/trunk/surefire-shadefire/pom.xml 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=1372564&r1=1372563&r2=1372564&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 Mon Aug 13 19:33:34 2012 @@ -103,7 +103,7 @@ public class ForkStarter fileReporterFactory = new FileReporterFactory( startupReportConfiguration ); } - public RunResult run(DefaultScanResult scanResult, String requestedForkMode) + public RunResult run( DefaultScanResult scanResult, String requestedForkMode ) throws SurefireBooterForkException, SurefireExecutionException { final RunResult result; @@ -227,15 +227,14 @@ public class ForkStarter { BooterSerializer booterSerializer = new BooterSerializer( forkConfiguration, properties ); - surefireProperties = booterSerializer.serialize( providerConfiguration, startupConfiguration, testSet); + surefireProperties = booterSerializer.serialize( providerConfiguration, startupConfiguration, testSet ); if ( effectiveSystemProperties != null ) { systPropsFile = SystemPropertyManager.writePropertiesFile( effectiveSystemProperties, - forkConfiguration.getTempDirectory(), - "surefire_" - + systemPropertiesFileCounter++, - forkConfiguration.isDebug() ); + forkConfiguration.getTempDirectory(), + "surefire_" + systemPropertiesFileCounter++, + forkConfiguration.isDebug() ); } } catch ( IOException e ) @@ -253,10 +252,10 @@ public class ForkStarter // Surefire-booter if !useSystemClassLoader Classpath bootClasspath = Classpath.join( bootClasspathConfiguration, additionlClassPathUrls ); - @SuppressWarnings( "unchecked" ) - Commandline cli = forkConfiguration.createCommandLine( bootClasspath.getClassPath(), - startupConfiguration.getClassLoaderConfiguration(), - startupConfiguration.isShadefire() ); + @SuppressWarnings( "unchecked" ) Commandline cli = + forkConfiguration.createCommandLine( bootClasspath.getClassPath(), + startupConfiguration.getClassLoaderConfiguration(), + startupConfiguration.isShadefire() ); cli.createArg().setFile( surefireProperties ); @@ -272,22 +271,19 @@ public class ForkStarter System.out.println( "Forking command line: " + cli ); } - RunResult runResult; + RunResult runResult = null; try { final int timeout = forkedProcessTimeoutInSeconds > 0 ? forkedProcessTimeoutInSeconds : 0; final int result = CommandLineUtils.executeCommandLine( cli, threadedStreamConsumer, threadedStreamConsumer, timeout ); - - threadedStreamConsumer.close(); - forkClient.close(); if ( result != RunResult.SUCCESS ) { throw new SurefireBooterForkException( "Error occurred in starting fork, check output in log" ); } - runResult = globalRunStatistics.getRunResult(); + } catch ( CommandLineTimeOutException e ) { @@ -295,8 +291,18 @@ public class ForkStarter } catch ( CommandLineException e ) { + runResult = RunResult.Failure; throw new SurefireBooterForkException( "Error while executing forked tests.", e.getCause() ); } + finally + { + threadedStreamConsumer.close(); + forkClient.close(); + if ( runResult == null ) + { + runResult = globalRunStatistics.getRunResult(); + } + } return runResult; } Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java?rev=1372564&r1=1372563&r2=1372564&view=diff ============================================================================== --- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java (original) +++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java Mon Aug 13 19:33:34 2012 @@ -60,12 +60,12 @@ public class ThreadedStreamConsumer { try { - String item = (String) queue.take(); + String item = queue.take(); //noinspection StringEquality while ( item != poison ) { target.consumeLine( item ); - item = (String) queue.take(); + item = queue.take(); } } catch ( InterruptedException e ) Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java?rev=1372564&r1=1372563&r2=1372564&view=diff ============================================================================== --- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java (original) +++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java Mon Aug 13 19:33:34 2012 @@ -48,6 +48,8 @@ public class RunResult public static final RunResult Timeout = new RunResult( 0, 0, 0, 0, false, true ); + public static final RunResult Failure = new RunResult( 0, 0, 0, 0, true, false); + public RunResult( int completedCount, int errors, int failures, int skipped ) { this( completedCount, errors, failures, skipped, false, false ); Modified: maven/surefire/trunk/surefire-shadefire/pom.xml URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-shadefire/pom.xml?rev=1372564&r1=1372563&r2=1372564&view=diff ============================================================================== --- maven/surefire/trunk/surefire-shadefire/pom.xml (original) +++ maven/surefire/trunk/surefire-shadefire/pom.xml Mon Aug 13 19:33:34 2012 @@ -46,7 +46,6 @@ <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-utils</artifactId> - <version>3.0</version> </dependency> <dependency> <groupId>org.apache.maven.surefire</groupId>