Author: evenisse Date: Thu Jul 21 10:25:22 2005 New Revision: 220147 URL: http://svn.apache.org/viewcvs?rev=220147&view=rev Log: Fixed partially it tests for windows. MavenOneIntegrationTest and ShellIntegrationTest failed in cvs checkout command. Modified: maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/AbstractIntegrationTest.java maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/AntIntegrationTest.java maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/MavenOneIntegrationTest.java maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/MavenTwoIntegrationTest.java maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/ShellIntegrationTest.java Modified: maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/AbstractIntegrationTest.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/AbstractIntegrationTest.java?rev=220147&r1=220146&r2=220147&view=diff ============================================================================== --- maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/AbstractIntegrationTest.java (original) +++ maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/AbstractIntegrationTest.java Thu Jul 21 10:25:22 2005 @@ -47,6 +47,7 @@ import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.context.Context; +import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.InterpolationFilterReader; import org.codehaus.plexus.util.IOUtil; @@ -280,7 +281,7 @@ if ( exitCode != 0 ) { - System.err.println( "Error while executing command: " + cmd ); + System.err.println( "Error while executing command: " + commandline.toString() ); System.err.println( "Exit code: " + exitCode ); System.err.println( "Standard output:" ); @@ -688,7 +689,7 @@ protected void svnImport( File root, String artifactId, File svnRoot ) throws CommandLineException { - system( root, "svn", "import -m - . file://" + svnRoot.getAbsolutePath() + "/" + artifactId ); + system( root, "svn", "import -m - . " + getFileUrl( getSvnRoot() ) + "/" + artifactId ); } protected void cvsCheckout( File cvsRoot, String module, File coDir ) @@ -713,23 +714,66 @@ system( svnRoot, "svnadmin", "create " + svnRoot.getAbsolutePath() ); } - // ---------------------------------------------------------------------- - // Maven 1 - // ---------------------------------------------------------------------- + protected String getFileUrl( File repositoryRootFile ) + throws CommandLineException + { + String repositoryRoot = repositoryRootFile.getAbsolutePath(); + + // TODO: it'd be great to build this into CommandLineUtils somehow + // TODO: some way without a custom cygwin sys property? + if ( "true".equals( System.getProperty( "cygwin" ) ) ) + { + Commandline cl = new Commandline(); + + cl.setExecutable( "cygpath" ); + + cl.createArgument().setValue( "--unix" ); + + cl.createArgument().setValue( repositoryRoot ); + + CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); + + int exitValue = CommandLineUtils.executeCommandLine( cl, stdout, null ); + + if ( exitValue != 0 ) + { + throw new CommandLineException( "Unable to convert cygwin path, exit code = " + exitValue ); + } + + repositoryRoot = stdout.getOutput().trim(); + } + else if ( System.getProperty( "os.name" ).startsWith( "Windows" ) ) + { + repositoryRoot = "/" + StringUtils.replace( repositoryRoot, "\\", "/" ); + } + + return "file://" + repositoryRoot; + } + + private String getScmUrl( File repositoryRootFile ) + throws CommandLineException + { + return "scm:svn:" + getFileUrl( repositoryRootFile ); + } protected String makeScmUrl( String scm, File scmRoot, String artifactId ) + throws CommandLineException { if ( scm.equals( "cvs" ) ) { - return "scm:cvs:local:" + scmRoot.getAbsolutePath() + ":" + artifactId; + return "scm|cvs|local|" + scmRoot.getAbsolutePath() + "|" + artifactId; } else if ( scm.equals( "svn" ) ) { - return "scm:svn:file:" + scmRoot.getAbsolutePath() + "/" + artifactId; + return getScmUrl( scmRoot ) + "/" + artifactId; } throw new RuntimeException( "Unknown SCM type '" + scm + "'" ); } + + // ---------------------------------------------------------------------- + // Maven 1 + // ---------------------------------------------------------------------- protected void writeMavenOnePom( File file, String artifactId, Modified: maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/AntIntegrationTest.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/AntIntegrationTest.java?rev=220147&r1=220146&r2=220147&view=diff ============================================================================== --- maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/AntIntegrationTest.java (original) +++ maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/AntIntegrationTest.java Thu Jul 21 10:25:22 2005 @@ -53,7 +53,7 @@ progress( "Adding Ant SVN project" ); AntProject p = new AntProject(); - p.setScmUrl( "scm:svn:file://" + getSvnRoot() + "/ant-svn" ); + p.setScmUrl( makeScmUrl( "svn", getSvnRoot(), "ant-svn" ) ); p.setName( "Ant SVN Project" ); // p.getNotifiers().add( makeMailNotifier( email ) ); p.setVersion( "3.0" ); @@ -94,7 +94,7 @@ cvsImport( root, "ant-cvs", getCvsRoot() ); AntProject p = new AntProject(); - p.setScmUrl( "scm:cvs:local:" + getCvsRoot().getAbsolutePath() + ":ant-cvs" ); + p.setScmUrl( makeScmUrl( "cvs", getCvsRoot(), "ant-cvs" ) ); p.setName( "Ant CVS Project" ); // p.getNotifiers().add( makeMailNotifier( email ) ); p.setVersion( "3.0" ); Modified: maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/MavenOneIntegrationTest.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/MavenOneIntegrationTest.java?rev=220147&r1=220146&r2=220147&view=diff ============================================================================== --- maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/MavenOneIntegrationTest.java (original) +++ maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/MavenOneIntegrationTest.java Thu Jul 21 10:25:22 2005 @@ -50,7 +50,7 @@ progress( "Adding Maven 1 project" ); - String projectId = getProjectId( continuum.addMavenOneProject( "file:" + root + "/project.xml" ) ); + String projectId = getProjectId( continuum.addMavenOneProject( getFileUrl( root ) + "/project.xml" ) ); waitForSuccessfulCheckout( projectId ); Modified: maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/MavenTwoIntegrationTest.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/MavenTwoIntegrationTest.java?rev=220147&r1=220146&r2=220147&view=diff ============================================================================== --- maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/MavenTwoIntegrationTest.java (original) +++ maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/MavenTwoIntegrationTest.java Thu Jul 21 10:25:22 2005 @@ -126,7 +126,7 @@ " \n" + " \n" + " \n" + - " scm:cvs:local:" + cvsRoot.getAbsolutePath() + ":" + artifactId + "\n" + + " " + makeScmUrl( "cvs", cvsRoot, artifactId ) + "\n" + " \n" + "" ); Modified: maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/ShellIntegrationTest.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/ShellIntegrationTest.java?rev=220147&r1=220146&r2=220147&view=diff ============================================================================== --- maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/ShellIntegrationTest.java (original) +++ maven/continuum/trunk/continuum-core-it/src/test/java/org/apache/maven/continuum/it/ShellIntegrationTest.java Thu Jul 21 10:25:22 2005 @@ -53,12 +53,12 @@ progress( "Adding CVS Shell project" ); ShellProject p = new ShellProject(); - p.setScmUrl( "scm:cvs:local:" + getCvsRoot() + ":shell" ); + p.setScmUrl( "scm|cvs|local|" + getCvsRoot() + "|shell" ); p.setName( "Shell Project" ); // p.getNotifiers().add( makeMailNotifier( email ) ); p.setVersion( "3.0" ); p.setCommandLineArguments( "" ); - p.setExecutable( "script.sh" ); + p.setExecutable( getScriptName() ); String projectId = continuum.addShellProject( p ); waitForSuccessfulCheckout( projectId ); @@ -76,7 +76,7 @@ cvsCheckout( getCvsRoot(), "shell", coDir ); - File s = new File( coDir, "script.sh" ); + File s = new File( coDir, getScriptName() ); String script = FileUtils.fileRead( s ); FileUtils.fileWrite( s.getAbsolutePath(), script + " # Extra part" ); system( root, "chmod", "+x " + s.getAbsolutePath() ); @@ -101,14 +101,43 @@ { deleteAndCreateDirectory( root ); - File script = new File( root, "script.sh" ); + File script = new File( root, getScriptName() ); - FileUtils.fileWrite( script.getAbsolutePath(), - "#!/bin/bash" + EOL + - "for arg in \"$@\"; do" + EOL + - " echo $arg" + EOL + - "done"); + FileUtils.fileWrite( script.getAbsolutePath(), getScriptContent() ); - system( root, "chmod", "+x " + script.getAbsolutePath() ); + if ( !System.getProperty( "os.name" ).startsWith( "Windows" ) || "true".equals( System.getProperty( "cygwin" ) ) ) + { + system( root, "chmod", "+x " + script.getAbsolutePath() ); + } + } + + private String getScriptName() + { + if ( System.getProperty( "os.name" ).startsWith( "Windows" ) && !"true".equals( System.getProperty( "cygwin" ) ) ) + { + return "script.bat"; + } + else + { + return "script.sh"; + } + } + + private String getScriptContent() + { + if ( System.getProperty( "os.name" ).startsWith( "Windows" ) && !"true".equals( System.getProperty( "cygwin" ) ) ) + { + return "@ECHO OFF" + EOL + + "IF \"%*\" == \"\" GOTO end" + EOL + + "FOR %%a IN (%*) DO ECHO %%a" + EOL + + ":end" + EOL; + } + else + { + return "#!/bin/bash" + EOL + + "for arg in \"$@\"; do" + EOL + + " echo $arg" + EOL + + "done"; + } } }