maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r599989 - in /maven/plugins/trunk/maven-invoker-plugin/src: main/java/org/apache/maven/plugin/invoker/ site/apt/ test/java/org/apache/maven/plugin/invoker/ test/resources/unit/dummy/
Date Fri, 30 Nov 2007 22:31:37 GMT
Author: olamy
Date: Fri Nov 30 14:31:36 2007
New Revision: 599989

URL: http://svn.apache.org/viewvc?rev=599989&view=rev
Log:
[MINVOKER-13] support a parameter "a la" -Dtest like in surefire

Added:
    maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/dummy/
    maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/dummy/pom.xml   (with
props)
Modified:
    maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
    maven/plugins/trunk/maven-invoker-plugin/src/site/apt/advance-usage.apt
    maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/InvokerMojoTest.java

Modified: maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java?rev=599989&r1=599988&r2=599989&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
(original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
Fri Nov 30 14:31:36 2007
@@ -50,6 +50,7 @@
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.InterpolationFilterReader;
+import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.cli.CommandLineException;
 import org.codehaus.plexus.util.xml.XmlStreamReader;
 
@@ -229,7 +230,17 @@
      * @readonly
      * @since 1.1
      */
-    private MavenProject project;    
+    private MavenProject project;  
+    
+    /**
+     * Specify this parameter to run individual tests by file name, overriding the <code>pomIncludes</code>
+     * and <code>pomExcludes</code> parameters.  Each pattern you specify here
will be used to create an 
+     * include pattern formatted like <code>${projectsDirectory}/${invoker.test}</code>,

+     * so you can just type "-Dinvoker.test=MyTest" to run a single it in ${projectsDirectory}/${invoker.test}".
 
+     * @parameter expression="${invoker.test}"
+     * @since 1.1
+     */    
+    private String invokerTest;
     
     // list to store interpolated pom for delete at the end
     private List/*File*/ interpolatedPomFiles = new ArrayList();
@@ -775,7 +786,7 @@
         return invocationGoals;
     }
 
-    private String[] getPoms()
+    protected String[] getPoms()
         throws IOException
     {
         String[] poms;
@@ -784,6 +795,30 @@
         {
             poms = new String[]{ pom.getAbsolutePath() };
         }
+        else if ( invokerTest != null )
+        {
+            String[] testRegexes = StringUtils.split( invokerTest, "," );
+            List /* String */includes = new ArrayList( testRegexes.length );
+            
+            for ( int i = 0, size = testRegexes.length; i < size; i++ )
+            {
+                // user just use -Dinvoker.test=MWAR191,MNG111 to use a directory thats the
end is not pom.xml
+                includes.add( testRegexes[i].endsWith( "pom.xml" ) ? testRegexes[i] : testRegexes[i]
+                    + File.separatorChar + "pom.xml" );
+            }
+            
+            final FileSet fs = new FileSet();
+
+            fs.setIncludes( includes );
+            //fs.setExcludes( pomExcludes );
+            fs.setDirectory( projectsDirectory.getCanonicalPath() );
+            fs.setFollowSymlinks( false );
+            fs.setUseDefaultExcludes( false );
+
+            final FileSetManager fsm = new FileSetManager( getLog() );
+
+            poms = fsm.getIncludedFiles( fs );
+        }  
         else
         {
             final FileSet fs = new FileSet();
@@ -803,7 +838,7 @@
 
         return poms;
     }
-
+    
     private String[] normalizePomPaths( String[] poms )
         throws IOException
     {

Modified: maven/plugins/trunk/maven-invoker-plugin/src/site/apt/advance-usage.apt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/site/apt/advance-usage.apt?rev=599989&r1=599988&r2=599989&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/site/apt/advance-usage.apt (original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/site/apt/advance-usage.apt Fri Nov 30 14:31:36
2007
@@ -23,6 +23,12 @@
   * values from the project pom (you must use @pom.groupId@ notation in your pom file)
   
   * In the plugin configuration you can add some properties in a interpolationsProperties
element    
+
+* Running only some tests
+
+  The plugin support a parameter -Dinvoker.test to run only its in the directory match by
the expressions 
+  used in the parameter 
+  command line is : mvn -Dinvoker.test=*MWAR*,simple*
     
   
    

Modified: maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/InvokerMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/InvokerMojoTest.java?rev=599989&r1=599988&r2=599989&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/InvokerMojoTest.java
(original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/InvokerMojoTest.java
Fri Nov 30 14:31:36 2007
@@ -21,6 +21,7 @@
 
 import java.io.File;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
@@ -74,5 +75,50 @@
         setVariableValueToObject( invokerMojo, "postBuildHookScript", "verify.bsh" );
         invokerMojo.execute();
     }
+    
+    public void testSingleInvokerTest()
+        throws Exception
+    {
+        InvokerMojo invokerMojo = new InvokerMojo();
+        setVariableValueToObject( invokerMojo, "goalsFile", "validate-goal.txt" );
+        String dirPath = getBasedir() + "/src/test/resources/unit";
+        List goals = invokerMojo.getGoals( new File( dirPath ) );
+        assertEquals( 1, goals.size() );
+        setVariableValueToObject( invokerMojo, "projectsDirectory", new File( dirPath ) );
+        setVariableValueToObject( invokerMojo, "invokerTest", "*dummy*" );
+        String[] poms = invokerMojo.getPoms();
+        System.out.println( Arrays.asList( poms ) );
+        assertEquals( 1, poms.length );
+    }
+
+    public void testMultiInvokerTest()
+        throws Exception
+    {
+        InvokerMojo invokerMojo = new InvokerMojo();
+        setVariableValueToObject( invokerMojo, "goalsFile", "validate-goal.txt" );
+        String dirPath = getBasedir() + "/src/test/resources/unit";
+        List goals = invokerMojo.getGoals( new File( dirPath ) );
+        assertEquals( 1, goals.size() );
+        setVariableValueToObject( invokerMojo, "projectsDirectory", new File( dirPath ) );
+        setVariableValueToObject( invokerMojo, "invokerTest", "*dummy*,*terpolatio*" );
+        String[] poms = invokerMojo.getPoms();
+        System.out.println( Arrays.asList( poms ) );
+        assertEquals( 2, poms.length );
+    }   
+    
+    public void testFullPatternInvokerTest()
+        throws Exception
+    {
+        InvokerMojo invokerMojo = new InvokerMojo();
+        setVariableValueToObject( invokerMojo, "goalsFile", "validate-goal.txt" );
+        String dirPath = getBasedir() + "/src/test/resources/unit";
+        List goals = invokerMojo.getGoals( new File( dirPath ) );
+        assertEquals( 1, goals.size() );
+        setVariableValueToObject( invokerMojo, "projectsDirectory", new File( dirPath ) );
+        setVariableValueToObject( invokerMojo, "invokerTest", "*" );
+        String[] poms = invokerMojo.getPoms();
+        System.out.println( Arrays.asList( poms ) );
+        assertEquals( 3, poms.length );
+    }    
     
 }

Added: maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/dummy/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/dummy/pom.xml?rev=599989&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/dummy/pom.xml (added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/dummy/pom.xml Fri Nov
30 14:31:36 2007
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.test</groupId>
+  <artifactId>unit</artifactId>
+  <packaging>pom</packaging>
+  <version>0.1-SNAPSHOT</version>
+  <properties>
+    <interpolateValue>@foo@</interpolateValue>
+  </properties>
+</project>
\ No newline at end of file

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/dummy/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = LF

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/dummy/pom.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/test/resources/unit/dummy/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message