Skip to content

Commit

Permalink
[SUREFIRE-2136] Rename test dir that has colon
Browse files Browse the repository at this point in the history
In the UmlautDirIT two special directories are created that have a
colon character in the name. This causes problems with the artifact
upload of the Github actions, so we rename those directories in a
finally block at the end of the test to something without a colon
character in it.
  • Loading branch information
andpab authored and slawekjaranowski committed Dec 19, 2022
1 parent 12b9679 commit ce16679
Showing 1 changed file with 42 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,37 +94,66 @@ public void surefire1617WithColonInLocalRepo()
Path to = Paths.get( cwd, "target", "UmlautDirIT_surefire1617WithColonInLocalRepo", "target",
"test-classes", "umlautTest" );

MavenLauncher mavenLauncher = unpackWithColonInLocalRepo()
.maven();
Path localRepoDirWithColonInName =
Paths.get( System.getProperty( "user.dir" ), "target", "local repo for: SUREFIRE-1617" );

mavenLauncher.setForkJvm( true );
mavenLauncher.setAutoclean( false );

if ( !Files.exists( to ) )
try
{
Files.createDirectories( to );
}
MavenLauncher mavenLauncher = unpackWithCustomLocalRepoDirectory( localRepoDirWithColonInName ).maven();

mavenLauncher.setForkJvm( true );
mavenLauncher.setAutoclean( false );

FileUtils.copyDirectory( from.toFile(), to.toFile() );
if ( !Files.exists( to ) )
{
Files.createDirectories( to );
}

mavenLauncher.sysProp( "skipCompiler", true )
FileUtils.copyDirectory( from.toFile(), to.toFile() );

mavenLauncher.sysProp( "skipCompiler", true )
.debugLogging()
.executeTest()
.verifyErrorFreeLog()
.assertTestSuiteResults( 1, 0, 0, 0 );
}
finally
{
if ( Files.exists( localRepoDirWithColonInName ) )
{
String dirNameWithoutColon = "surefire-1617-colon-in-local-repo_renamed-after-test";
Path localRepoDirWithNoColonInName = localRepoDirWithColonInName.resolveSibling( dirNameWithoutColon );
Files.move( localRepoDirWithColonInName, localRepoDirWithNoColonInName );
}
}
}

@Test
public void surefire1617WithColonInProjectDir()
throws Exception
{
assumeTrue( IS_OS_LINUX );
unpackWithNewProjectDirectory( "this is: a test", "_surefire-1617" )
SurefireLauncher mavenLauncher = null;
try
{
mavenLauncher = unpackWithNewProjectDirectory( "this is: a test", "_surefire-1617" );
mavenLauncher
.setForkJvm()
.sysProp( "argLine", "-Dpath.separator=;" )
.executeTest()
.verifyErrorFreeLog()
.assertTestSuiteResults( 1, 0, 0, 0 );
}
finally
{
if ( mavenLauncher != null )
{
String dirNameWithoutColon = "surefire-1617-colon-in-project-dir_renamed-after-test";
Path projectDirWithColonInName = mavenLauncher.getUnpackedAt().toPath();
Path projectDirWithNoColonInName = projectDirWithColonInName.resolveSibling( dirNameWithoutColon );
Files.move( projectDirWithColonInName, projectDirWithNoColonInName );
}
}
}

@Test
Expand Down Expand Up @@ -158,11 +187,10 @@ private SurefireLauncher unpackWithNewProjectDirectory( String projectDirectory,
return unpack;
}

private SurefireLauncher unpackWithColonInLocalRepo()
private SurefireLauncher unpackWithCustomLocalRepoDirectory( Path customLocalRepoPath )
throws IOException
{
String newLocalRepo =
Paths.get( System.getProperty( "user.dir" ), "target", "local repo for: SUREFIRE-1617" ).toString();
String newLocalRepo = customLocalRepoPath.toString();
String defaultLocalRepo = new MavenLauncher( getClass(), "junit-pathWithUmlaut", null ).getLocalRepository();

copyFolder( Paths.get( defaultLocalRepo, "org", "apache", "maven", "surefire" ),
Expand Down

0 comments on commit ce16679

Please sign in to comment.