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 2018/11/25 18:10:32 UTC

[maven-surefire] branch SUREFIRE-1568 updated (7941c2d -> f308c20)

This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a change to branch SUREFIRE-1568
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git.


 discard 7941c2d  [SUREFIRE-1568] Versions 2.21 and higher doesn't work with junit-platform for Java 9 module
     new f308c20  [SUREFIRE-1568] Versions 2.21 and higher doesn't work with junit-platform for Java 9 module

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (7941c2d)
            \
             N -- N -- N   refs/heads/SUREFIRE-1568 (f308c20)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../ModularClasspathForkConfigurationTest.java     | 58 +++++++++++++++-------
 surefire-its/pom.xml                               |  2 +-
 2 files changed, 40 insertions(+), 20 deletions(-)


[maven-surefire] 01/01: [SUREFIRE-1568] Versions 2.21 and higher doesn't work with junit-platform for Java 9 module

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch SUREFIRE-1568
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit f308c20e1509f69c79a9e41db55b52007004fb34
Author: Tibor17 <ti...@apache.org>
AuthorDate: Sun Nov 25 15:33:02 2018 +0100

    [SUREFIRE-1568] Versions 2.21 and higher doesn't work with junit-platform for Java 9 module
---
 .../ModularClasspathForkConfiguration.java         | 30 +++++++----
 .../ModularClasspathForkConfigurationTest.java     | 58 +++++++++++++++-------
 .../maven/surefire/its/AbstractJigsawIT.java       |  7 ++-
 .../apache/maven/surefire/its/ModulePathIT.java    | 20 ++++++++
 4 files changed, 84 insertions(+), 31 deletions(-)

diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java
index fb8c86a..f53a449 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java
@@ -131,50 +131,58 @@ public class ModularClasspathForkConfiguration
             StringBuilder args = new StringBuilder( 64 * 1024 );
             if ( !modulePath.isEmpty() )
             {
+                // https://docs.oracle.com/en/java/javase/11/tools/java.html#GUID-4856361B-8BFD-4964-AE84-121F5F6CF111
                 args.append( "--module-path" )
-                        .append( ' ' );
+                        .append( NL )
+                        .append( '"' );
 
                 for ( Iterator<String> it = modulePath.iterator(); it.hasNext(); )
                 {
-                    args.append( it.next() );
+                    args.append( replace( it.next(), "\\", "\\\\" ) );
                     if ( it.hasNext() )
                     {
                         args.append( pathSeparatorChar );
                     }
                 }
 
-                args.append( NL );
+                args.append( '"' )
+                        .append( NL );
             }
 
             if ( !classPath.isEmpty() )
             {
                 args.append( "--class-path" )
-                        .append( ' ' );
+                        .append( NL )
+                        .append( '"' );
+
                 for ( Iterator<String> it = classPath.iterator(); it.hasNext(); )
                 {
-                    args.append( it.next() );
+                    args.append( replace( it.next(), "\\", "\\\\" ) );
                     if ( it.hasNext() )
                     {
                         args.append( pathSeparatorChar );
                     }
                 }
 
-                args.append( NL );
+                args.append( '"' )
+                        .append( NL );
             }
 
             final String moduleName = toModuleName( moduleDescriptor );
 
             args.append( "--patch-module" )
-                    .append( ' ' )
+                    .append( NL )
                     .append( moduleName )
                     .append( '=' )
-                    .append( patchFile.getPath() )
+                    .append( '"' )
+                    .append( replace( patchFile.getPath(), "\\", "\\\\" ) )
+                    .append( '"' )
                     .append( NL );
 
             for ( String pkg : packages )
             {
                 args.append( "--add-exports" )
-                        .append( ' ' )
+                        .append( NL )
                         .append( moduleName )
                         .append( '/' )
                         .append( pkg )
@@ -184,12 +192,12 @@ public class ModularClasspathForkConfiguration
             }
 
             args.append( "--add-modules" )
-                    .append( ' ' )
+                    .append( NL )
                     .append( moduleName )
                     .append( NL );
 
             args.append( "--add-reads" )
-                    .append( ' ' )
+                    .append( NL )
                     .append( moduleName )
                     .append( '=' )
                     .append( "ALL-UNNAMED" )
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfigurationTest.java
index c2b327e..d129df3 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfigurationTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfigurationTest.java
@@ -37,12 +37,14 @@ import java.util.List;
 import java.util.Properties;
 
 import static java.io.File.createTempFile;
+import static java.io.File.pathSeparatorChar;
 import static java.io.File.separator;
-import static java.io.File.pathSeparator;
+import static java.io.File.separatorChar;
 import static java.nio.charset.StandardCharsets.UTF_8;
 import static java.nio.file.Files.readAllLines;
 import static java.util.Arrays.asList;
 import static java.util.Collections.singleton;
