#!/usr/bin/perl # 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. use File::Path; use strict; my $dirname = "maven-core-it"; my $newITs = "maven-core-integration-tests"; my $newITsResources = "$newITs/src/test/resources"; open( FILE, "$dirname/integration-tests-descriptions.txt" ) or die; undef $/; my $readme = ; close( FILE ); $/ = "\n"; my @descriptions = $readme =~ m/(it\d+\: .*?)(?=\nit\d+\:|$)/gsx; my %comment; for my $desc (@descriptions) { my ($name, $value) = ($desc =~ m/^(it\d+)\: (.*)$/s); chomp ($value); $comment{$name} = $value; } rmtree($newITs); mkpath($newITs); open (POM, "> $newITs/pom.xml" ); print POM < 4.0.0 org.apache.maven.integrationtests maven-core-integrationtests 1.0-SNAPSHOT Maven Integration Tests org.apache.maven.plugins maven-surefire-plugin **/IntegrationTestSuite.java never org.apache.maven.shared maven-verifier 1.0-SNAPSHOT junit junit 3.8.1 test END close POM; my $suiteRoot = "$newITs/src/test/java/org/apache/maven/integrationtests"; mkpath($suiteRoot); mkpath($newITsResources); open( SUITE, "> $suiteRoot/IntegrationTestSuite.java" ); print SUITE </\>/gs; if (-e $testPomFile) { my $testPom; { local( $/, *TESTPOM ); open (TESTPOM, "<$testPomFile"); $testPom = ; close TESTPOM; } # drop the existing description, if there is one $testPom =~ s!.*?!!s; # insert the test description into the POM $testPom =~ s^(?!.*)(\s+)<^\1$testDescriptionEscaped\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; } 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"); open( T, "> $testFile") or die; print $filename . "\n"; print T <) { if ($line =~ /^(rm|rmdir) (.*)/) { my ($cmd, $path) = ($1, $2); if ($cmd eq "rm") { if ($path =~ m/^\$\{artifact:([^:]*?):([^:]*?):([^:]*?):([^:]*?)\}$/) { print T "verifier.deleteArtifact(\"$1\", \"$2\", \"$3\", \"$4\");\n"; } else { print T "FileUtils.deleteFile(new File(basedir, \"$path\"));\n"; } } elsif ($cmd eq "rmdir") { print T "FileUtils.deleteDirectory(new File(basedir, \"$path\"));\n"; } else { die ("wtf? $line\n"); } } else { die ("unexpected command: $line\n"); } } close FILE; } if (-e "$fileCliOptions") { open(FILE, $fileCliOptions); my $cliOptions = ; chomp ($cliOptions); $cliOptions =~ s/"/\\"/g; print T "List cliOptions = new ArrayList();\n"; print T "cliOptions.add(\"$cliOptions\");\n"; print T "verifier.setCliOptions(cliOptions);\n"; close FILE; } if (-e "$fileSystemProperties") { open(FILE, $fileSystemProperties); print T "Properties systemProperties = new Properties();\n"; while (my $line = ) { next if ($line =~ m/^\s*\#/); my ($name, $value) = ($line =~ m/^([^=]*)=(.*)/); print T "systemProperties.put(\"$name\", \"$value\");\n"; } print T "verifier.setSystemProperties(systemProperties);\n"; close FILE; } if (-e "$fileVerifierProperties") { open(FILE, $fileVerifierProperties); print T "Properties verifierProperties = new Properties();\n"; while (my $line = ) { next if ($line =~ m/^\s*\#/); my ($name, $value) = ($line =~ m/^([^=]*)=(.*)/); if ($name eq "failOnErrorOutput" and $value eq "false") { $failOnErrorOutput = 0; } print T "verifierProperties.put(\"$name\", \"$value\");\n"; } print T "verifier.setVerifierProperties(verifierProperties);\n"; close FILE; } open (FILE, $fileGoals) or die "Couldn't open $fileGoals: $!\n"; my @goals = (); while (my $line = ) { next if ($line =~ m/^\s*$/); chomp ($line); push (@goals, $line); } if (scalar(@goals) == 1) { print T "verifier.executeGoal(\"$goals[0]\");\n"; } else { print T "List goals = Arrays.asList(new String[] {"; for (my $i = 0; $i < @goals; $i++) { print T "\"$goals[$i]\""; print T ", " if ($i != scalar(@goals) -1); } print T "});\n"; print T "verifier.executeGoals(goals);\n"; } close FILE; if (-e $fileExpectedResults) { open (FILE, $fileExpectedResults) or die "Couldn't open $fileExpectedResults: $!\n"; while (my $line = ) { chomp ($line); #print T ("OLDLINE: $line\n"); if ($line =~ /^\#(.*)/) { print T "//$1\n"; next; } if ($line =~ m/^\!\$\{artifact:([^:]*?):([^:]*?):([^:]*?):([^:]*?)\}$/) { print T "verifier.assertArtifactNotPresent(\"$1\", \"$2\", \"$3\", \"$4\");\n"; } elsif ($line =~ m/^\$\{artifact:([^:]*?):([^:]*?):([^:]*?):([^:]*?)\}$/) { print T "verifier.assertArtifactPresent(\"$1\", \"$2\", \"$3\", \"$4\");\n"; } elsif ($line =~ m/^\!(.*)/) { print T "verifier.assertFileNotPresent(\"$1\");\n"; } else { print T "verifier.assertFilePresent(\"$line\");\n"; } } close FILE; } if ($failOnErrorOutput) { print T "verifier.verifyErrorFreeLog();\n"; } else { print T "// don't verify error free log\n"; } print T "verifier.resetStreams();\n"; print T "System.out.println(\"PASS\");\n"; print T "}}\n\n"; } # DGF end of the suite print SUITE <