Return-Path: Delivered-To: apmail-maven-surefire-commits-archive@www.apache.org Received: (qmail 15371 invoked from network); 21 Jan 2011 20:51:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 21 Jan 2011 20:51:54 -0000 Received: (qmail 23235 invoked by uid 500); 21 Jan 2011 20:51:54 -0000 Delivered-To: apmail-maven-surefire-commits-archive@maven.apache.org Received: (qmail 23193 invoked by uid 500); 21 Jan 2011 20:51:53 -0000 Mailing-List: contact surefire-commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: surefire-dev@maven.apache.org Delivered-To: mailing list surefire-commits@maven.apache.org Received: (qmail 23186 invoked by uid 99); 21 Jan 2011 20:51:53 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Jan 2011 20:51:53 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Jan 2011 20:51:46 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 22FFA2388900; Fri, 21 Jan 2011 20:51:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1062022 - in /maven/surefire/trunk: maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ maven-surefire-common/src/test/java/org/apache/mav... Date: Fri, 21 Jan 2011 20:51:23 -0000 To: surefire-commits@maven.apache.org From: krosenvold@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110121205124.22FFA2388900@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: krosenvold Date: Fri Jan 21 20:51:22 2011 New Revision: 1062022 URL: http://svn.apache.org/viewvc?rev=1062022&view=rev Log: [SUREFIRE-468] Report files on disk should not be present when fork times out Added: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/SurefireTimeoutMonitor.java - copied, changed from r1061478, maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractFileReporter.java maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractReporter.java maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/ForkingConsoleReporterTest.java maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java maven/surefire/trunk/surefire-integration-tests/src/test/resources/timeout-forked/pom.xml maven/surefire/trunk/surefire-integration-tests/src/test/resources/timeout-forked/src/test/java/timeoutForked/BasicTest.java maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManagerTest.java maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTestCase.java Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java?rev=1062022&r1=1062021&r2=1062022&view=diff ============================================================================== --- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java (original) +++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java Fri Jan 21 20:51:22 2011 @@ -227,8 +227,11 @@ public abstract class AbstractSurefireMo { List reports = getReporters( forkConfiguration.isForking() ); + Integer timeoutSet = + getForkedProcessTimeoutInSeconds() > 0 ? Integer.valueOf( getForkedProcessTimeoutInSeconds() ) : null; ReporterConfiguration reporterConfiguration = - new ReporterConfiguration( reports, getReportsDirectory(), Boolean.valueOf( isTrimStackTrace() ) ); + new ReporterConfiguration( reports, getReportsDirectory(), Boolean.valueOf( isTrimStackTrace() ), + timeoutSet ); surefireArtifact = (Artifact) getPluginArtifactMap().get( "org.apache.maven.surefire:surefire-booter" ); if ( surefireArtifact == null ) @@ -712,7 +715,7 @@ public abstract class AbstractSurefireMo protected void processSystemProperties( boolean setInSystem ) { - copyPropertiesToInternalSystemProperties( getSystemProperties() ); + copyPropertiesToInternalSystemProperties( getSystemProperties() ); if ( this.getSystemPropertyVariables() != null ) { @@ -735,7 +738,7 @@ public abstract class AbstractSurefireMo // Not gonna do THAT any more... instead, we only propagate those system properties // that have been explicitly specified by the user via -Dkey=value on the CLI - copyPropertiesToInternalSystemProperties( getUserProperties() ); + copyPropertiesToInternalSystemProperties( getUserProperties() ); getInternalSystemProperties().setProperty( "basedir", getBasedir().getAbsolutePath() ); getInternalSystemProperties().setProperty( "user.dir", getWorkingDirectory().getAbsolutePath() ); Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java?rev=1062022&r1=1062021&r2=1062022&view=diff ============================================================================== --- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java (original) +++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java Fri Jan 21 20:51:22 2011 @@ -103,8 +103,7 @@ public class BooterSerializer properties.addList( directoryScannerParameters.getExcludes(), BooterConstants.EXCLUDES_PROPERTY_PREFIX ); properties.setProperty( BooterConstants.TEST_CLASSES_DIRECTORY, directoryScannerParameters.getTestClassesDirectory() ); - properties.setProperty( BooterConstants.RUN_ORDER, - directoryScannerParameters.getRunOrder() ); + properties.setProperty( BooterConstants.RUN_ORDER, directoryScannerParameters.getRunOrder() ); } ReporterConfiguration reporterConfiguration = booterConfiguration.getReporterConfiguration(); @@ -114,6 +113,7 @@ public class BooterSerializer Boolean rep = reporterConfiguration.isTrimStackTrace(); properties.setProperty( BooterConstants.ISTRIMSTACKTRACE, rep ); properties.setProperty( BooterConstants.REPORTSDIRECTORY, reporterConfiguration.getReportsDirectory() ); + properties.setProperty( BooterConstants.FORKTIMEOUT, reporterConfiguration.getForkTimeout() ); ClassLoaderConfiguration classLoaderConfiguration = providerConfiguration.getClassLoaderConfiguration(); properties.setProperty( BooterConstants.USESYSTEMCLASSLOADER, String.valueOf( classLoaderConfiguration.isUseSystemClassLoader() ) ); 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=1062022&r1=1062021&r2=1062022&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 Fri Jan 21 20:51:22 2011 @@ -35,11 +35,7 @@ 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.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.cli.CommandLineException; -import org.codehaus.plexus.util.cli.CommandLineUtils; -import org.codehaus.plexus.util.cli.Commandline; -import org.codehaus.plexus.util.cli.StreamConsumer; +import org.apache.maven.surefire.suite.RunResult; import java.io.File; import java.io.FileInputStream; @@ -48,6 +44,13 @@ import java.io.IOException; import java.util.Iterator; import java.util.Properties; +import org.codehaus.plexus.util.IOUtil; +import org.codehaus.plexus.util.cli.CommandLineException; +import org.codehaus.plexus.util.cli.CommandLineTimeOutException; +import org.codehaus.plexus.util.cli.CommandLineUtils; +import org.codehaus.plexus.util.cli.Commandline; +import org.codehaus.plexus.util.cli.StreamConsumer; + /** * Starts the fork or runs in-process. @@ -225,7 +228,11 @@ public class ForkStarter try { - returnCode = CommandLineUtils.executeCommandLine( cli, out, err, forkedProcessTimeoutInSeconds ); + returnCode = CommandLineUtils.executeCommandLine( cli, out, err, forkedProcessTimeoutInSeconds > 0 ? forkedProcessTimeoutInSeconds + 1 : 0 ); + } + catch ( CommandLineTimeOutException e ) + { + returnCode = RunResult.FAILURE; } catch ( CommandLineException e ) { Modified: maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java?rev=1062022&r1=1062021&r2=1062022&view=diff ============================================================================== --- maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java (original) +++ maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java Fri Jan 21 20:51:22 2011 @@ -19,8 +19,6 @@ package org.apache.maven.plugin.surefire * under the License. */ -import junit.framework.Assert; -import junit.framework.TestCase; import org.apache.maven.surefire.booter.BooterDeserializer; import org.apache.maven.surefire.booter.ClassLoaderConfiguration; import org.apache.maven.surefire.booter.ClasspathConfiguration; @@ -40,6 +38,9 @@ import java.util.Arrays; import java.util.List; import java.util.Properties; +import junit.framework.Assert; +import junit.framework.TestCase; + /** * Performs roundtrip testing of serialization/deserialization of the ProviderConfiguration * @@ -74,7 +75,7 @@ public class BooterDeserializerProviderC ClassLoaderConfiguration forkConfiguration = getForkConfiguration(); final StartupConfiguration testStartupConfiguration = getTestStartupConfiguration( forkConfiguration ); - ProviderConfiguration providerConfiguration = getReloadedProviderConfiguration(new ArrayList( ) ); + ProviderConfiguration providerConfiguration = getReloadedProviderConfiguration( new ArrayList() ); ProviderConfiguration read = saveAndReload( providerConfiguration, testStartupConfiguration ); Assert.assertEquals( aDir, read.getBaseDir() ); @@ -98,7 +99,8 @@ public class BooterDeserializerProviderC reports.add( second ); reports.add( third ); - ProviderConfiguration providerConfiguration = getTestProviderConfiguration( directoryScannerParameters, reports ); + ProviderConfiguration providerConfiguration = + getTestProviderConfiguration( directoryScannerParameters, reports ); final ReporterConfiguration reporterConfiguration = providerConfiguration.getReporterConfiguration(); reporterConfiguration.getReports().add( first ); @@ -125,13 +127,13 @@ public class BooterDeserializerProviderC public void testTestRequest() throws IOException { - ProviderConfiguration reloaded = getReloadedProviderConfiguration(new ArrayList( ) ); + ProviderConfiguration reloaded = getReloadedProviderConfiguration( new ArrayList() ); TestRequest testSuiteDefinition = reloaded.getTestSuiteDefinition(); List suiteXmlFiles = testSuiteDefinition.getSuiteXmlFiles(); File[] expected = getSuiteXmlFiles(); - Assert.assertEquals( expected[0], suiteXmlFiles.get(0) ); - Assert.assertEquals( expected[1], suiteXmlFiles.get(1) ); + Assert.assertEquals( expected[0], suiteXmlFiles.get( 0 ) ); + Assert.assertEquals( expected[1], suiteXmlFiles.get( 1 ) ); Assert.assertEquals( getTestSourceDirectory(), testSuiteDefinition.getTestSourceDirectory() ); Assert.assertEquals( aUserRequestedTest, testSuiteDefinition.getRequestedTest() ); } @@ -195,7 +197,8 @@ public class BooterDeserializerProviderC { File cwd = new File( "." ); - ReporterConfiguration reporterConfiguration = new ReporterConfiguration( reports, cwd, Boolean.TRUE ); + ReporterConfiguration reporterConfiguration = + new ReporterConfiguration( reports, cwd, Boolean.TRUE, null ); TestRequest testSuiteDefinition = new TestRequest( getSuiteXmlFileStrings(), getTestSourceDirectory(), aUserRequestedTest ); return new ProviderConfiguration( directoryScannerParameters, true, reporterConfiguration, @@ -223,6 +226,6 @@ public class BooterDeserializerProviderC private List getSuiteXmlFileStrings() { - return Arrays.asList( new Object[]{ "A1", "A2" }); + return Arrays.asList( new Object[]{ "A1", "A2" } ); } } Modified: maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java?rev=1062022&r1=1062021&r2=1062022&view=diff ============================================================================== --- maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java (original) +++ maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java Fri Jan 21 20:51:22 2011 @@ -19,7 +19,6 @@ package org.apache.maven.plugin.surefire * under the License. */ -import junit.framework.TestCase; import org.apache.maven.surefire.booter.BooterConstants; import org.apache.maven.surefire.booter.BooterDeserializer; import org.apache.maven.surefire.booter.ClassLoaderConfiguration; @@ -39,6 +38,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Properties; +import junit.framework.TestCase; + /** * Performs roundtrip testing of serialization/deserialization of The StartupConfiguration * @@ -69,8 +70,8 @@ public class BooterDeserializerStartupCo assertEquals( "true", props.get( BooterConstants.CHILD_DELEGATION ) ); assertEquals( "CP1", classpathConfiguration.getTestClasspath().get( 0 ) ); assertEquals( "CP2", classpathConfiguration.getTestClasspath().get( 1 ) ); - assertEquals( "SP1", props.get( BooterConstants.SUREFIRE_CLASSPATHURL + "0" )); - assertEquals( "SP2", props.get( BooterConstants.SUREFIRE_CLASSPATHURL + "1" )); + assertEquals( "SP1", props.get( BooterConstants.SUREFIRE_CLASSPATHURL + "0" ) ); + assertEquals( "SP2", props.get( BooterConstants.SUREFIRE_CLASSPATHURL + "1" ) ); } public void testClassLoaderConfiguration() @@ -112,8 +113,7 @@ public class BooterDeserializerStartupCo private StartupConfiguration saveAndReload( StartupConfiguration startupConfiguration ) throws IOException { - final ForkConfiguration forkConfiguration = - ForkConfigurationTest.getForkConfiguration(); + final ForkConfiguration forkConfiguration = ForkConfigurationTest.getForkConfiguration(); Properties props = new Properties(); BooterSerializer booterSerializer = new BooterSerializer( forkConfiguration, props ); booterSerializer.serialize( getProviderConfiguration(), startupConfiguration, aTest ); @@ -130,9 +130,10 @@ public class BooterDeserializerStartupCo File cwd = new File( "." ); DirectoryScannerParameters directoryScannerParameters = new DirectoryScannerParameters( cwd, new ArrayList(), new ArrayList(), Boolean.TRUE, "hourly" ); - ReporterConfiguration reporterConfiguration = new ReporterConfiguration( new ArrayList(), cwd, Boolean.TRUE ); + ReporterConfiguration reporterConfiguration = + new ReporterConfiguration( new ArrayList(), cwd, Boolean.TRUE, null ); TestRequest testSuiteDefinition = - new TestRequest( Arrays.asList( getSuiteXmlFileStrings()), getTestSourceDirectory(), aUserRequestedTest ); + new TestRequest( Arrays.asList( getSuiteXmlFileStrings() ), getTestSourceDirectory(), aUserRequestedTest ); return new ProviderConfiguration( directoryScannerParameters, true, reporterConfiguration, new TestArtifactInfo( "5.0", "ABC" ), testSuiteDefinition, new Properties(), aTest ); Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java?rev=1062022&r1=1062021&r2=1062022&view=diff ============================================================================== --- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java (original) +++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java Fri Jan 21 20:51:22 2011 @@ -181,10 +181,11 @@ public class SurefireReflector Object createReporterConfiguration( ReporterConfiguration reporterConfiguration ) { Constructor constructor = ReflectionUtils.getConstructor( this.reporterConfiguration, - new Class[]{ List.class, File.class, - Boolean.class } ); + new Class[]{ List.class, File.class, Boolean.class, + Integer.class } ); return ReflectionUtils.newInstance( constructor, new Object[]{ reporterConfiguration.getReports(), - reporterConfiguration.getReportsDirectory(), reporterConfiguration.isTrimStackTrace() } ); + reporterConfiguration.getReportsDirectory(), reporterConfiguration.isTrimStackTrace(), + reporterConfiguration.getForkTimeout() } ); } public Object createBooterConfiguration() @@ -223,7 +224,7 @@ public class SurefireReflector void setTestSuiteDefinition( Object o, TestRequest testSuiteDefinition1 ) { final Object param = createTestRequest( testSuiteDefinition1 ); - ReflectionUtils.invokeSetter( o, "setTestRequest", this.testRequest, param ); + ReflectionUtils.invokeSetter( o, "setTestRequest", this.testRequest, param ); } public void setProviderPropertiesAware( Object o, Properties properties ) @@ -264,8 +265,8 @@ public class SurefireReflector void setTestClassLoader( Object o, ClassLoader surefireClassLoader, ClassLoader testClassLoader ) { - final Method setter = ReflectionUtils.getMethod( o, "setClassLoaders", - new Class[]{ ClassLoader.class, ClassLoader.class } ); + final Method setter = + ReflectionUtils.getMethod( o, "setClassLoaders", new Class[]{ ClassLoader.class, ClassLoader.class } ); ReflectionUtils.invokeMethodWithArray( o, setter, new Object[]{ surefireClassLoader, testClassLoader } ); } Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractFileReporter.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractFileReporter.java?rev=1062022&r1=1062021&r2=1062022&view=diff ============================================================================== --- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractFileReporter.java (original) +++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractFileReporter.java Fri Jan 21 20:51:22 2011 @@ -34,11 +34,15 @@ public abstract class AbstractFileReport { private File reportsDirectory; + private final boolean deleteOnStarting; + protected AbstractFileReporter( ReporterConfiguration reporterConfiguration, String format ) { super( reporterConfiguration, format ); this.reportsDirectory = reporterConfiguration.getReportsDirectory(); + + this.deleteOnStarting = reporterConfiguration.isForkWithTimeout(); } @@ -47,13 +51,19 @@ public abstract class AbstractFileReport { super.testSetStarting( report ); - File reportFile = new File( reportsDirectory, report.getName() + ".txt" ); + File reportFile = getReportFile( report ); File reportDir = reportFile.getParentFile(); //noinspection ResultOfMethodCallIgnored reportDir.mkdirs(); + if ( deleteOnStarting && reportFile.exists() ) + { + //noinspection ResultOfMethodCallIgnored + reportFile.delete(); + } + try { PrintWriter writer = new PrintWriter( new FileWriter( reportFile ) ); @@ -72,6 +82,11 @@ public abstract class AbstractFileReport } } + private File getReportFile( ReportEntry report ) + { + return new File( reportsDirectory, report.getName() + ".txt" ); + } + public void testSetCompleted( ReportEntry report ) throws ReporterException { @@ -82,5 +97,10 @@ public abstract class AbstractFileReport writer.close(); writer = null; + + if ( isTimedOut() ) + { + deleteIfExisting( getReportFile( report ) ); + } } } Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractReporter.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractReporter.java?rev=1062022&r1=1062021&r2=1062022&view=diff ============================================================================== --- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractReporter.java (original) +++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractReporter.java Fri Jan 21 20:51:22 2011 @@ -19,6 +19,7 @@ package org.apache.maven.surefire.report * under the License. */ +import java.io.File; import java.text.NumberFormat; import java.util.Locale; @@ -51,6 +52,8 @@ public abstract class AbstractReporter private boolean trimStackTrace; + private final ReporterConfiguration reporterConfiguration; + // ---------------------------------------------------------------------- // Report interface // ---------------------------------------------------------------------- @@ -58,12 +61,19 @@ public abstract class AbstractReporter protected AbstractReporter( ReporterConfiguration reporterConfiguration ) { + this.reporterConfiguration = reporterConfiguration; this.trimStackTrace = reporterConfiguration.isTrimStackTrace().booleanValue(); } protected AbstractReporter( Boolean trimStackTrace ) { this.trimStackTrace = trimStackTrace.booleanValue(); + this.reporterConfiguration = null; + } + + protected boolean isTimedOut() + { + return reporterConfiguration.isTimedOut(); } public void writeFooter( String footer ) @@ -221,4 +231,13 @@ public abstract class AbstractReporter public void testAssumptionFailure( ReportEntry report ) { } + + protected void deleteIfExisting( File reportFile ) + { + if ( reportFile.exists() ) + { + //noinspection ResultOfMethodCallIgnored + reportFile.delete(); + } + } } Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java?rev=1062022&r1=1062021&r2=1062022&view=diff ============================================================================== --- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java (original) +++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java Fri Jan 21 20:51:22 2011 @@ -22,6 +22,7 @@ package org.apache.maven.surefire.report import java.io.File; import java.io.PrintStream; import java.util.List; +import java.util.Timer; /** * @author Kristian Rosenvold @@ -36,16 +37,22 @@ public class ReporterConfiguration private final PrintStream originalSystemErr; + private final Integer forkTimeout; + /** * A non-null Boolean value */ private final Boolean trimStackTrace; - public ReporterConfiguration( List reports, File reportsDirectory, Boolean trimStackTrace ) + private volatile boolean timedOut = false; + + + public ReporterConfiguration( List reports, File reportsDirectory, Boolean trimStackTrace, Integer forkWithTimeout ) { this.reports = reports; this.reportsDirectory = reportsDirectory; this.trimStackTrace = trimStackTrace; + this.forkTimeout = forkWithTimeout; /* * While this may seem slightly odd, when this object is constructted no user code has been run * (including classloading), and we can be guaranteed that no-one has modified System.out/System.err. @@ -53,6 +60,13 @@ public class ReporterConfiguration */ this.originalSystemOut = System.out; this.originalSystemErr = System.err; + + } + + // todo: remove once we build with 2.7.2 + public ReporterConfiguration( List reports, File reportsDirectory, Boolean trimStackTrace ) + { + this( reports, reportsDirectory, trimStackTrace, null ); } /** @@ -107,4 +121,30 @@ public class ReporterConfiguration { return originalSystemErr; } + + /** + * Indicates that the test is running timed out, meaning this process could be abruptly killed. + * This will normally tell the reporter to delete result files upon startup. + * + * @return true if test run can be killed by timeout + */ + public boolean isForkWithTimeout() + { + return getForkTimeout() != null; + } + + public Integer getForkTimeout() + { + return forkTimeout; + } + + public void setTimedOut( boolean timedOut ) + { + this.timedOut = timedOut; + } + + public boolean isTimedOut() + { + return this.timedOut; + } } Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java?rev=1062022&r1=1062021&r2=1062022&view=diff ============================================================================== --- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java (original) +++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java Fri Jan 21 20:51:22 2011 @@ -27,6 +27,7 @@ import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.Timer; /** * Creates ReporterManager instances for the providers. @@ -63,6 +64,11 @@ public class ReporterManagerFactory private final SystemStreamCapturer systemStreamCapturer = new SystemStreamCapturer(); + private final SurefireTimeoutMonitor timeoutTask; + + private final Timer timer; + + public ReporterManagerFactory( List reportDefinitions, ClassLoader surefireClassLoader, ReporterConfiguration reporterConfiguration ) { @@ -70,6 +76,18 @@ public class ReporterManagerFactory this.surefireClassLoader = surefireClassLoader; this.reporterConfiguration = reporterConfiguration; this.reports = instantiateReportsNewStyle( reportDefinitions, reporterConfiguration, surefireClassLoader ); + if ( reporterConfiguration.getForkTimeout() != null ) + { + timeoutTask = new SurefireTimeoutMonitor( reporterConfiguration ); + timer = new Timer( "Surefire fork timeout timer" ); + } + else + { + timeoutTask = null; + timer = null; + } + + } public ReporterManagerFactory( ClassLoader surefireClassLoader, ReporterConfiguration reporterConfiguration ) @@ -84,6 +102,7 @@ public class ReporterManagerFactory public Reporter createReporter() { + startTimer(); reports = instantiateReportsNewStyle( reportDefinitions, reporterConfiguration, surefireClassLoader ); return setupReporter( reports ); } @@ -113,6 +132,7 @@ public class ReporterManagerFactory public RunResult close() { warnIfNoTests(); + cancelTimerIfActive(); synchronized ( lock ) { if ( first != null ) @@ -178,4 +198,21 @@ public class ReporterManagerFactory new MulticastingReporter( reports ).writeMessage( "There are no tests to run." ); } } + + public void startTimer() + { + if ( timer != null ) + { + timer.schedule( timeoutTask, reporterConfiguration.getForkTimeout().intValue() * 1000 ); + } + } + + public void cancelTimerIfActive() + { + if ( timer != null ) + { + timer.cancel(); + } + } + } Copied: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/SurefireTimeoutMonitor.java (from r1061478, maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java) URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/SurefireTimeoutMonitor.java?p2=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/SurefireTimeoutMonitor.java&p1=maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java&r1=1061478&r2=1062022&rev=1062022&view=diff ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java (original) +++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/SurefireTimeoutMonitor.java Fri Jan 21 20:51:22 2011 @@ -1,4 +1,5 @@ -package org.apache.maven.surefire.its; +package org.apache.maven.surefire.report; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,33 +19,30 @@ package org.apache.maven.surefire.its; * under the License. */ -import org.apache.maven.it.VerificationException; +import java.util.TimerTask; /** - * Test - * - * @author Dan Fabulich + * @author Kristian Rosenvold */ -public class TimeoutForkedTestIT - extends SurefireVerifierTestClass +class SurefireTimeoutMonitor + extends TimerTask { + private final Thread mainThread; + + private final ReporterConfiguration reporterConfiguration; - public TimeoutForkedTestIT() + public SurefireTimeoutMonitor( ReporterConfiguration reporterConfiguration ) { - super( "/timeout-forked" ); + this.mainThread = Thread.currentThread(); + this.reporterConfiguration = reporterConfiguration; } - public void testTimeoutForked() - throws Exception + public void run() { - try - { - executeTest(); - verifyErrorFreeLog(); - fail( "Build didn't fail, but it should have" ); - } - catch ( VerificationException ignore ) + reporterConfiguration.setTimedOut( true ); + synchronized ( mainThread ) { + mainThread.interrupt(); } } } Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java?rev=1062022&r1=1062021&r2=1062022&view=diff ============================================================================== --- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java (original) +++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java Fri Jan 21 20:51:22 2011 @@ -19,6 +19,11 @@ package org.apache.maven.surefire.report * under the License. */ +import org.apache.maven.surefire.util.PrettyPrintXMLWriter; +import org.codehaus.plexus.util.IOUtil; +import org.codehaus.plexus.util.xml.Xpp3Dom; +import org.codehaus.plexus.util.xml.Xpp3DomWriter; + import java.io.BufferedWriter; import java.io.File; import java.io.FileNotFoundException; @@ -34,11 +39,6 @@ import java.util.List; import java.util.Properties; import java.util.StringTokenizer; -import org.apache.maven.surefire.util.PrettyPrintXMLWriter; -import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.xml.Xpp3Dom; -import org.codehaus.plexus.util.xml.Xpp3DomWriter; - /** * XML format reporter. * @@ -52,6 +52,9 @@ public class XMLReporter private File reportsDirectory; + private final boolean deleteOnStarting; + + private List results = Collections.synchronizedList( new ArrayList() ); public XMLReporter( ReporterConfiguration reporterConfiguration ) @@ -59,16 +62,8 @@ public class XMLReporter super( reporterConfiguration ); this.reportsDirectory = reporterConfiguration.getReportsDirectory(); - } - /** - * @deprecated Can be removed once we build surfire with 2.7 - */ - public XMLReporter( File reportsDirectory, Boolean trimStackTrace ) - { - super( trimStackTrace ); - - this.reportsDirectory = reportsDirectory; + this.deleteOnStarting = reporterConfiguration.isForkWithTimeout(); } @@ -80,11 +75,28 @@ public class XMLReporter { } + + public void testSetStarting( ReportEntry report ) + throws ReporterException + { + super.testSetStarting( report ); + + if ( deleteOnStarting ) + { + final File reportFile = getReportFile( report ); + deleteIfExisting( reportFile ); + } + } + public void testSetCompleted( ReportEntry report ) throws ReporterException { super.testSetCompleted( report ); + if ( isTimedOut() ) + { + return; + } long runTime = System.currentTimeMillis() - testSetStartTime; Xpp3Dom testSuite = createTestSuiteElement( report, runTime ); @@ -105,7 +117,7 @@ public class XMLReporter testSuite.addChild( testcase ); } - File reportFile = new File( reportsDirectory, "TEST-" + report.getName() + ".xml" ); + File reportFile = getReportFile( report ); File reportDir = reportFile.getParentFile(); @@ -137,6 +149,11 @@ public class XMLReporter } } + private File getReportFile( ReportEntry report ) + { + return new File( reportsDirectory, "TEST-" + report.getName() + ".xml" ); + } + private String getReportName( ReportEntry report ) { String reportName; @@ -156,7 +173,7 @@ public class XMLReporter { super.testSucceeded( report ); - long runTime = getActualRunTime( report ); + long runTime = getActualRunTime( report ); Xpp3Dom testCase = createTestElement( report, runTime ); Modified: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/ForkingConsoleReporterTest.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/ForkingConsoleReporterTest.java?rev=1062022&r1=1062021&r2=1062022&view=diff ============================================================================== --- maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/ForkingConsoleReporterTest.java (original) +++ maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/ForkingConsoleReporterTest.java Fri Jan 21 20:51:22 2011 @@ -42,7 +42,7 @@ public class ForkingConsoleReporterTest public static ReporterConfiguration getTestReporterConfiguration() { - return new ReporterConfiguration( new ArrayList(), null, Boolean.TRUE ); + return new ReporterConfiguration( new ArrayList(), null, Boolean.TRUE, null ); } } Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java?rev=1062022&r1=1062021&r2=1062022&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java (original) +++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java Fri Jan 21 20:51:22 2011 @@ -22,6 +22,7 @@ package org.apache.maven.surefire.booter /** * Constants used by the serializer/deserializer + * * @author Kristian Rosenvold */ public interface BooterConstants @@ -42,6 +43,7 @@ public interface BooterConstants String FAILIFNOTESTS = "failIfNoTests"; String ISTRIMSTACKTRACE = "isTrimStackTrace"; String REPORTSDIRECTORY = "reportsDirectory"; + String FORKTIMEOUT = "forkTimeout"; String TESTARTIFACT_VERSION = "testFwJarVersion"; String TESTARTIFACT_CLASSIFIER = "testFwJarClassifier"; String REQUESTEDTEST = "requestedTest"; Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java?rev=1062022&r1=1062021&r2=1062022&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java (original) +++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java Fri Jan 21 20:51:22 2011 @@ -23,7 +23,6 @@ import org.apache.maven.surefire.report. import org.apache.maven.surefire.testset.DirectoryScannerParameters; import org.apache.maven.surefire.testset.TestArtifactInfo; import org.apache.maven.surefire.testset.TestRequest; -import org.apache.maven.surefire.util.internal.StringUtils; import java.io.File; import java.io.IOException; @@ -62,6 +61,7 @@ public class BooterDeserializer { final File reportsDirectory = new File( properties.getProperty( REPORTSDIRECTORY ) ); + Integer timeout = properties.getIntegerObjectProperty( FORKTIMEOUT ); final String testNgVersion = properties.getProperty( TESTARTIFACT_VERSION ); final String testArtifactClassifier = properties.getProperty( TESTARTIFACT_CLASSIFIER ); final Object testForFork = properties.getTypeDecoded( FORKTESTSET ); @@ -78,14 +78,14 @@ public class BooterDeserializer DirectoryScannerParameters dirScannerParams = new DirectoryScannerParameters( testClassesDirectory, includesList, excludesList, - valueOf( properties.getBooleanProperty( FAILIFNOTESTS ) ), runOrder ); + properties.getBooleanObjectProperty( FAILIFNOTESTS ), runOrder ); TestArtifactInfo testNg = new TestArtifactInfo( testNgVersion, testArtifactClassifier ); TestRequest testSuiteDefinition = new TestRequest( testSuiteXmlFiles, sourceDirectory, requestedTest ); - ReporterConfiguration reporterConfiguration = - new ReporterConfiguration( reports, reportsDirectory, - valueOf( properties.getBooleanProperty( ISTRIMSTACKTRACE ) ) ); + ReporterConfiguration reporterConfiguration = new ReporterConfiguration( reports, reportsDirectory, + properties.getBooleanObjectProperty( + ISTRIMSTACKTRACE ), timeout ); return new ProviderConfiguration( dirScannerParams, properties.getBooleanProperty( FAILIFNOTESTS ), reporterConfiguration, testNg, testSuiteDefinition, @@ -101,7 +101,6 @@ public class BooterDeserializer boolean useManifestOnlyJar = properties.getBooleanProperty( USEMANIFESTONLYJAR ); String providerConfiguration = properties.getProperty( PROVIDER_CONFIGURATION ); - final List classpath = properties.getStringList( CLASSPATH_URL ); final List sureFireClasspath = properties.getStringList( SUREFIRE_CLASSPATHURL ); Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java?rev=1062022&r1=1062021&r2=1062022&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java (original) +++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java Fri Jan 21 20:51:22 2011 @@ -24,7 +24,10 @@ import org.apache.maven.surefire.util.in import java.io.ByteArrayInputStream; import java.io.File; -import java.util.*; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Properties; /** * @author Kristian Rosenvold @@ -68,6 +71,17 @@ public class PropertiesWrapper return aBoolean.booleanValue(); } + public Boolean getBooleanObjectProperty( String propertyName ) + { + return Boolean.valueOf( properties.getProperty( propertyName ) ); + } + + public Integer getIntegerObjectProperty( String propertyName ) + { + String property = properties.getProperty( propertyName ); + return property != null ? Integer.valueOf( property ) : null; + } + public File getFileProperty( String key ) { final String property = getProperty( key ); @@ -219,6 +233,15 @@ public class PropertiesWrapper } } + public void setProperty( String key, Integer integer ) + { + if ( integer != null ) + { + setProperty( key, integer.toString() ); + } + } + + public void setProperty( String key, String value ) { if ( value != null ) Modified: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java?rev=1062022&r1=1062021&r2=1062022&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java (original) +++ maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java Fri Jan 21 20:51:22 2011 @@ -2,7 +2,8 @@ package org.apache.maven.surefire.booter /* * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file + * or more contributor lice +nse agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the @@ -19,7 +20,6 @@ package org.apache.maven.surefire.booter * under the License. */ -import junit.framework.TestCase; import org.apache.maven.surefire.report.ReporterConfiguration; import org.apache.maven.surefire.testset.DirectoryScannerParameters; import org.apache.maven.surefire.testset.TestArtifactInfo; @@ -32,6 +32,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Properties; +import junit.framework.TestCase; + /** * @author Kristian Rosenvold */ @@ -45,9 +47,10 @@ public class SurefireReflectorTest Object foo = getFoo(); DirectoryScannerParameters directoryScannerParameters = - new DirectoryScannerParameters( new File( "ABC" ), new ArrayList(), new ArrayList(), Boolean.FALSE, "hourly" ); + new DirectoryScannerParameters( new File( "ABC" ), new ArrayList(), new ArrayList(), Boolean.FALSE, + "hourly" ); surefireReflector.setDirectoryScannerParameters( foo, directoryScannerParameters ); - assertTrue( isCalled( foo ).booleanValue()); + assertTrue( isCalled( foo ).booleanValue() ); } @@ -58,7 +61,8 @@ public class SurefireReflectorTest Object foo = getFoo(); TestRequest testSuiteDefinition = - new TestRequest( Arrays.asList( new File[]{new File("file1"),new File("file2")} ), new File( "TestSOurce" ), "aUserRequestedTest" ); + new TestRequest( Arrays.asList( new File[]{ new File( "file1" ), new File( "file2" ) } ), + new File( "TestSOurce" ), "aUserRequestedTest" ); surefireReflector.setTestSuiteDefinition( foo, testSuiteDefinition ); assertTrue( isCalled( foo ).booleanValue() ); } @@ -86,7 +90,7 @@ public class SurefireReflectorTest private ReporterConfiguration getReporterConfiguration() { - return new ReporterConfiguration( new ArrayList(), new File( "CDE" ), Boolean.TRUE ); + return new ReporterConfiguration( new ArrayList(), new File( "CDE" ), Boolean.TRUE, null ); } public void testTestClassLoaderAware() @@ -121,12 +125,13 @@ public class SurefireReflectorTest } - private Boolean isCalled(Object foo){ + private Boolean isCalled( Object foo ) + { final Method isCalled; try { isCalled = foo.getClass().getMethod( "isCalled", new Class[0] ); - return (Boolean) isCalled.invoke( foo, new Object[0] ); + return (Boolean) isCalled.invoke( foo, new Object[0] ); } catch ( IllegalAccessException e ) { Modified: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java?rev=1062022&r1=1062021&r2=1062022&view=diff ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java (original) +++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TimeoutForkedTestIT.java Fri Jan 21 20:51:22 2011 @@ -39,6 +39,8 @@ public class TimeoutForkedTestIT { try { + addGoal( "-DsleepLength=10000" ); + addGoal( "-DforkTimeout=1" ); executeTest(); verifyErrorFreeLog(); fail( "Build didn't fail, but it should have" ); @@ -46,5 +48,7 @@ public class TimeoutForkedTestIT catch ( VerificationException ignore ) { } + assertFalse( getSurefireReportsFile( "TEST-timeoutForked.BasicTest.xml" ).exists() ); + assertFalse( getSurefireReportsFile( "timeoutForked.BasicTest.txt" ).exists() ); } } Modified: maven/surefire/trunk/surefire-integration-tests/src/test/resources/timeout-forked/pom.xml URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/timeout-forked/pom.xml?rev=1062022&r1=1062021&r2=1062022&view=diff ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/resources/timeout-forked/pom.xml (original) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/timeout-forked/pom.xml Fri Jan 21 20:51:22 2011 @@ -34,7 +34,8 @@ maven-surefire-plugin ${surefire.version} - 3 + ${forkTimeout} + plain Modified: maven/surefire/trunk/surefire-integration-tests/src/test/resources/timeout-forked/src/test/java/timeoutForked/BasicTest.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/timeout-forked/src/test/java/timeoutForked/BasicTest.java?rev=1062022&r1=1062021&r2=1062022&view=diff ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/resources/timeout-forked/src/test/java/timeoutForked/BasicTest.java (original) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/timeout-forked/src/test/java/timeoutForked/BasicTest.java Fri Jan 21 20:51:22 2011 @@ -11,7 +11,8 @@ public class BasicTest public void testSleep() throws Exception { - Thread.sleep(10000); + int sleepLength = Integer.valueOf( System.getProperty( "sleepLength", "10000" )); + Thread.sleep(sleepLength); } } Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManagerTest.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManagerTest.java?rev=1062022&r1=1062021&r2=1062022&view=diff ============================================================================== --- maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManagerTest.java (original) +++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManagerTest.java Fri Jan 21 20:51:22 2011 @@ -20,6 +20,9 @@ package org.apache.maven.surefire.junitcore; +import junit.framework.Assert; +import junit.framework.TestCase; +import junit.framework.TestSuite; import org.apache.maven.surefire.report.ConsoleReporter; import org.apache.maven.surefire.report.Reporter; import org.apache.maven.surefire.report.ReporterConfiguration; @@ -27,6 +30,11 @@ import org.apache.maven.surefire.report. import org.apache.maven.surefire.report.ReporterManagerFactory; import org.apache.maven.surefire.report.RunStatistics; import org.apache.maven.surefire.testset.TestSetFailedException; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.Computer; +import org.junit.runner.JUnitCore; +import org.junit.runner.notification.RunListener; import java.io.ByteArrayOutputStream; import java.io.File; @@ -36,15 +44,6 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import junit.framework.Assert; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.Computer; -import org.junit.runner.JUnitCore; -import org.junit.runner.notification.RunListener; - import static junit.framework.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -225,7 +224,7 @@ public class ConcurrentReporterManagerTe public ReporterConfiguration getReporterConfiguration() { - return new ReporterConfiguration( new ArrayList(), new File( "." ), true ); + return new ReporterConfiguration( new ArrayList(), new File( "." ), true, null ); } @@ -422,7 +421,8 @@ public class ConcurrentReporterManagerTe public static ReporterConfiguration getTestReporterConfiguration() { - return new ReporterConfiguration( Arrays.asList( ConsoleReporter.class.getName() ), null, Boolean.TRUE ); + return new ReporterConfiguration( Arrays.asList( ConsoleReporter.class.getName() ), null, Boolean.TRUE, + null ); } Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTestCase.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTestCase.java?rev=1062022&r1=1062021&r2=1062022&view=diff ============================================================================== --- maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTestCase.java (original) +++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTestCase.java Fri Jan 21 20:51:22 2011 @@ -155,7 +155,7 @@ public class MavenSurefireJUnit47RunnerT private ReporterConfiguration getReporterConfiguration() { - return new ReporterConfiguration( new ArrayList(), new File( "." ), true ); + return new ReporterConfiguration( new ArrayList(), new File( "." ), true, null ); } /**