You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2015/02/01 01:00:19 UTC

[1/3] maven-surefire git commit: SUREFIRE-1136 Current working directory propagation in forked mode - ignore testExceptionWhenCurrentDirectoryCannotBeCreated under certain conditions.

Repository: maven-surefire
Updated Branches:
  refs/heads/master 60111e78f -> 2b4629c71


SUREFIRE-1136 Current working directory propagation in forked mode - ignore testExceptionWhenCurrentDirectoryCannotBeCreated under certain conditions.


Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/d6a8af59
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/d6a8af59
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/d6a8af59

Branch: refs/heads/master
Commit: d6a8af593fc03e12ecf2dc8047669472f7ca263b
Parents: 60111e7
Author: norbertwnuk <no...@gmail.com>
Authored: Wed Jan 28 02:51:39 2015 +0100
Committer: norbertwnuk <no...@gmail.com>
Committed: Wed Jan 28 03:25:14 2015 +0100

----------------------------------------------------------------------
 .../booterclient/ForkConfigurationTest.java     | 25 +++++++++++++++-----
 1 file changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d6a8af59/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java
index b3d2151..4f62670 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java
@@ -26,6 +26,7 @@ import java.util.Properties;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.RandomStringUtils;
+import org.apache.commons.lang3.SystemUtils;
 import org.apache.maven.shared.utils.StringUtils;
 import org.apache.maven.shared.utils.cli.Commandline;
 import org.apache.maven.surefire.booter.Classpath;
@@ -122,7 +123,9 @@ public class ForkConfigurationTest
         baseDir.mkdirs();
         baseDir.deleteOnExit();
 
-        File cwd = new File( baseDir, "?\0InvalidDirectoryName" );
+        // NULL is invalid for JDK starting from 1.7.60 - https://github.com/openjdk-mirror/jdk/commit/e5389115f3634d25d101e2dcc71f120d4fd9f72f
+        // ? character is invalid on Windows, seems to be imposable to create invalid directory using Java on Linux
+        File cwd = new File( baseDir, "?\u0000InvalidDirectoryName" );
         ForkConfiguration config = getForkConfiguration( null, "java", cwd.getAbsoluteFile() );
 
         try
@@ -135,7 +138,10 @@ public class ForkConfigurationTest
             return;
         }
 
-        fail();
+        if ( SystemUtils.IS_OS_WINDOWS || isJavaVersionAtLeast( 7, 60 ) )
+        {
+            fail();
+        }
     }
 
     private File getTempClasspathFile()
@@ -147,10 +153,10 @@ public class ForkConfigurationTest
     }
 
     public static ForkConfiguration getForkConfiguration( String argLine, String jvm )
-    throws IOException
-{
-    return getForkConfiguration( argLine, jvm, new File( "." ).getCanonicalFile() );
-}
+        throws IOException
+    {
+        return getForkConfiguration( argLine, jvm, new File( "." ).getCanonicalFile() );
+    }
 
     public static ForkConfiguration getForkConfiguration( String argLine, String jvm, File cwd )
         throws IOException
@@ -159,4 +165,11 @@ public class ForkConfigurationTest
                                       false, 1, false );
     }
 
+    // based on http://stackoverflow.com/questions/2591083/getting-version-of-java-in-runtime
+    private boolean isJavaVersionAtLeast( int major, int update )
+    {
+        String[] javaVersionElements = System.getProperty( "java.runtime.version" ).split( "\\.|_|-b" );
+        return Integer.valueOf( javaVersionElements[1] ) >= major
+            && Integer.valueOf( javaVersionElements[4] ) >= update;
+    }
 }


[3/3] maven-surefire git commit: SUREFIRE-1136 Current working directory propagation in forked mode - add documentation.

Posted by ti...@apache.org.
SUREFIRE-1136 Current working directory propagation in forked mode - add documentation.


Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/2b4629c7
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/2b4629c7
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/2b4629c7

Branch: refs/heads/master
Commit: 2b4629c71e5c82716d99a738f02063c90413253f
Parents: 9a8bb17
Author: Norbert Wnuk <no...@sabre.com>
Authored: Sat Jan 31 21:57:46 2015 +0100
Committer: Norbert Wnuk <no...@sabre.com>
Committed: Sat Jan 31 22:21:55 2015 +0100

----------------------------------------------------------------------
 .../examples/fork-options-and-parallel-execution.apt.vm  | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/2b4629c7/maven-surefire-plugin/src/site/apt/examples/fork-options-and-parallel-execution.apt.vm
----------------------------------------------------------------------
diff --git a/maven-surefire-plugin/src/site/apt/examples/fork-options-and-parallel-execution.apt.vm b/maven-surefire-plugin/src/site/apt/examples/fork-options-and-parallel-execution.apt.vm
index 6b9d046..271f58c 100644
--- a/maven-surefire-plugin/src/site/apt/examples/fork-options-and-parallel-execution.apt.vm
+++ b/maven-surefire-plugin/src/site/apt/examples/fork-options-and-parallel-execution.apt.vm
@@ -190,7 +190,8 @@ Fork Options and Parallel Test Execution
   <databaseSchema> is passed to the processes, that shall specify the database
   schema to use during the tests. The values for that will be
   <MY_TEST_SCHEMA_1>, <MY_TEST_SCHEMA_2>, and <MY_TEST_SCHEMA_3> for the three
