From 83a87f7987c128e8a4edfb4760a83d3953de166d Mon Sep 17 00:00:00 2001 From: Jason van Zyl Date: Thu, 12 Oct 2006 21:36:32 +0000 Subject: [PATCH] o generate individual test files, which can be aggrated but i figure we want to keep these separate and ideally we would want to keep an integration test encapsulated ... so we can make an archetype for people so that they can create ITs easily. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@463443 13f79535-47bb-0310-9956-ffa450edef68 --- mavenexecute.pl | 102 +++++++++++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 49 deletions(-) diff --git a/mavenexecute.pl b/mavenexecute.pl index 544563cf85..3256ac7953 100644 --- a/mavenexecute.pl +++ b/mavenexecute.pl @@ -9,13 +9,9 @@ $readme = ; @descriptions = $readme =~ m/(it\d+\: .*?)(?=\nit\d+\:|$)/gsx; for $desc (@descriptions) { ($name, $value) = ($desc =~ m/^(it\d+)\: (.*)$/s); - # ($value) = ($result =~ m/^it\d+\: (.*)$/s); - # $value =~ s/\s+/ /g; chomp ($value); $comment{$name} = $value; } - - $preamble = < ) chomp; if ( /^\#/ ) { - print "//"; + print T "//"; } - print "\"" . $_ . "\"," . "\n"; + print T "\"" . $_ . "\"," . "\n"; } -print "};" . "\n"; - +print T "};" . "\n"; + $TEST_SUITE = < /tmp/mits/MavenIntegrationTest_$filename" . ".java" ) or die; + print $filename . "\n"; + print T "package org.apache.maven.it;\n"; + print T "import java.io.File;\n"; + print T "public class MavenIntegrationTest${filename} /*extends AbstractMavenIntegrationTest*/ {\n"; + + 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"; if (-e "$filePrebuildHook") { open (FILE, "$filePrebuildHook"); while ($line = ) { - # print ("OLDLINE: $line"); if ($line =~ /^(rm|rmdir) (.*)/) { ($cmd, $path) = ($1, $2); if ($cmd eq "rm") { if ($path =~ m/^\$\{artifact:([^:]*?):([^:]*?):([^:]*?):([^:]*?)\}$/) { - print "verifier.deleteArtifact(\"$1\", \"$2\", \"$3\", \"$4\");\n"; + print T "verifier.deleteArtifact(\"$1\", \"$2\", \"$3\", \"$4\");\n"; } else { - print "FileUtils.deleteFile(new File(basedir, \"$path\"));\n"; + print T "FileUtils.deleteFile(new File(basedir, \"$path\"));\n"; } } elsif ($cmd eq "rmdir") { - print "FileUtils.deleteDirectory(new File(basedir, \"$path\"));\n"; + print T "FileUtils.deleteDirectory(new File(basedir, \"$path\"));\n"; } else { die ("wtf? $line\n"); } @@ -134,34 +138,34 @@ while (defined($filename = readdir(DIR))) { $cliOptions = ; chomp ($cliOptions); $cliOptions =~ s/"/\\"/g; - print "List cliOptions = new ArrayList();\n"; - print "cliOptions.add(\"$cliOptions\");\n"; - print "verifier.setCliOptions(cliOptions);\n"; + 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 "Properties systemProperties = new Properties();\n"; + print T "Properties systemProperties = new Properties();\n"; while ($line = ) { next if ($line =~ m/^\s*\#/); ($name, $value) = ($line =~ m/^([^=]*)=(.*)/); - print "systemProperties.put(\"$name\", \"$value\");\n"; + print T "systemProperties.put(\"$name\", \"$value\");\n"; } - print "verifier.setSystemProperties(systemProperties);\n"; + print T "verifier.setSystemProperties(systemProperties);\n"; close FILE; } if (-e "$fileVerifierProperties") { open(FILE, $fileVerifierProperties); - print "Properties verifierProperties = new Properties();\n"; + print T "Properties verifierProperties = new Properties();\n"; while ($line = ) { next if ($line =~ m/^\s*\#/); ($name, $value) = ($line =~ m/^([^=]*)=(.*)/); if ($name eq "failOnErrorOutput" and $value eq "false") { $failOnErrorOutput = 0; } - print "verifierProperties.put(\"$name\", \"$value\");\n"; + print T "verifierProperties.put(\"$name\", \"$value\");\n"; } - print "verifier.setVerifierProperties(verifierProperties);\n"; + print T "verifier.setVerifierProperties(verifierProperties);\n"; close FILE; } @@ -174,15 +178,15 @@ while (defined($filename = readdir(DIR))) { push (@goals, $line); } if (scalar(@goals) == 1) { - print "verifier.executeGoal(\"$goals[0]\");\n"; + print T "verifier.executeGoal(\"$goals[0]\");\n"; } else { - print "List goals = Arrays.asList(new String[] {"; + print T "List goals = Arrays.asList(new String[] {"; for ($i = 0; $i < @goals; $i++) { - print "\"$goals[$i]\""; - print ", " if ($i != scalar(@goals) -1); + print T "\"$goals[$i]\""; + print T ", " if ($i != scalar(@goals) -1); } - print "});\n"; - print "verifier.executeGoals(goals);\n"; + print T "});\n"; + print T "verifier.executeGoals(goals);\n"; } close FILE; @@ -193,33 +197,33 @@ while (defined($filename = readdir(DIR))) { while ($line = ) { chomp ($line); - #print ("OLDLINE: $line\n"); + #print T ("OLDLINE: $line\n"); if ($line =~ /^\#(.*)/) { - print "//$1\n"; + print T "//$1\n"; next; } if ($line =~ m/^\!\$\{artifact:([^:]*?):([^:]*?):([^:]*?):([^:]*?)\}$/) { - print "verifier.assertArtifactNotPresent(\"$1\", \"$2\", \"$3\", \"$4\");\n"; + print T "verifier.assertArtifactNotPresent(\"$1\", \"$2\", \"$3\", \"$4\");\n"; } elsif ($line =~ m/^\$\{artifact:([^:]*?):([^:]*?):([^:]*?):([^:]*?)\}$/) { - print "verifier.assertArtifactPresent(\"$1\", \"$2\", \"$3\", \"$4\");\n"; + print T "verifier.assertArtifactPresent(\"$1\", \"$2\", \"$3\", \"$4\");\n"; } elsif ($line =~ m/^\!(.*)/) { - print "verifier.assertFileNotPresent(\"$1\");\n"; + print T "verifier.assertFileNotPresent(\"$1\");\n"; } else { - print "verifier.assertFilePresent(\"$line\");\n"; + print T "verifier.assertFilePresent(\"$line\");\n"; } } close FILE; } if ($failOnErrorOutput) { - print "verifier.verifyErrorFreeLog();\n"; + print T "verifier.verifyErrorFreeLog();\n"; } else { - print "// don't verify error free log\n"; + print T "// don't verify error free log\n"; } - print "}\n\n"; + print T "}}\n\n"; } -print $postamble; +print T $postamble; closedir(DIR);