Skip to content

Commit

Permalink
[SUREFIRE-2063] Remove tabs in forked JVM arguments
Browse files Browse the repository at this point in the history
Closes #523
  • Loading branch information
mthmulders committed Apr 21, 2022
1 parent 959c1e9 commit 0e08169
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ private String interpolateArgLineWithPropertyExpressions()
}

@Nonnull
private static String stripNewLines( @Nonnull String argLine )
private static String stripWhitespace( @Nonnull String argLine )
{
return argLine.replace( "\n", " " ).replace( "\r", " " );
return argLine.replaceAll( "\\s+", " " );
}

/**
Expand Down Expand Up @@ -361,7 +361,7 @@ protected Classpath getBooterClasspath()
@Nonnull
private String newJvmArgLine( int forks )
{
String interpolatedArgs = stripNewLines( interpolateArgLineWithPropertyExpressions() );
String interpolatedArgs = stripWhitespace( interpolateArgLineWithPropertyExpressions() );
String argsWithReplacedForkNumbers = replaceThreadNumberPlaceholders( interpolatedArgs, forks );
return extendJvmArgLine( argsWithReplacedForkNumbers );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ protected void resolveClasspath( @Nonnull Commandline cli,
DefaultForkConfiguration mockedConfig = spy( config );
String newArgLine = invokeMethod( mockedConfig, "newJvmArgLine", new Class[] { int.class }, 2 );
verifyPrivate( mockedConfig, times( 1 ) ).invoke( "interpolateArgLineWithPropertyExpressions" );
verifyPrivate( mockedConfig, times( 1 ) ).invoke( "extendJvmArgLine", eq( "a b" ) );
assertThat( newArgLine ).isEqualTo( "a b" );
verifyPrivate( mockedConfig, times( 1 ) ).invoke( "extendJvmArgLine", eq( "a b" ) );
assertThat( newArgLine ).isEqualTo( "a b" );
}

@Test
Expand Down
9 changes: 8 additions & 1 deletion surefire-its/src/test/resources/argLine-parameter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>once</forkMode>
<argLine>-Dfoo.property="foo foo/foo/bar/1.0" -Dbar.property="bar bar/foo/bar/2.0"</argLine>
<argLine>
<!--
These lines must be tab-indented, see SUREFIRE-2063;
regular tab characters could easily be reformatted by an IDE,
so we're using XML entities here.
-->
-Dfoo.property="foo foo/foo/bar/1.0"&#09;-Dbar.property="bar bar/foo/bar/2.0"
</argLine>
</configuration>
</plugin>
</plugins>
Expand Down

0 comments on commit 0e08169

Please sign in to comment.