2006-10-12 08:06:13 -04:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
$dirname = "maven-core-it";
|
2006-10-13 12:01:44 -04:00
|
|
|
$newITs = "maven-core-it-new";
|
2006-10-12 08:03:04 -04:00
|
|
|
|
2006-10-13 12:01:44 -04:00
|
|
|
open( FILE, "$dirname/integration-tests-descriptions.txt" ) or die;
|
2006-10-12 12:28:11 -04:00
|
|
|
undef $/;
|
|
|
|
$readme = <FILE>;
|
2006-10-13 12:01:44 -04:00
|
|
|
close( FILE );
|
2006-10-12 08:03:04 -04:00
|
|
|
|
2006-10-13 16:59:29 -04:00
|
|
|
$/ = "\n";
|
|
|
|
|
2006-10-12 08:03:04 -04:00
|
|
|
@descriptions = $readme =~ m/(it\d+\: .*?)(?=\nit\d+\:|$)/gsx;
|
|
|
|
for $desc (@descriptions) {
|
|
|
|
($name, $value) = ($desc =~ m/^(it\d+)\: (.*)$/s);
|
|
|
|
chomp ($value);
|
|
|
|
$comment{$name} = $value;
|
|
|
|
}
|
2006-10-12 13:25:46 -04:00
|
|
|
|
2006-10-13 12:01:44 -04:00
|
|
|
system( "rm -rf $newITs" );
|
2006-10-13 23:26:12 -04:00
|
|
|
system( "mkdir -p $newITs" );
|
|
|
|
|
|
|
|
open( POM, "> $newITs/pom.xml" );
|
|
|
|
print POM "<project>\n";
|
|
|
|
print POM " <modelVersion>4.0.0</modelVersion>\n";
|
|
|
|
print POM " <groupId>org.apache.maven.it</groupId>\n";
|
|
|
|
print POM " <artifactId>maven-core-its</artifactId>\n";
|
|
|
|
print POM " <version>1.0-SNAPSHOT</version>\n";
|
|
|
|
print POM " <packaging>pom</packaging>\n";
|
|
|
|
print POM " <modules>\n";
|
2006-10-12 15:42:51 -04:00
|
|
|
|
2006-10-12 08:03:04 -04:00
|
|
|
opendir(DIR, $dirname) or die "can't opendir $dirname: $!";
|
|
|
|
while (defined($filename = readdir(DIR))) {
|
|
|
|
next unless (-d "$dirname/$filename");
|
|
|
|
next if ($filename eq ".svn");
|
|
|
|
next unless ($filename =~ m/^it0\d+$/);
|
|
|
|
$filePrebuildHook = "$dirname/$filename/prebuild-hook.txt";
|
|
|
|
$fileCliOptions = "$dirname/$filename/cli-options.txt";
|
|
|
|
$fileSystemProperties = "$dirname/$filename/system.properties";
|
|
|
|
$fileVerifierProperties = "$dirname/$filename/verifier.properties";
|
|
|
|
$fileGoals = "$dirname/$filename/goals.txt";
|
|
|
|
$fileExpectedResults = "$dirname/$filename/expected-results.txt";
|
|
|
|
$failOnErrorOutput = 1;
|
2006-10-13 23:26:12 -04:00
|
|
|
|
|
|
|
print POM " <module>$filename</module>\n";
|
|
|
|
|
2006-10-12 08:03:04 -04:00
|
|
|
if (!exists($comment{$filename})) {
|
|
|
|
die "no comment: $filename\n";
|
|
|
|
}
|
2006-10-12 17:36:32 -04:00
|
|
|
|
2006-10-13 12:01:44 -04:00
|
|
|
$itBaseDirectory = "$newITs/$filename";
|
2006-10-13 16:59:29 -04:00
|
|
|
$itPOM = "$itBaseDirectory/pom.xml";
|
2006-10-13 23:26:12 -04:00
|
|
|
$itTestCaseDirectory = "$itBaseDirectory/src/test/java/org/apache/maven/it";
|
|
|
|
$itTestName = "Maven" . uc($filename) . "Test";
|
|
|
|
$testFile = "$itTestCaseDirectory/$itTestName" . ".java";
|
|
|
|
$testProjectDirectory = "$itBaseDirectory/src/test-project";
|
2006-10-13 12:01:44 -04:00
|
|
|
|
|
|
|
system( "mkdir -p $itTestCaseDirectory" );
|
|
|
|
system( "cp -r $dirname/$filename $testProjectDirectory" );
|
2006-10-13 12:19:47 -04:00
|
|
|
system( "rm $testProjectDirectory/cli-options.txt > /dev/null 2>&1" );
|
|
|
|
system( "rm $testProjectDirectory/system.properties > /dev/null 2>&1" );
|
|
|
|
system( "rm $testProjectDirectory/verifier.properties > /dev/null 2>&1" );
|
|
|
|
system( "rm $testProjectDirectory/goals.txt > /dev/null 2>&1" );
|
|
|
|
system( "rm $testProjectDirectory/expected-results.txt > /dev/null 2>&1" );
|
2006-10-13 23:26:12 -04:00
|
|
|
system( "rm $testProjectDirectory/prebuild-hook.txt > /dev/null 2>&1" );
|
2006-10-13 12:19:47 -04:00
|
|
|
system( "rm $testProjectDirectory/log.txt > /dev/null 2>&1" );
|
2006-10-13 16:59:29 -04:00
|
|
|
|
2006-10-13 23:26:12 -04:00
|
|
|
open( P, "> $itPOM" ) or die;
|
2006-10-13 16:59:29 -04:00
|
|
|
print P "<project>\n";
|
|
|
|
print P " <modelVersion>4.0.0</modelVersion>\n";
|
|
|
|
print P " <groupId>org.apache.maven.it</groupId>\n";
|
|
|
|
print P " <artifactId>maven-core-it-$filename</artifactId>\n";
|
|
|
|
print P " <version>1.0-SNAPSHOT</version>\n";
|
2006-10-13 23:26:12 -04:00
|
|
|
print P " <name>Maven Integration Tests :: $filename</name>\n";
|
2006-10-13 16:59:29 -04:00
|
|
|
|
|
|
|
$build = <<EOF;
|
2006-10-13 23:26:12 -04:00
|
|
|
<dependencies>
|
|
|
|
<dependency>
|
|
|
|
<groupId>org.apache.maven</groupId>
|
|
|
|
<artifactId>maven-core-it-verifier</artifactId>
|
|
|
|
<version>2.1-SNAPSHOT</version>
|
|
|
|
</dependency>
|
|
|
|
</dependencies>
|
2006-10-13 16:59:29 -04:00
|
|
|
EOF
|
|
|
|
|
|
|
|
print P "$build";
|
|
|
|
print P "</project>\n";
|
|
|
|
close P;
|
2006-10-13 12:01:44 -04:00
|
|
|
|
|
|
|
open( T, "> $testFile") or die;
|
2006-10-12 17:36:32 -04:00
|
|
|
print $filename . "\n";
|
|
|
|
print T "package org.apache.maven.it;\n";
|
|
|
|
print T "import java.io.File;\n";
|
2006-10-13 17:31:20 -04:00
|
|
|
print T "import junit.framework.*;\n";
|
2006-10-13 23:26:12 -04:00
|
|
|
print T "public class $itTestName extends TestCase /*extends AbstractMavenIntegrationTest*/ {\n";
|
2006-10-12 17:36:32 -04:00
|
|
|
print T "/** $comment{$filename} */\n";
|
2006-10-13 23:26:12 -04:00
|
|
|
print T "public void test$filename() throws Exception {\n";
|
|
|
|
print T "String basedir = System.getProperty(\"basedir\");\n";
|
|
|
|
print T "File testDir = new File(basedir, \"src\/test-project\");\n";
|
|
|
|
print T "Verifier verifier = new Verifier(testDir.getAbsolutePath());\n";
|
2006-10-12 08:03:04 -04:00
|
|
|
|
|
|
|
if (-e "$filePrebuildHook") {
|
|
|
|
open (FILE, "$filePrebuildHook");
|
|
|
|
while ($line = <FILE>) {
|
|
|
|
if ($line =~ /^(rm|rmdir) (.*)/) {
|
|
|
|
($cmd, $path) = ($1, $2);
|
|
|
|
|
|
|
|
if ($cmd eq "rm") {
|
|
|
|
if ($path =~ m/^\$\{artifact:([^:]*?):([^:]*?):([^:]*?):([^:]*?)\}$/) {
|
2006-10-12 17:36:32 -04:00
|
|
|
print T "verifier.deleteArtifact(\"$1\", \"$2\", \"$3\", \"$4\");\n";
|
2006-10-12 08:03:04 -04:00
|
|
|
} else {
|
2006-10-12 17:36:32 -04:00
|
|
|
print T "FileUtils.deleteFile(new File(basedir, \"$path\"));\n";
|
2006-10-12 08:03:04 -04:00
|
|
|
}
|
|
|
|
} elsif ($cmd eq "rmdir") {
|
2006-10-12 17:36:32 -04:00
|
|
|
print T "FileUtils.deleteDirectory(new File(basedir, \"$path\"));\n";
|
2006-10-12 08:03:04 -04:00
|
|
|
} else {
|
|
|
|
die ("wtf? $line\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
die ("unexpected command: $line\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close FILE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (-e "$fileCliOptions") {
|
|
|
|
open(FILE, $fileCliOptions);
|
|
|
|
$cliOptions = <FILE>;
|
|
|
|
chomp ($cliOptions);
|
|
|
|
$cliOptions =~ s/"/\\"/g;
|
2006-10-12 17:36:32 -04:00
|
|
|
print T "List cliOptions = new ArrayList();\n";
|
|
|
|
print T "cliOptions.add(\"$cliOptions\");\n";
|
|
|
|
print T "verifier.setCliOptions(cliOptions);\n";
|
2006-10-12 08:03:04 -04:00
|
|
|
close FILE;
|
|
|
|
}
|
|
|
|
if (-e "$fileSystemProperties") {
|
|
|
|
open(FILE, $fileSystemProperties);
|
2006-10-12 17:36:32 -04:00
|
|
|
print T "Properties systemProperties = new Properties();\n";
|
2006-10-12 08:03:04 -04:00
|
|
|
while ($line = <FILE>) {
|
|
|
|
next if ($line =~ m/^\s*\#/);
|
|
|
|
($name, $value) = ($line =~ m/^([^=]*)=(.*)/);
|
2006-10-12 17:36:32 -04:00
|
|
|
print T "systemProperties.put(\"$name\", \"$value\");\n";
|
2006-10-12 08:03:04 -04:00
|
|
|
}
|
2006-10-12 17:36:32 -04:00
|
|
|
print T "verifier.setSystemProperties(systemProperties);\n";
|
2006-10-12 08:03:04 -04:00
|
|
|
close FILE;
|
|
|
|
}
|
|
|
|
if (-e "$fileVerifierProperties") {
|
|
|
|
open(FILE, $fileVerifierProperties);
|
2006-10-12 17:36:32 -04:00
|
|
|
print T "Properties verifierProperties = new Properties();\n";
|
2006-10-12 08:03:04 -04:00
|
|
|
while ($line = <FILE>) {
|
|
|
|
next if ($line =~ m/^\s*\#/);
|
|
|
|
($name, $value) = ($line =~ m/^([^=]*)=(.*)/);
|
|
|
|
if ($name eq "failOnErrorOutput" and $value eq "false") {
|
|
|
|
$failOnErrorOutput = 0;
|
|
|
|
}
|
2006-10-12 17:36:32 -04:00
|
|
|
print T "verifierProperties.put(\"$name\", \"$value\");\n";
|
2006-10-12 08:03:04 -04:00
|
|
|
}
|
2006-10-12 17:36:32 -04:00
|
|
|
print T "verifier.setVerifierProperties(verifierProperties);\n";
|
2006-10-12 08:03:04 -04:00
|
|
|
close FILE;
|
|
|
|
}
|
|
|
|
|
|
|
|
open (FILE, $fileGoals) or die "Couldn't open $fileGoals: $!\n";
|
|
|
|
|
|
|
|
@goals = ();
|
|
|
|
while ($line = <FILE>) {
|
|
|
|
next if ($line =~ m/^\s*$/);
|
|
|
|
chomp ($line);
|
|
|
|
push (@goals, $line);
|
|
|
|
}
|
|
|
|
if (scalar(@goals) == 1) {
|
2006-10-12 17:36:32 -04:00
|
|
|
print T "verifier.executeGoal(\"$goals[0]\");\n";
|
2006-10-12 08:03:04 -04:00
|
|
|
} else {
|
2006-10-12 17:36:32 -04:00
|
|
|
print T "List goals = Arrays.asList(new String[] {";
|
2006-10-12 08:03:04 -04:00
|
|
|
for ($i = 0; $i < @goals; $i++) {
|
2006-10-12 17:36:32 -04:00
|
|
|
print T "\"$goals[$i]\"";
|
|
|
|
print T ", " if ($i != scalar(@goals) -1);
|
2006-10-12 08:03:04 -04:00
|
|
|
}
|
2006-10-12 17:36:32 -04:00
|
|
|
print T "});\n";
|
|
|
|
print T "verifier.executeGoals(goals);\n";
|
2006-10-12 08:03:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
close FILE;
|
|
|
|
|
|
|
|
if (-e $fileExpectedResults) {
|
|
|
|
|
|
|
|
open (FILE, $fileExpectedResults) or die "Couldn't open $fileExpectedResults: $!\n";
|
|
|
|
|
|
|
|
while ($line = <FILE>) {
|
|
|
|
chomp ($line);
|
2006-10-12 17:36:32 -04:00
|
|
|
#print T ("OLDLINE: $line\n");
|
2006-10-12 08:03:04 -04:00
|
|
|
if ($line =~ /^\#(.*)/) {
|
2006-10-12 17:36:32 -04:00
|
|
|
print T "//$1\n";
|
2006-10-12 08:03:04 -04:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
if ($line =~ m/^\!\$\{artifact:([^:]*?):([^:]*?):([^:]*?):([^:]*?)\}$/) {
|
2006-10-12 17:36:32 -04:00
|
|
|
print T "verifier.assertArtifactNotPresent(\"$1\", \"$2\", \"$3\", \"$4\");\n";
|
2006-10-12 08:03:04 -04:00
|
|
|
} elsif ($line =~ m/^\$\{artifact:([^:]*?):([^:]*?):([^:]*?):([^:]*?)\}$/) {
|
2006-10-12 17:36:32 -04:00
|
|
|
print T "verifier.assertArtifactPresent(\"$1\", \"$2\", \"$3\", \"$4\");\n";
|
2006-10-12 08:03:04 -04:00
|
|
|
} elsif ($line =~ m/^\!(.*)/) {
|
2006-10-12 17:36:32 -04:00
|
|
|
print T "verifier.assertFileNotPresent(\"$1\");\n";
|
2006-10-12 08:03:04 -04:00
|
|
|
} else {
|
2006-10-12 17:36:32 -04:00
|
|
|
print T "verifier.assertFilePresent(\"$line\");\n";
|
2006-10-12 08:03:04 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
close FILE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($failOnErrorOutput) {
|
2006-10-12 17:36:32 -04:00
|
|
|
print T "verifier.verifyErrorFreeLog();\n";
|
2006-10-12 08:03:04 -04:00
|
|
|
} else {
|
2006-10-12 17:36:32 -04:00
|
|
|
print T "// don't verify error free log\n";
|
2006-10-12 08:03:04 -04:00
|
|
|
}
|
2006-10-12 17:36:32 -04:00
|
|
|
print T "}}\n\n";
|
2006-10-12 08:03:04 -04:00
|
|
|
|
|
|
|
}
|
2006-10-13 23:26:12 -04:00
|
|
|
|
|
|
|
print POM " </modules>\n";
|
|
|
|
print POM "</project>";
|
2006-10-12 13:25:46 -04:00
|
|
|
|
2006-10-12 17:36:32 -04:00
|
|
|
print T $postamble;
|
2006-10-12 13:25:46 -04:00
|
|
|
|
2006-10-12 08:06:13 -04:00
|
|
|
closedir(DIR);
|