Author: jvanzyl
Date: Thu Oct 12 14:36:32 2006
New Revision: 463443

URL: http://svn.apache.org/viewvc?view=rev&rev=463443
Log:
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.

Modified:
    maven/components/trunk/mavenexecute.pl

Modified: maven/components/trunk/mavenexecute.pl
URL: 
http://svn.apache.org/viewvc/maven/components/trunk/mavenexecute.pl?view=diff&rev=463443&r1=463442&r2=463443
==============================================================================
--- maven/components/trunk/mavenexecute.pl (original)
+++ maven/components/trunk/mavenexecute.pl Thu Oct 12 14:36:32 2006
@@ -9,13 +9,9 @@
 @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 = <<EOF;
 package org.apache.maven.it;                                                   
                                                                                
                                                                             
                                                                                
                                                                                
                                                                             
@@ -51,10 +47,9 @@
             
     }                                                                          
                                                                                
                                                                             
 }
-
 EOF
 
-print $preamble;        
+print T  $preamble;        
 
 $/ = "\n";
 open( TESTS, "maven-core-it/integration-tests.txt" ) or die;      
@@ -64,24 +59,25 @@
      chomp;
      if ( /^\#/ )
      {
-         print "//";
+         print T  "//";
      }
     
-       print "\"" . $_ . "\"," . "\n";
+       print T  "\"" . $_ . "\"," . "\n";
 }              
 
-print "};" . "\n";        
-
+print T  "};" . "\n";        
+ 
 $TEST_SUITE = <<EOF;
-TestSuite suite = new TestSuite(IntegrationTests.class.getName());             
                                                                                
                                                                    
-              for (int i = 0; i < tests.length; i++) {                         
                                                                                
                                                                                
  
-                        suite.addTest(new IntegrationTests(tests[i]));         
                                                                                
                                                                                
        
-                    }                                                          
                                                                                
                                                                                
        
-         return suite;
+    TestSuite suite = new TestSuite(IntegrationTests.class.getName());         
                                                                                
                                                                        
+    for (int i = 0; i < tests.length; i++) 
+    {
+        suite.addTest(new IntegrationTests(tests[i]));                         
                                                                                
                                                                         
+    }
+    return suite;
 }        
 EOF
  
-print $TEST_SUITE;    
+print T  $TEST_SUITE;    
     
 opendir(DIR, $dirname) or die "can't opendir $dirname: $!";
 while (defined($filename = readdir(DIR))) {
@@ -98,26 +94,34 @@
     if (!exists($comment{$filename})) {
        die "no comment: $filename\n";
     }
-    print "/** $comment{$filename} */\n";
-    print "public void test_$filename() throws Exception {\n";
-    print "File basedir = new File(rootdir, \"$filename\");\n";
-    print "verifier = new Verifier(basedir.getAbsolutePath());\n";
+    
+    mkdir( "/tmp/mits" );
+    open( T, "> /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 = <FILE>) {
-               # 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 @@
        $cliOptions = <FILE>;
        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 = <FILE>) {
                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 = <FILE>) {
                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 @@
        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 ($line = <FILE>) {
                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);


Reply via email to