-  processes.
+  processes. Additionaly by specifying custom <workingDirectory> each of processes
+  will be executed in a separate working directory to ensure isolation on file system level.
 
 +---+
 <plugins>
@@ -206,6 +207,7 @@ Fork Options and Parallel Test Execution
         <systemPropertyVariables>
             <databaseSchema>MY_TEST_SCHEMA_${surefire.forkNumber}</databaseSchema>
         </systemPropertyVariables>
+        <workingDirectory>FORK_DIRECTORY_${surefire.forkNumber}</workingDirectory>
     </configuration>
   </plugin>
 [...]
@@ -270,3 +272,10 @@ Fork Options and Parallel Test Execution
                            | had that one set)                         |
 *--------------------------+-------------------------------------------+
 
+* Known issues and limitations
+
+ * <<<$\{surefire.forkNumber\}>>> propagation is not supported on Maven 2.x
+   (the variable will be resolved to null value all the time)
+
+ * <<<$\{surefire.forkNumber\}>>> is properly propagated within <<<workingDirectory>>> since Surefire 2.19,
+   more details in {{{https://jira.codehaus.org/browse/SUREFIRE-1136}SUREFIRE-1136}}


[2/3] maven-surefire git commit: SUREFIRE-1136 Current working directory propagation in forked mode - mark CurrentWorkingDirectoryInForkedModeTest as not compatible with maven 2.x since ${surefire.forkNumber} expansion cannot work on this version.

Posted by ti...@apache.org.
SUREFIRE-1136 Current working directory propagation in forked mode - mark CurrentWorkingDirectoryInForkedModeTest as not compatible with maven 2.x since ${surefire.forkNumber} expansion cannot work on this version.


Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/9a8bb172
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/9a8bb172
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/9a8bb172

Branch: refs/heads/master
Commit: 9a8bb172cae84fe89f597843560056def30bd351
Parents: d6a8af5
Author: norbertwnuk <no...@gmail.com>
Authored: Sat Jan 31 00:38:31 2015 +0100
Committer: norbertwnuk <no...@gmail.com>
Committed: Sat Jan 31 10:08:10 2015 +0100

----------------------------------------------------------------------
 .../its/jiras/Surefire1136CwdPropagationInForkedModeIT.java  | 8 +++++++-
 .../java/cwd/CurrentWorkingDirectoryInForkedModeTest.java    | 6 +++---
 2 files changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/9a8bb172/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1136CwdPropagationInForkedModeIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1136CwdPropagationInForkedModeIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1136CwdPropagationInForkedModeIT.java
index bcd6f2a..cd6de87 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1136CwdPropagationInForkedModeIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1136CwdPropagationInForkedModeIT.java
@@ -19,15 +19,21 @@ package org.apache.maven.surefire.its.jiras;
  * under the License.
  */
 
+import org.apache.maven.surefire.its.Not2xCompatible;
 import org.apache.maven.surefire.its.fixture.OutputValidator;
 import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 /**
- * SUREFIRE-1136 Correct current working directory propagation
+ * SUREFIRE-1136 Correct current working directory propagation in forked mode
+ *
+ * Note: variables expansion behaves differently on MVN 2.x since not existing variables
+ * are resolved to 'null' value so that ${surefire.forkNumber} cannot work.
  *
  * @author Norbert Wnuk
  */
+@Category( Not2xCompatible.class )
 public class Surefire1136CwdPropagationInForkedModeIT
     extends SurefireJUnit4IntegrationTestCase
 {

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/9a8bb172/surefire-integration-tests/src/test/resources/surefire-1136-cwd-propagation-in-forked-mode/src/test/java/cwd/CurrentWorkingDirectoryInForkedModeTest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-1136-cwd-propagation-in-forked-mode/src/test/java/cwd/CurrentWorkingDirectoryInForkedModeTest.java b/surefire-integration-tests/src/test/resources/surefire-1136-cwd-propagation-in-forked-mode/src/test/java/cwd/CurrentWorkingDirectoryInForkedModeTest.java
index 9dc0ffe..6a82ee3 100644
--- a/surefire-integration-tests/src/test/resources/surefire-1136-cwd-propagation-in-forked-mode/src/test/java/cwd/CurrentWorkingDirectoryInForkedModeTest.java
+++ b/surefire-integration-tests/src/test/resources/surefire-1136-cwd-propagation-in-forked-mode/src/test/java/cwd/CurrentWorkingDirectoryInForkedModeTest.java
@@ -39,9 +39,9 @@ public class CurrentWorkingDirectoryInForkedModeTest
         forkDirectory.deleteOnExit();
 
         // user.dir and current working directory must be aligned, base directory is not affected
-        assertEquals( System.getProperty( "basedir" ), projectDirectory.getCanonicalPath() );
-        assertEquals( System.getProperty( "user.dir" ), forkDirectory.getCanonicalPath() );
-        assertEquals( new File( "." ).getCanonicalPath(), forkDirectory.getCanonicalPath() );
+        assertEquals( projectDirectory.getCanonicalPath(), System.getProperty( "basedir" ) );
+        assertEquals( forkDirectory.getCanonicalPath(), System.getProperty( "user.dir" ) );
+        assertEquals( forkDirectory.getCanonicalPath(), new File( "." ).getCanonicalPath() );
 
         // original working directory (before variable expansion) should not be created
         assertFalse( new File( "cwd_${surefire.forkNumber}" ).exists() );