Updated Branches: refs/heads/master d39c290e7 -> 00e31e5a8
o IT's now support embedded mode with maven 3.0.4 Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/00e31e5a Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/00e31e5a Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/00e31e5a Branch: refs/heads/master Commit: 00e31e5a8552b2264762726e8aee812561b872a0 Parents: d39c290 Author: Kristian Rosenvold <krosenv...@apache.org> Authored: Thu Dec 6 19:03:44 2012 +0100 Committer: Kristian Rosenvold <krosenv...@apache.org> Committed: Thu Dec 6 19:03:44 2012 +0100 ---------------------------------------------------------------------- .../surefire/StartupReportConfiguration.java | 2 +- .../plugin/surefire/booterclient/ForkStarter.java | 8 ++ .../surefire/booterclient/output/ForkClient.java | 10 +- .../plugin/surefire/report/ConsoleReporter.java | 13 +-- surefire-integration-tests/pom.xml | 90 +++++++-------- .../surefire/its/JUnit48TestCategoriesIT.java | 6 +- .../maven/surefire/its/WorkingDirectoryIT.java | 3 +- .../surefire/its/fixture/SurefireLauncher.java | 7 + .../src/test/java/forkMode/Test1.java | 2 +- .../fork-mode/src/test/java/forkMode/Test1.java | 8 +- .../surefire/junitcore/JUnitCoreProvider.java | 3 +- 11 files changed, 76 insertions(+), 76 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/00e31e5a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java ---------------------------------------------------------------------- diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java index a27ff54..b29ed38 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java @@ -162,7 +162,7 @@ public class StartupReportConfiguration public ConsoleReporter instantiateConsoleReporter() { - return shouldReportToConsole() ? new ConsoleReporter() : null; + return shouldReportToConsole() ? new ConsoleReporter(originalSystemOut) : null; } private boolean shouldReportToConsole() http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/00e31e5a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java ---------------------------------------------------------------------- diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java index a1ecc9b..31f2475 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java @@ -420,6 +420,14 @@ public class ForkStarter { runResult = fileReporterFactory.getGlobalRunStatistics().getRunResult(); } + if (!runResult.isTimeout() && !forkClient.isSaidGoodBye()) + { + //noinspection ThrowFromFinallyBlock + throw new RuntimeException( + "The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?" + + "\nCommand was" + cli.toString()); + } + forkClient.close( runResult.isTimeout()); } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/00e31e5a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java ---------------------------------------------------------------------- diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java index fa7d141..2d77085 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java @@ -267,11 +267,11 @@ public class ForkClient public void close(boolean hadTimeout) { - if ( !saidGoodBye && !hadTimeout) - { - throw new RuntimeException( - "The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?" ); - } + } + + public boolean isSaidGoodBye() + { + return saidGoodBye; } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/00e31e5a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleReporter.java ---------------------------------------------------------------------- diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleReporter.java index 50f6e2d..cecb461 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleReporter.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleReporter.java @@ -48,20 +48,13 @@ public class ConsoleReporter private static final int BUFFER_SIZE = 4096; - private static final PrintStream ORIGINAL_SYSTEM_OUT = System.out; - private final PrintWriter writer; - public ConsoleReporter() - { - this.writer = getPrintWriter(); - } - - private static PrintWriter getPrintWriter() + public ConsoleReporter( PrintStream originalSystemOut ) { - return new PrintWriter( - new OutputStreamWriter( new BufferedOutputStream( ORIGINAL_SYSTEM_OUT, BUFFER_SIZE ) ) ); + OutputStreamWriter out = new OutputStreamWriter( new BufferedOutputStream( originalSystemOut, BUFFER_SIZE ) ); + this.writer = new PrintWriter( out ); } public void testSetStarting( ReportEntry report ) http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/00e31e5a/surefire-integration-tests/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/pom.xml b/surefire-integration-tests/pom.xml index adc5cc4..9914a28 100644 --- a/surefire-integration-tests/pom.xml +++ b/surefire-integration-tests/pom.xml @@ -82,42 +82,6 @@ </dependencies> <build> - <pluginManagement> - <plugins> - <plugin> - <artifactId>maven-failsafe-plugin</artifactId> - <version>${shadedVersion}</version> - <configuration> - <threadCount>1</threadCount> - <perCoreThreadCount>false</perCoreThreadCount> - - <!-- Pass current surefire version to the main suite so that it --> - <!-- can forward to all integration test projects. SUREFIRE-513 --> - <systemPropertyVariables> - <surefire.version>${project.version}</surefire.version> - <testng.version>${testng.version}</testng.version> - <maven.home>${mavenHomeUsed}</maven.home> - <maven.settings.file> - ${project.basedir}/../surefire-setup-integration-tests/target/private/it-settings.xml - </maven.settings.file> - <maven.repo.local>${project.basedir}/../surefire-setup-integration-tests/target/it-repo</maven.repo.local> - <maven.test.tmpdir>${project.build.directory}</maven.test.tmpdir> - <user.localRepository>${settings.localRepository}</user.localRepository> - <useInterpolatedSettings>${useInterpolatedSettings}</useInterpolatedSettings> - <testBuildDirectory>${project.build.testOutputDirectory}</testBuildDirectory> - <verifier.forkMode>${verifier.forkMode}</verifier.forkMode> - </systemPropertyVariables> - </configuration> - <dependencies> - <dependency> - <groupId>org.apache.maven.surefire</groupId> - <artifactId>surefire-junit47</artifactId> - <version>${shadedVersion}</version> - </dependency> - </dependencies> - </plugin> - </plugins> - </pluginManagement> <plugins> <plugin> <artifactId>maven-surefire-plugin</artifactId> @@ -127,7 +91,35 @@ </plugin> <plugin> <artifactId>maven-failsafe-plugin</artifactId> - <version>${shadedVersion}</version> + <version>${project.version}</version> + <configuration> + <threadCount>1</threadCount> + <perCoreThreadCount>false</perCoreThreadCount> + <forkMode>never</forkMode> + <argLine>-Xmx512m -XX:MaxPermSize=256m</argLine> + <!-- Pass current surefire version to the main suite so that it --> + <!-- can forward to all integration test projects. SUREFIRE-513 --> + <systemPropertyVariables> + <surefire.version>${project.version}</surefire.version> + <testng.version>${testng.version}</testng.version> + <maven.home>${mavenHomeUsed}</maven.home> + <maven.settings.file>${project.basedir}/../surefire-setup-integration-tests/target/private/it-settings.xml</maven.settings.file> + <maven.repo.local>${project.basedir}/../surefire-setup-integration-tests/target/it-repo</maven.repo.local> + <maven.test.tmpdir>${project.build.directory}</maven.test.tmpdir> + <user.localRepository>${settings.localRepository}</user.localRepository> + <useInterpolatedSettings>${useInterpolatedSettings}</useInterpolatedSettings> + <testBuildDirectory>${project.build.testOutputDirectory}</testBuildDirectory> + <verifier.forkMode>${verifier.forkMode}</verifier.forkMode> + </systemPropertyVariables> + </configuration> + <dependencies> + <dependency> + <groupId>org.apache.maven.surefire</groupId> + <artifactId>surefire-junit47</artifactId> + <version>${shadedVersion}</version> + </dependency> + </dependencies> + <executions> <execution> <goals> @@ -172,19 +164,17 @@ <useInterpolatedSettings>false</useInterpolatedSettings> </properties> <build> - <pluginManagement> - <plugins> - <plugin> - <artifactId>maven-failsafe-plugin</artifactId> - <version>${shadedVersion}</version> - <configuration> - <parallel>classes</parallel> - <threadCount>${surefire.threadcount}</threadCount> - </configuration> - </plugin> - </plugins> - </pluginManagement> - + <plugins> + <plugin> + <artifactId>maven-failsafe-plugin</artifactId> + <version>${shadedVersion}</version> + <configuration> + <parallel>classes</parallel> + <threadCount>${surefire.threadcount}</threadCount> + <argLine>-Xmx2512m -XX:MaxPermSize=256m</argLine> + </configuration> + </plugin> + </plugins> </build> <dependencies> <dependency> http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/00e31e5a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit48TestCategoriesIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit48TestCategoriesIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit48TestCategoriesIT.java index 2844879..c3ad471 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit48TestCategoriesIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit48TestCategoriesIT.java @@ -43,7 +43,7 @@ public class JUnit48TestCategoriesIT public void testCategoriesABForkAlways() throws Exception { - runAB( unpacked().forkAlways() ); + runAB( unpacked() ); } private void runAB( SurefireLauncher unpacked ) @@ -56,7 +56,7 @@ public class JUnit48TestCategoriesIT public void testCategoriesAC() throws Exception { - runAC( unpacked().forkAlways() ); + runAC( unpacked()); } public void testCategoriesACForkAlways() @@ -81,7 +81,7 @@ public class JUnit48TestCategoriesIT private SurefireLauncher unpacked() throws VerificationException, IOException { - return unpack( "/junit48-categories" ); + return unpack( "/junit48-categories" ); // .debugSurefireFork(); } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/00e31e5a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/WorkingDirectoryIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/WorkingDirectoryIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/WorkingDirectoryIT.java index 9db2e6d..26848bd 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/WorkingDirectoryIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/WorkingDirectoryIT.java @@ -115,8 +115,7 @@ public class WorkingDirectoryIT // test if not a symlink if ( childTestDir.getBaseDir().getCanonicalFile().equals( childTestDir.getBaseDir().getAbsoluteFile() ) ) { - assertEquals( "wrong user.dir ! symlink ", childTestDir.getBaseDir().getAbsolutePath(), - userDir.getAbsolutePath() ); + assertTrue( "wrong user.dir ! symlink ", childTestDir.getBaseDir().getAbsolutePath().equalsIgnoreCase(userDir.getAbsolutePath())); } else { http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/00e31e5a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java index 0c0e1da..330b87e 100755 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; + import org.apache.commons.lang.text.StrSubstitutor; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; @@ -262,6 +263,12 @@ public class SurefireLauncher return this; } + public SurefireLauncher debugSurefireFork() + { + addD( "maven.surefire.debug", "true" ); + return this; + } + public SurefireLauncher failNever() { cliOptions.add( "-fn" ); http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/00e31e5a/surefire-integration-tests/src/test/resources/fork-mode-testng/src/test/java/forkMode/Test1.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/resources/fork-mode-testng/src/test/java/forkMode/Test1.java b/surefire-integration-tests/src/test/resources/fork-mode-testng/src/test/java/forkMode/Test1.java index 408550b..2a0f822 100644 --- a/surefire-integration-tests/src/test/resources/fork-mode-testng/src/test/java/forkMode/Test1.java +++ b/surefire-integration-tests/src/test/resources/fork-mode-testng/src/test/java/forkMode/Test1.java @@ -24,7 +24,7 @@ public class Test1 throws IOException { String fileName = name + "-pid"; - File target = new File( "target" ); + File target = new File( "target" ).getCanonicalFile(); if ( !( target.exists() && target.isDirectory() ) ) { target = new File( "." ); http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/00e31e5a/surefire-integration-tests/src/test/resources/fork-mode/src/test/java/forkMode/Test1.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/resources/fork-mode/src/test/java/forkMode/Test1.java b/surefire-integration-tests/src/test/resources/fork-mode/src/test/java/forkMode/Test1.java index 35f746e..01f1151 100644 --- a/surefire-integration-tests/src/test/resources/fork-mode/src/test/java/forkMode/Test1.java +++ b/surefire-integration-tests/src/test/resources/fork-mode/src/test/java/forkMode/Test1.java @@ -12,9 +12,9 @@ public class Test1 extends TestCase { - private static final Random RANDOM = new Random(); + private static final Random RANDOM = new Random(); - public void test1() + public void test1() throws IOException { dumpPidFile( this ); @@ -24,7 +24,7 @@ public class Test1 throws IOException { String fileName = test.getName() + "-pid"; - File target = new File( "target" ); + File target = new File( "target" ).getCanonicalFile(); // getCanonicalFile required for embedded mode if ( !( target.exists() && target.isDirectory() ) ) { target = new File( "." ); @@ -39,6 +39,8 @@ public class Test1 fw.write( System.getProperty( "testProperty", String.valueOf( RANDOM.nextLong() ) ) ); fw.flush(); fw.close(); + System.out.println( "Done Writing pid file" + pidFile.getAbsolutePath() ); } + } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/00e31e5a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java index 81ea524..b2608e8 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java @@ -25,6 +25,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; + import org.apache.maven.surefire.common.junit4.JUnit4RunListenerFactory; import org.apache.maven.surefire.common.junit4.JUnit4TestChecker; import org.apache.maven.surefire.common.junit48.FilterFactory; @@ -51,7 +52,7 @@ import org.junit.runner.manipulation.Filter; /** * @author Kristian Rosenvold */ -@SuppressWarnings( { "UnusedDeclaration" } ) +@SuppressWarnings({ "UnusedDeclaration" }) public class JUnitCoreProvider extends AbstractProvider {