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
|
|
|
|
|
|
|
@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-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;
|
|
|
|
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";
|
|
|
|
$itTestCaseDirectory = "$itBaseDirectory/src/test/java/org/apache/maven/it";
|
|
|
|
$testFile = "$itTestCaseDirectory/MavenIntegrationTest_$filename" . ".java";
|
|
|
|
$testProjectDirectory = "$itBaseDirectory/src/test-project";
|
|
|
|
|
|
|
|
system( "mkdir -p $itTestCaseDirectory" );
|
|
|
|
system( "cp -r $dirname/$filename $testProjectDirectory" );
|
|
|
|
#system( "mkdir -p $testProjectDirectory" );
|
|
|
|
|
|
|
|
print $testFile . "\n";
|
|
|
|
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 12:01:44 -04:00
|
|
|
print T "public class MavenIntegrationTest${filename} /*extends AbstractMavenIntegrationTest*/ {\n";
|
2006-10-12 17:36:32 -04:00
|
|
|
print T "/** $comment{$filename} */\n";
|
|
|
|
print T "public void test_$filename() throws Exception {\n";
|
|
|
|
print T "String rootdir = System.getProperty(\"rootdir\");\n";
|
|
|
|
print T "File basedir = new File(rootdir, \"$filename\");\n";
|
|
|
|
print T "Verifier verifier = new Verifier(basedir.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-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);
|