2006-10-12 08:06:13 -04:00
|
|
|
#!/usr/bin/perl
|
2006-10-19 17:22:35 -04:00
|
|
|
|
|
|
|
# DO NOT EXECUTE THIS SCRIPT!!!!!!
|
|
|
|
# This script was used to generate the new IT structure and we're leaving it around for safe keeping
|
|
|
|
# but the transfer to the new mechanism has been made.
|
|
|
|
|
2006-10-17 21:39:23 -04:00
|
|
|
use File::Path;
|
2006-10-18 17:47:40 -04:00
|
|
|
use strict;
|
|
|
|
|
|
|
|
my $dirname = "maven-core-it";
|
2006-10-19 15:48:59 -04:00
|
|
|
my $newITs = "maven-core-integration-tests";
|
2006-10-18 17:47:40 -04:00
|
|
|
my $newITsResources = "$newITs/src/test/resources";
|
2006-10-12 08:06:13 -04:00
|
|
|
|
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 $/;
|
2006-10-18 17:47:40 -04:00
|
|
|
my $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-18 17:47:40 -04:00
|
|
|
my @descriptions = $readme =~ m/(it\d+\: .*?)(?=\nit\d+\:|$)/gsx;
|
|
|
|
my %comment;
|
|
|
|
for my $desc (@descriptions) {
|
|
|
|
my ($name, $value) = ($desc =~ m/^(it\d+)\: (.*)$/s);
|
2006-10-12 08:03:04 -04:00
|
|
|
chomp ($value);
|
|
|
|
$comment{$name} = $value;
|
|
|
|
}
|
2006-10-17 21:39:23 -04:00
|
|
|
|
|
|
|
rmtree($newITs);
|
|
|
|
mkpath($newITs);
|
2006-10-13 23:26:12 -04:00
|
|
|
|
2006-10-18 17:47:40 -04:00
|
|
|
open (POM, "> $newITs/pom.xml" );
|
|
|
|
print POM <<END;
|
|
|
|
|
|
|
|
<project>
|
|
|
|
<modelVersion>4.0.0</modelVersion>
|
|
|
|
<groupId>org.apache.maven.integrationtests</groupId>
|
|
|
|
<artifactId>maven-core-integrationtests</artifactId>
|
|
|
|
<version>1.0-SNAPSHOT</version>
|
|
|
|
<name>Maven Integration Tests</name>
|
|
|
|
<build>
|
|
|
|
<plugins>
|
|
|
|
<plugin>
|
|
|
|
<groupId>org.apache.maven.plugins</groupId>
|
|
|
|
<artifactId>maven-surefire-plugin</artifactId>
|
|
|
|
<configuration>
|
|
|
|
<includes>
|
|
|
|
<include>**/IntegrationTestSuite.java</include>
|
|
|
|
</includes>
|
|
|
|
<forkMode>never</forkMode>
|
|
|
|
</configuration>
|
|
|
|
</plugin>
|
|
|
|
</plugins>
|
|
|
|
</build>
|
|
|
|
<dependencies>
|
|
|
|
<dependency>
|
2006-10-18 17:55:48 -04:00
|
|
|
<groupId>org.apache.maven.shared</groupId>
|
|
|
|
<artifactId>maven-verifier</artifactId>
|
|
|
|
<version>1.0-SNAPSHOT</version>
|
2006-10-18 17:47:40 -04:00
|
|
|
</dependency>
|
|
|
|
<dependency>
|
|
|
|
<groupId>junit</groupId>
|
|
|
|
<artifactId>junit</artifactId>
|
|
|
|
<version>3.8.1</version>
|
|
|
|
<scope>test</scope>
|
|
|
|
</dependency>
|
|
|
|
</dependencies>
|
|
|
|
</project>
|
|
|
|
END
|
|
|
|
|
|
|
|
close POM;
|
|
|
|
|
|
|
|
my $suiteRoot = "$newITs/src/test/java/org/apache/maven/integrationtests";
|
|
|
|
mkpath($suiteRoot);
|
|
|
|
mkpath($newITsResources);
|
|
|
|
|
|
|
|
open( SUITE, "> $suiteRoot/IntegrationTestSuite.java" );
|
|
|
|
print SUITE <<END;
|
|
|
|
package org.apache.maven.integrationtests;
|
|
|
|
|
|
|
|
import junit.framework.*;
|
|
|
|
|
|
|
|
public class IntegrationTestSuite extends TestCase {
|
|
|
|
|
|
|
|
public static Test suite() {
|
|
|
|
TestSuite suite = new TestSuite();
|
|
|
|
END
|
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: $!";
|
2006-10-18 17:47:40 -04:00
|
|
|
while (defined(my $filename = readdir(DIR))) {
|
2006-10-12 08:03:04 -04:00
|
|
|
next unless (-d "$dirname/$filename");
|
|
|
|
next if ($filename eq ".svn");
|
|
|
|
next unless ($filename =~ m/^it0\d+$/);
|
2006-10-18 17:47:40 -04:00
|
|
|
my $filePrebuildHook = "$dirname/$filename/prebuild-hook.txt";
|
|
|
|
my $fileCliOptions = "$dirname/$filename/cli-options.txt";
|
|
|
|
my $fileSystemProperties = "$dirname/$filename/system.properties";
|
|
|
|
my $fileVerifierProperties = "$dirname/$filename/verifier.properties";
|
|
|
|
my $fileGoals = "$dirname/$filename/goals.txt";
|
|
|
|
my $fileExpectedResults = "$dirname/$filename/expected-results.txt";
|
|
|
|
my $failOnErrorOutput = 1;
|
2006-10-13 23:26:12 -04:00
|
|
|
|
2006-10-18 17:47:40 -04:00
|
|
|
my $itTestCaseDirectory = $suiteRoot;
|
|
|
|
my $itTestName = "Maven" . uc($filename) . "Test";
|
|
|
|
my $testFile = "$itTestCaseDirectory/$itTestName" . ".java";
|
|
|
|
my $testProjectDirectory = "$newITsResources/$filename";
|
|
|
|
|
|
|
|
# 96, 97 will not due to bugs in maven, they work when other ITs are run but it's due to ordering and fluke
|
2006-10-14 08:23:48 -04:00
|
|
|
# 43 will not run because it can't find the maven-help-plugin
|
|
|
|
# 90 will not run because it relies of an environment variable which I think is wrong
|
2006-10-14 09:54:58 -04:00
|
|
|
# 91 POM interpolation test failure
|
|
|
|
# 98 fails because it needs a quoted CLI property, this isn't really a core problem and certainly won't be valid in an embedded env
|
|
|
|
# 104 test failure in interpolation
|
2006-10-14 10:27:52 -04:00
|
|
|
# 106 failure in artifact resolution
|
2006-10-14 10:53:38 -04:00
|
|
|
# 107 failure in artifact resolution
|
2006-10-14 09:54:58 -04:00
|
|
|
if ( $filename eq "it0096" ||
|
2006-10-14 08:23:48 -04:00
|
|
|
$filename eq "it0097" ||
|
|
|
|
$filename eq "it0043" ||
|
2006-10-14 09:54:58 -04:00
|
|
|
$filename eq "it0090" ||
|
|
|
|
$filename eq "it0091" ||
|
|
|
|
$filename eq "it0098" ||
|
2006-10-14 10:27:52 -04:00
|
|
|
$filename eq "it0104" ||
|
2006-10-14 10:53:38 -04:00
|
|
|
$filename eq "it0106" ||
|
|
|
|
$filename eq "it0107" )
|
2006-10-14 08:23:48 -04:00
|
|
|
{
|
2006-10-18 17:47:40 -04:00
|
|
|
print SUITE " // suite.addTestSuite($itTestName.class);\n";
|
2006-10-14 08:23:48 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-10-18 17:47:40 -04:00
|
|
|
print SUITE " suite.addTestSuite($itTestName.class);\n";
|
2006-10-14 08:23:48 -04:00
|
|
|
}
|
2006-10-13 23:26:12 -04:00
|
|
|
|
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-18 17:47:40 -04:00
|
|
|
|
2006-10-13 12:01:44 -04:00
|
|
|
|
2006-10-17 21:39:23 -04:00
|
|
|
mkpath($itTestCaseDirectory);
|
|
|
|
# DGF can't believe perl doesn't have a baked in recursive copy!
|
|
|
|
if ("MSWin32" eq $^O) {
|
2006-10-18 17:47:40 -04:00
|
|
|
my $winSrc = "$dirname/$filename";
|
2006-10-17 21:39:23 -04:00
|
|
|
$winSrc =~ s!/!\\!g;
|
2006-10-18 17:47:40 -04:00
|
|
|
my $winDest = $testProjectDirectory;
|
2006-10-17 21:39:23 -04:00
|
|
|
$winDest =~ s!/!\\!g;
|
|
|
|
mkpath($testProjectDirectory);
|
|
|
|
system( "xcopy /e $winSrc $winDest" );
|
|
|
|
} else {
|
|
|
|
system( "cp -r $dirname/$filename $testProjectDirectory" );
|
2006-10-19 15:41:23 -04:00
|
|
|
}
|
|
|
|
my $testPomFile = "$testProjectDirectory/pom.xml";
|
|
|
|
my $testDescription = $comment{$filename} or die "wtf? no test description for $filename\n";
|
|
|
|
(my $testDescriptionEscaped = $testDescription) =~ s/</\</gs;
|
|
|
|
$testDescriptionEscaped =~ s/>/\>/gs;
|
|
|
|
if (-e $testPomFile) {
|
|
|
|
my $testPom;
|
|
|
|
{
|
|
|
|
local( $/, *TESTPOM );
|
|
|
|
open (TESTPOM, "<$testPomFile");
|
|
|
|
$testPom = <TESTPOM>;
|
|
|
|
close TESTPOM;
|
|
|
|
}
|
|
|
|
# drop the existing description, if there is one
|
|
|
|
$testPom =~ s!<description>.*?</description>!!s;
|
|
|
|
# insert the test description into the POM
|
|
|
|
$testPom =~ s^</artifactId>(?!.*</parent>)(\s+)<^</artifactId>\1<description>$testDescriptionEscaped</description>\1<^sx;
|
|
|
|
my $testDescriptionMatcher = quotemeta($testDescriptionEscaped);
|
|
|
|
die "failed to insert description in $testProjectDirectory/pom.xml " unless ($testPom =~ m/$testDescriptionMatcher/s);
|
|
|
|
open (TESTPOM, ">$testPomFile");
|
|
|
|
print TESTPOM $testPom;
|
|
|
|
close TESTPOM;
|
2006-10-17 21:39:23 -04:00
|
|
|
}
|
|
|
|
unlink("$testProjectDirectory/cli-options.txt");
|
|
|
|
unlink("$testProjectDirectory/system.properties");
|
|
|
|
unlink("$testProjectDirectory/verifier.properties");
|
|
|
|
unlink("$testProjectDirectory/goals.txt");
|
|
|
|
unlink("$testProjectDirectory/expected-results.txt");
|
|
|
|
unlink("$testProjectDirectory/prebuild-hook.txt");
|
|
|
|
unlink("$testProjectDirectory/log.txt");
|
2006-10-13 16:59:29 -04:00
|
|
|
|
2006-10-18 17:47:40 -04:00
|
|
|
open( T, "> $testFile") or die;
|
|
|
|
print $filename . "\n";
|
|
|
|
print T <<END;
|
|
|
|
package org.apache.maven.integrationtests;
|
|
|
|
import java.io.*;
|
|
|
|
import java.util.*;
|
2006-10-13 16:59:29 -04:00
|
|
|
|
2006-10-18 17:47:40 -04:00
|
|
|
import junit.framework.*;
|
|
|
|
|
|
|
|
import org.apache.maven.it.*;
|
|
|
|
import org.apache.maven.it.util.*;
|
|
|
|
|
|
|
|
public class $itTestName extends TestCase /*extends AbstractMavenIntegrationTest*/ {
|
|
|
|
|
2006-10-19 15:41:23 -04:00
|
|
|
/** $testDescriptionEscaped */
|
2006-10-18 17:47:40 -04:00
|
|
|
public void test$filename() throws Exception {
|
|
|
|
String basedir = System.getProperty("maven.test.tmpdir", System.getProperty("java.io.tmpdir"));
|
|
|
|
File testDir = new File(basedir, getName());
|
|
|
|
FileUtils.deleteDirectory(testDir);
|
|
|
|
System.out.println("Extracting $filename to " + testDir.getAbsolutePath());
|
|
|
|
ResourceExtractor.extractResourcePath(getClass(), "/$filename", testDir);
|
|
|
|
Verifier verifier = new Verifier(testDir.getAbsolutePath());
|
|
|
|
END
|
2006-10-13 16:59:29 -04:00
|
|
|
|
2006-10-12 08:03:04 -04:00
|
|
|
if (-e "$filePrebuildHook") {
|
|
|
|
open (FILE, "$filePrebuildHook");
|
2006-10-18 17:47:40 -04:00
|
|
|
while (my $line = <FILE>) {
|
2006-10-12 08:03:04 -04:00
|
|
|
if ($line =~ /^(rm|rmdir) (.*)/) {
|
2006-10-18 17:47:40 -04:00
|
|
|
my ($cmd, $path) = ($1, $2);
|
2006-10-12 08:03:04 -04:00
|
|
|
|
|
|
|
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);
|
2006-10-18 17:47:40 -04:00
|
|
|
my $cliOptions = <FILE>;
|
2006-10-12 08:03:04 -04:00
|
|
|
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-18 17:47:40 -04:00
|
|
|
while (my $line = <FILE>) {
|
2006-10-12 08:03:04 -04:00
|
|
|
next if ($line =~ m/^\s*\#/);
|
2006-10-18 17:47:40 -04:00
|
|
|
my ($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-18 17:47:40 -04:00
|
|
|
while (my $line = <FILE>) {
|
2006-10-12 08:03:04 -04:00
|
|
|
next if ($line =~ m/^\s*\#/);
|
2006-10-18 17:47:40 -04:00
|
|
|
my ($name, $value) = ($line =~ m/^([^=]*)=(.*)/);
|
2006-10-12 08:03:04 -04:00
|
|
|
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";
|
|
|
|
|
2006-10-18 17:47:40 -04:00
|
|
|
my @goals = ();
|
|
|
|
while (my $line = <FILE>) {
|
2006-10-12 08:03:04 -04:00
|
|
|
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-18 17:47:40 -04:00
|
|
|
for (my $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";
|
|
|
|
|
2006-10-18 17:47:40 -04:00
|
|
|
while (my $line = <FILE>) {
|
2006-10-12 08:03:04 -04:00
|
|
|
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-18 17:47:40 -04:00
|
|
|
print T "verifier.resetStreams();\n";
|
|
|
|
print T "System.out.println(\"PASS\");\n";
|
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
|
|
|
|
2006-10-18 17:47:40 -04:00
|
|
|
# DGF end of the suite
|
|
|
|
print SUITE <<END;
|
|
|
|
return suite;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
END
|
|
|
|
|
2006-10-12 13:25:46 -04:00
|
|
|
|
2006-10-12 08:06:13 -04:00
|
|
|
closedir(DIR);
|