+import static org.apache.maven.shared.utils.StringUtils.replace;
 import static org.fest.assertions.Assertions.assertThat;
 
 /**
@@ -73,10 +75,11 @@ public class ModularClasspathForkConfigurationTest
             }
         };
 
-        File patchFile = new File( "target" + separator + "test-classes" );
+        File patchFile = new File( "target" + separatorChar + "test-classes" );
         File descriptor = new File( tmp, "module-info.class" );
         descriptor.createNewFile();
-        List<String> modulePath = asList( "modular.jar", "target/classes" );
+        List<String> modulePath =
+                asList( "modular.jar", "target" + separatorChar + "classes" );
         List<String> classPath = asList( "booter.jar", "non-modular.jar", patchFile.getPath() );
         Collection<String> packages = singleton( "org.apache.abc" );
         String startClassName = ForkedBooter.class.getName();
@@ -90,35 +93,52 @@ public class ModularClasspathForkConfigurationTest
         List<String> argsFileLines = readAllLines( jigsawArgsFile.toPath(), UTF_8 );
 
         assertThat( argsFileLines )
-                .hasSize( 7 );
+                .hasSize( 13 );
 
         assertThat( argsFileLines.get( 0 ) )
-                .isEqualTo( "--module-path"
-                        + " modular.jar"
-                        + pathSeparator
-                        + "target/classes" );
+                .isEqualTo( "--module-path" );
 
         assertThat( argsFileLines.get( 1 ) )
-                .isEqualTo( "--class-path"
-                        + " booter.jar"
-                        + pathSeparator
-                        + "non-modular.jar"
-                        + pathSeparator
-                        + patchFile.getPath() );
+                .isEqualTo( "\"modular.jar"
+                        + pathSeparatorChar
+                        + "target" + ( separatorChar == '\\' ? "\\\\" : "/" ) + "classes\"" );
 
         assertThat( argsFileLines.get( 2 ) )
-                .isEqualTo( "--patch-module abc=" + patchFile.getPath() );
+                .isEqualTo( "--class-path" );
 
         assertThat( argsFileLines.get( 3 ) )
-                .isEqualTo( "--add-exports abc/org.apache.abc=ALL-UNNAMED" );
+                .isEqualTo( "\"booter.jar"
+                        + pathSeparatorChar
+                        + "non-modular.jar"
+                        + pathSeparatorChar
+                        + replace( patchFile.getPath(), "\\", "\\\\" )
+                        + "\"" );
 
         assertThat( argsFileLines.get( 4 ) )
-                .isEqualTo( "--add-modules abc" );
+                .isEqualTo( "--patch-module" );
 
         assertThat( argsFileLines.get( 5 ) )
-                .isEqualTo( "--add-reads abc=ALL-UNNAMED" );
+                .isEqualTo( "abc=\"" + replace( patchFile.getPath(), "\\", "\\\\" ) + "\"" );
 
         assertThat( argsFileLines.get( 6 ) )
+                .isEqualTo( "--add-exports" );
+
+        assertThat( argsFileLines.get( 7 ) )
+                .isEqualTo( "abc/org.apache.abc=ALL-UNNAMED" );
+
+        assertThat( argsFileLines.get( 8 ) )
+                .isEqualTo( "--add-modules" );
+
+        assertThat( argsFileLines.get( 9 ) )
+                .isEqualTo( "abc" );
+
+        assertThat( argsFileLines.get( 10 ) )
+                .isEqualTo( "--add-reads" );
+
+        assertThat( argsFileLines.get( 11 ) )
+                .isEqualTo( "abc=ALL-UNNAMED" );
+
+        assertThat( argsFileLines.get( 12 ) )
                 .isEqualTo( ForkedBooter.class.getName() );
 
         ModularClasspath modularClasspath = new ModularClasspath( descriptor, modulePath, packages, patchFile );
@@ -140,7 +160,7 @@ public class ModularClasspathForkConfigurationTest
         File argFile = new File( cli.getArguments()[0].substring( 1 ) );
         assertThat( argFile ).isFile();
         List<String> argsFileLines2 = readAllLines( argFile.toPath(), UTF_8 );
-        assertThat( argsFileLines2 ).hasSize( 7 );
+        assertThat( argsFileLines2 ).hasSize( 13 );
         for ( int i = 0; i < argsFileLines2.size(); i++ )
         {
             String line = argsFileLines2.get( i );
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/AbstractJigsawIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/AbstractJigsawIT.java
index 646869a..67e835f 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/AbstractJigsawIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/AbstractJigsawIT.java
@@ -64,9 +64,14 @@ public abstract class AbstractJigsawIT
         return unpack();
     }
 
+    protected String getSuffix()
+    {
+        return null;
+    }
+
     private SurefireLauncher unpack()
     {
-        return unpack( getProjectDirectoryName() );
+        return unpack( getProjectDirectoryName(), getSuffix() );
     }
 
     private static boolean isJavaVersion9AtLeast()
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ModulePathIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ModulePathIT.java
index 3c3d2c6..dedd0db 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/ModulePathIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ModulePathIT.java
@@ -26,6 +26,8 @@ import java.io.IOException;
 public class ModulePathIT
         extends AbstractJigsawIT
 {
+    private String suffix;
+
     @Test
     public void testModulePath()
             throws IOException
@@ -37,9 +39,27 @@ public class ModulePathIT
                 .assertTestSuiteResults( 2 );
     }
 
+    @Test
+    public void testModulePathWithSpaces()
+            throws IOException
+    {
+        suffix = " with spaces";
+        assumeJigsaw()
+                .debugLogging()
+                .executeTest()
+                .verifyErrorFreeLog()
+                .assertTestSuiteResults( 2 );
+    }
+
     @Override
     protected String getProjectDirectoryName()
     {
         return "modulepath";
     }
+
+    @Override
+    protected String getSuffix()
+    {
+        return suffix;
+    }
 }