You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2012/01/24 20:03:21 UTC

svn commit: r1235412 - in /maven/surefire/trunk: maven-surefire-common/ maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ maven-surefire-common/src/main/java/org/apache/maven/surefire/group/ maven-surefire-common/src/main/java/org/a...

Author: jdcasey
Date: Tue Jan 24 19:03:20 2012
New Revision: 1235412

URL: http://svn.apache.org/viewvc?rev=1235412&view=rev
Log:
[SUREFIRE-809] implemented grammar for parsing boolean expressions in group parameters, along with group matchers to render the parsed expression into matches against @Category annotations and the like. Started trying to integrate with the JUnit 47 provider, but the tests are still failing. Started implementing unit tests for the expression-based filter, but haven't completed this yet.

Added:
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/AndGroupMatcher.java   (with props)
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/GroupMatcher.java   (with props)
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/InverseGroupMatcher.java   (with props)
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/JoinGroupMatcher.java   (with props)
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/OrGroupMatcher.java   (with props)
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/SingleGroupMatcher.java   (with props)
    maven/surefire/trunk/maven-surefire-common/src/main/javacc/
    maven/surefire/trunk/maven-surefire-common/src/main/javacc/category-expression.jj
    maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/
    maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/cat/
    maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/cat/First.java   (with props)
    maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/cat/Second.java   (with props)
    maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/cat/Third.java   (with props)
    maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/test/
    maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/test/FirstTest.java   (with props)
    maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/test/SecondTest.java   (with props)
    maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/test/ThirdTest.java   (with props)
Modified:
    maven/surefire/trunk/maven-surefire-common/pom.xml
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/SpecificTestClassFilter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java
    maven/surefire/trunk/surefire-providers/common-junit48/pom.xml
    maven/surefire/trunk/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/FilterFactory.java

Modified: maven/surefire/trunk/maven-surefire-common/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/pom.xml?rev=1235412&r1=1235411&r2=1235412&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/pom.xml (original)
+++ maven/surefire/trunk/maven-surefire-common/pom.xml Tue Jan 24 19:03:20 2012
@@ -85,6 +85,19 @@
   <build>
     <plugins>
       <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>javacc-maven-plugin</artifactId>
+        <version>2.6</version>
+        <executions>
+          <execution>
+            <id>javacc</id>
+            <goals>
+              <goal>javacc</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
         <artifactId>maven-surefire-plugin</artifactId>
         <dependencies>
           <dependency>
@@ -94,6 +107,16 @@
           </dependency>
         </dependencies>
       </plugin>
+      <plugin>
+        <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <archive>
+            <manifest>
+              <mainClass>org.apache.maven.surefire.group.parse.GroupMatcherParser</mainClass>
+            </manifest>
+          </archive>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
 </project>

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java?rev=1235412&r1=1235411&r2=1235412&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java Tue Jan 24 19:03:20 2012
@@ -565,8 +565,6 @@ public abstract class AbstractSurefireMo
             includes = new ArrayList<String>( Arrays.asList( getDefaultIncludes() ) );
         }
 
-        System.out.println( "Test includes:\n\n" + includes + "\n\n" );
-
         return includes;
     }
 

Added: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/AndGroupMatcher.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/AndGroupMatcher.java?rev=1235412&view=auto
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/AndGroupMatcher.java (added)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/AndGroupMatcher.java Tue Jan 24 19:03:20 2012
@@ -0,0 +1,97 @@
+package org.apache.maven.surefire.group.match;
+
+import java.util.Collection;
+
+public class AndGroupMatcher
+    extends JoinGroupMatcher
+{
+
+    public AndGroupMatcher( GroupMatcher... matchers )
+    {
+        for ( GroupMatcher matcher : matchers )
+        {
+            addMatcher( matcher );
+        }
+    }
+
+    public AndGroupMatcher( Collection<GroupMatcher> matchers )
+    {
+        for ( GroupMatcher matcher : matchers )
+        {
+            addMatcher( matcher );
+        }
+    }
+
+    public boolean enabled( Class<?>... cats )
+    {
+        for ( GroupMatcher matcher : getMatchers() )
+        {
+            boolean result = matcher.enabled( cats );
+            if ( !result )
+            {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    public boolean enabled( String... cats )
+    {
+        for ( GroupMatcher matcher : getMatchers() )
+        {
+            boolean result = matcher.enabled( cats );
+            if ( !result )
+            {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    @Override
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder();
+        for ( GroupMatcher matcher : getMatchers() )
+        {
+            if ( sb.length() > 0 )
+            {
+                sb.append( " AND " );
+            }
+            sb.append( matcher );
+        }
+
+        return sb.toString();
+    }
+
+    @Override
+    public int hashCode()
+    {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result;
+        for ( GroupMatcher matcher : getMatchers() )
+        {
+            result += matcher.hashCode();
+        }
+        return result;
+    }
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+            return true;
+        if ( obj == null )
+            return false;
+        if ( getClass() != obj.getClass() )
+            return false;
+        AndGroupMatcher other = (AndGroupMatcher) obj;
+        if ( !getMatchers().equals( other.getMatchers() ) )
+            return false;
+        return true;
+    }
+
+}

Propchange: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/AndGroupMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/GroupMatcher.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/GroupMatcher.java?rev=1235412&view=auto
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/GroupMatcher.java (added)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/GroupMatcher.java Tue Jan 24 19:03:20 2012
@@ -0,0 +1,11 @@
+package org.apache.maven.surefire.group.match;
+
+
+public interface GroupMatcher
+{
+
+    boolean enabled( Class<?>... cats );
+
+    boolean enabled( String... cats );
+
+}

Propchange: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/GroupMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/InverseGroupMatcher.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/InverseGroupMatcher.java?rev=1235412&view=auto
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/InverseGroupMatcher.java (added)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/InverseGroupMatcher.java Tue Jan 24 19:03:20 2012
@@ -0,0 +1,60 @@
+package org.apache.maven.surefire.group.match;
+
+
+public class InverseGroupMatcher
+    implements GroupMatcher
+{
+
+    private final GroupMatcher matcher;
+
+    public InverseGroupMatcher( GroupMatcher matcher )
+    {
+        this.matcher = matcher;
+    }
+
+    public boolean enabled( Class<?>... cats )
+    {
+        return cats == null ? true : !matcher.enabled( cats );
+    }
+
+    public boolean enabled( String... cats )
+    {
+        return cats == null ? true : !matcher.enabled( cats );
+    }
+
+    @Override
+    public String toString()
+    {
+        return "NOT " + matcher;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ( ( matcher == null ) ? 0 : matcher.hashCode() );
+        return result;
+    }
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+            return true;
+        if ( obj == null )
+            return false;
+        if ( getClass() != obj.getClass() )
+            return false;
+        InverseGroupMatcher other = (InverseGroupMatcher) obj;
+        if ( matcher == null )
+        {
+            if ( other.matcher != null )
+                return false;
+        }
+        else if ( !matcher.equals( other.matcher ) )
+            return false;
+        return true;
+    }
+
+}

Propchange: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/InverseGroupMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/JoinGroupMatcher.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/JoinGroupMatcher.java?rev=1235412&view=auto
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/JoinGroupMatcher.java (added)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/JoinGroupMatcher.java Tue Jan 24 19:03:20 2012
@@ -0,0 +1,22 @@
+package org.apache.maven.surefire.group.match;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public abstract class JoinGroupMatcher
+    implements GroupMatcher
+{
+
+    Set<GroupMatcher> matchers = new HashSet<GroupMatcher>();
+
+    public final boolean addMatcher( GroupMatcher matcher )
+    {
+        return matchers.add( matcher );
+    }
+
+    protected final Set<GroupMatcher> getMatchers()
+    {
+        return matchers;
+    }
+
+}

Propchange: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/JoinGroupMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/OrGroupMatcher.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/OrGroupMatcher.java?rev=1235412&view=auto
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/OrGroupMatcher.java (added)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/OrGroupMatcher.java Tue Jan 24 19:03:20 2012
@@ -0,0 +1,96 @@
+package org.apache.maven.surefire.group.match;
+
+import java.util.Collection;
+
+public class OrGroupMatcher
+    extends JoinGroupMatcher
+{
+
+    public OrGroupMatcher( GroupMatcher... matchers )
+    {
+        for ( GroupMatcher matcher : matchers )
+        {
+            addMatcher( matcher );
+        }
+    }
+
+    public OrGroupMatcher( Collection<GroupMatcher> matchers )
+    {
+        for ( GroupMatcher matcher : matchers )
+        {
+            addMatcher( matcher );
+        }
+    }
+
+    public boolean enabled( Class<?>... cats )
+    {
+        for ( GroupMatcher matcher : getMatchers() )
+        {
+            boolean result = matcher.enabled( cats );
+            if ( result )
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    public boolean enabled( String... cats )
+    {
+        for ( GroupMatcher matcher : getMatchers() )
+        {
+            boolean result = matcher.enabled( cats );
+            if ( result )
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    @Override
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder();
+        for ( GroupMatcher matcher : getMatchers() )
+        {
+            if ( sb.length() > 0 )
+            {
+                sb.append( " OR " );
+            }
+            sb.append( matcher );
+        }
+
+        return sb.toString();
+    }
+
+    @Override
+    public int hashCode()
+    {
+        final int prime = 37;
+        int result = 1;
+        result = prime * result;
+        for ( GroupMatcher matcher : getMatchers() )
+        {
+            result += matcher.hashCode();
+        }
+        return result;
+    }
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+            return true;
+        if ( obj == null )
+            return false;
+        if ( getClass() != obj.getClass() )
+            return false;
+        AndGroupMatcher other = (AndGroupMatcher) obj;
+        if ( !getMatchers().equals( other.getMatchers() ) )
+            return false;
+        return true;
+    }
+}

Propchange: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/OrGroupMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/SingleGroupMatcher.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/SingleGroupMatcher.java?rev=1235412&view=auto
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/SingleGroupMatcher.java (added)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/SingleGroupMatcher.java Tue Jan 24 19:03:20 2012
@@ -0,0 +1,91 @@
+package org.apache.maven.surefire.group.match;
+
+
+public class SingleGroupMatcher
+    implements GroupMatcher
+{
+
+    private String enabled;
+
+    @Override
+    public int hashCode()
+    {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ( ( enabled == null ) ? 0 : enabled.hashCode() );
+        return result;
+    }
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+            return true;
+        if ( obj == null )
+            return false;
+        if ( getClass() != obj.getClass() )
+            return false;
+        SingleGroupMatcher other = (SingleGroupMatcher) obj;
+        if ( enabled == null )
+        {
+            if ( other.enabled != null )
+                return false;
+        }
+        else if ( !enabled.equals( other.enabled ) )
+            return false;
+        return true;
+    }
+
+    @Override
+    public String toString()
+    {
+        return "*" + enabled;
+    }
+
+    public SingleGroupMatcher( String disabled )
+    {
+        this.enabled = disabled;
+    }
+
+    public boolean enabled( Class<?>... cats )
+    {
+        if ( cats != null )
+        {
+            for ( Class<?> cls : cats )
+            {
+                String name = cls.getName();
+                if ( name.endsWith( enabled ) )
+                {
+                    return true;
+                }
+            }
+        }
+
+        return false;
+    }
+
+    public boolean enabled( String... cats )
+    {
+        if ( enabled == null )
+        {
+            return true;
+        }
+
+        for ( String cat : cats )
+        {
+            if ( cat == null || cat.trim().length() < 1 )
+            {
+                continue;
+            }
+
+            System.out.println( cat + ".endsWith(" + enabled + ")? " + ( cat.endsWith( enabled ) ) );
+            if ( cat.endsWith( enabled ) )
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+}

Propchange: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/surefire/group/match/SingleGroupMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/maven-surefire-common/src/main/javacc/category-expression.jj
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/javacc/category-expression.jj?rev=1235412&view=auto
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/javacc/category-expression.jj (added)
+++ maven/surefire/trunk/maven-surefire-common/src/main/javacc/category-expression.jj Tue Jan 24 19:03:20 2012
@@ -0,0 +1,196 @@
+options {
+  DEBUG_PARSER = false;
+  DEBUG_LOOKAHEAD = false;
+  DEBUG_TOKEN_MANAGER = false;
+  LOOKAHEAD=3;
+  FORCE_LA_CHECK=true;
+  STATIC = false;
+}
+
+PARSER_BEGIN(GroupMatcherParser)
+package org.apache.maven.surefire.group.parse;
+
+import org.apache.maven.surefire.group.match.*;
+import java.io.*;
+
+public class GroupMatcherParser
+{
+    public static void main( String[] args )
+        throws Exception
+    {
+        BufferedReader reader = new BufferedReader( new InputStreamReader( System.in ) );
+        while( true )
+        {
+        try
+        {
+            System.out.print( "Enter expression: " );
+            String expr = reader.readLine();
+            GroupMatcherParser parser = new GroupMatcherParser( expr );
+            GroupMatcher matcher = parser.parse();
+            System.out.println( matcher );
+        }
+        catch ( ParseException e )
+        {
+            e.printStackTrace();
+        }
+        }
+    }
+    
+    public GroupMatcherParser( String expression )
+    {
+        this( (Reader)(new StringReader( expression ) ) );
+    }
+    
+    private GroupMatcher getMatcher( Op op, GroupMatcher...matchers )
+    {
+      GroupMatcher matcher = null;
+      if ( Op.AND == op )
+      {
+        matcher = new AndGroupMatcher( matchers );
+      }
+      else
+      {
+        matcher = new OrGroupMatcher( matchers );
+      }
+      
+      return matcher;
+    }
+    
+    public enum Op
+    {
+      AND, OR;
+    }
+}
+
+PARSER_END(GroupMatcherParser)
+
+SKIP :
+{
+  " "
+| "\t"
+| "\r"
+| "\n"
+}
+
+TOKEN:
+{
+  <AND: (["A", "a"] ["N", "n"] ["D", "d"]) >
+| <OR:  (["O","o"] ["R", "r"]) >
+| <AMP2: "&&">
+| <PIPE2: "||">
+| <NOT:   "NOT">
+| <BANG:  "!">
+| <LPAREN: "(">
+| <RPAREN: ")">
+| <STRING: (["A"-"Z", "a"-"z", "0"-"9", "_", "$", "#", "."])+ >
+| <CLS:    ".class">
+}
+
+GroupMatcher parse() :
+{GroupMatcher matcher = null;}
+{
+  matcher=expr()
+  {
+    return matcher;
+  }
+}
+
+GroupMatcher expr() :
+{
+GroupMatcher matcher=null;
+}
+{
+(
+  matcher=igroup()
+| matcher=group()
+)
+  {return matcher;}
+}
+
+GroupMatcher igroup() :
+{
+GroupMatcher lhs=null;
+GroupMatcher rhs=null;
+Op op=null;
+}
+{
+  (lhs=value() (op=op() rhs=expr())?)
+  {
+    GroupMatcher matcher = lhs;
+    if ( op != null )
+    {
+      matcher = getMatcher( op, lhs, rhs );
+    }
+    
+    return matcher;
+  }
+}
+
+GroupMatcher group() :
+{
+boolean inverted=false;
+GroupMatcher lhs=null;
+GroupMatcher rhs=null;
+Op op=null;
+}
+{
+  (not())?
+  {
+    inverted=true;
+  }
+  <LPAREN>
+  lhs=expr()
+  (
+  op=op()
+  rhs=expr()
+  )?
+  <RPAREN>
+  {
+    GroupMatcher matcher = lhs;
+    if ( op != null )
+    {
+      matcher = getMatcher( op, lhs, rhs );
+    }
+    
+    return inverted ? new InverseGroupMatcher( matcher ) : matcher;
+  }
+}
+
+GroupMatcher value() :
+{
+boolean inverted=false;
+Token val=null;
+}
+{
+( not()
+  {inverted=true;}
+)?
+  val=<STRING>
+  {
+    GroupMatcher m = new SingleGroupMatcher( val.image );
+    return inverted ? new InverseGroupMatcher( m ) : m;
+  }
+  (<CLS>)?
+}
+
+Op op() :
+{Op o=null;}
+{
+(
+  <AND>
+  {o=Op.AND;}
+| <OR> 
+  {o=Op.OR;}
+| <AMP2> 
+  {o=Op.AND;}
+| <PIPE2>
+  {o=Op.OR;}
+)  
+  {return o;}
+}
+
+void not() :
+{}
+{
+  <NOT> | <BANG>
+}

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/SpecificTestClassFilter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/SpecificTestClassFilter.java?rev=1235412&r1=1235411&r2=1235412&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/SpecificTestClassFilter.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/SpecificTestClassFilter.java Tue Jan 24 19:03:20 2012
@@ -38,7 +38,6 @@ public class SpecificTestClassFilter
         if ( names != null && !names.isEmpty() )
         {
             String className = testClass.getName().replace( '.', FS ) + JAVA_CLASS_FILE_EXTENSION;
-            System.out.println( "Checking classname: '" + className + "' against patterns:\n\n" + names + "\n\n" );
 
             boolean found = false;
             for ( Iterator it = names.iterator(); it.hasNext(); )
@@ -60,7 +59,6 @@ public class SpecificTestClassFilter
             }
         }
 
-        System.out.println( "Accepted? " + result );
         return result;
     }
 

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java?rev=1235412&r1=1235411&r2=1235412&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java Tue Jan 24 19:03:20 2012
@@ -67,7 +67,6 @@ public class DefaultDirectoryScanner
         String[] testClassNames = collectTests();
         List result = new ArrayList();
 
-        System.out.println( "Got specific tests: " + specificTests );
         String[] specific = specificTests == null ? new String[0] : processIncludesExcludes( specificTests );
         SpecificTestClassFilter specificTestFilter = new SpecificTestClassFilter( specific );
 
@@ -79,7 +78,6 @@ public class DefaultDirectoryScanner
 
             if ( !specificTestFilter.accept( testClass ) )
             {
-                System.out.println( "Skip: " + testClass.getName() );
                 // FIXME: Log this somehow!
                 continue;
             }
@@ -94,7 +92,6 @@ public class DefaultDirectoryScanner
             }
         }
 
-        System.out.println( "Running: " + result );
         return new TestsToRun( result );
     }
 

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java?rev=1235412&r1=1235411&r2=1235412&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java Tue Jan 24 19:03:20 2012
@@ -69,7 +69,6 @@ public class BooterDeserializer
         final List excludesList = properties.getStringList( EXCLUDES_PROPERTY_PREFIX );
         final List includesList = properties.getStringList( INCLUDES_PROPERTY_PREFIX );
         final List specificTestsList = properties.getStringList( SPECIFIC_TEST_PROPERTY_PREFIX );
-        System.out.println( "DESER: Got specific tests: " + specificTestsList );
 
         final List testSuiteXmlFiles = properties.getStringList( TEST_SUITE_XML_FILES );
         final File testClassesDirectory = properties.getFileProperty( TEST_CLASSES_DIRECTORY );

Modified: maven/surefire/trunk/surefire-providers/common-junit48/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/common-junit48/pom.xml?rev=1235412&r1=1235411&r2=1235412&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/common-junit48/pom.xml (original)
+++ maven/surefire/trunk/surefire-providers/common-junit48/pom.xml Tue Jan 24 19:03:20 2012
@@ -47,8 +47,11 @@
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
     </dependency>
-
- </dependencies>
+    <dependency>
+      <groupId>org.apache.maven.surefire</groupId>
+      <artifactId>maven-surefire-common</artifactId>
+    </dependency>
+  </dependencies>
 
   <build>
     <plugins>
@@ -78,6 +81,14 @@
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <excludes>
+            <exclude>**/fixture/**</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
 </project>

Modified: maven/surefire/trunk/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/FilterFactory.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/FilterFactory.java?rev=1235412&r1=1235411&r2=1235412&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/FilterFactory.java (original)
+++ maven/surefire/trunk/surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/FilterFactory.java Tue Jan 24 19:03:20 2012
@@ -20,12 +20,19 @@ package org.apache.maven.surefire.common
  */
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Properties;
 import org.apache.maven.surefire.booter.ProviderParameterNames;
+import org.apache.maven.surefire.group.match.AndGroupMatcher;
+import org.apache.maven.surefire.group.match.GroupMatcher;
+import org.apache.maven.surefire.group.match.InverseGroupMatcher;
+import org.apache.maven.surefire.group.match.OrGroupMatcher;
+import org.apache.maven.surefire.group.parse.GroupMatcherParser;
+import org.apache.maven.surefire.group.parse.ParseException;
 import org.codehaus.plexus.util.SelectorUtils;
 
-import org.junit.experimental.categories.Categories;
+import org.junit.experimental.categories.Category;
 import org.junit.runner.Description;
 import org.junit.runner.manipulation.Filter;
 
@@ -45,14 +52,14 @@ public class FilterFactory
     {
         String groups = providerProperties.getProperty( ProviderParameterNames.TESTNG_GROUPS_PROP );
         String excludedGroups = providerProperties.getProperty( ProviderParameterNames.TESTNG_EXCLUDEDGROUPS_PROP );
-        List<Filter> included = commaSeparatedListToFilters( groups );
-        List<Filter> excluded = commaSeparatedListToFilters( excludedGroups );
-        return new CombinedCategoryFilter( included, excluded );
+        GroupMatcher included = commaSeparatedListToFilters( groups );
+        GroupMatcher excluded = commaSeparatedListToFilters( excludedGroups );
+        return new GroupMatcherCategoryFilter( included, excluded );
     }
 
-    private List<Filter> commaSeparatedListToFilters( String str )
+    private GroupMatcher commaSeparatedListToFilters( String str )
     {
-        List<Filter> included = new ArrayList<Filter>();
+        List<GroupMatcher> included = new ArrayList<GroupMatcher>();
         if ( str != null )
         {
             for ( String group : str.split( "," ) )
@@ -62,11 +69,25 @@ public class FilterFactory
                 {
                     continue;
                 }
-                Class<?> categoryType = classloadCategory( group );
-                included.add( Categories.CategoryFilter.include( categoryType ) );
+
+                try
+                {
+                    GroupMatcher matcher = new GroupMatcherParser( group ).parse();
+                    included.add( matcher );
+                }
+                catch ( ParseException e )
+                {
+                    // TODO Auto-generated catch block
+                    throw new IllegalArgumentException( "Invalid group expression: '" + group + "'. Reason: "
+                        + e.getMessage(), e );
+                }
+
+                // Class<?> categoryType = classloadCategory( group );
+                // included.add( Categories.CategoryFilter.include( categoryType ) );
             }
         }
-        return included;
+
+        return included.isEmpty() ? null : new OrGroupMatcher( included );
     }
 
     public Filter createMethodFilter( String requestedTestMethod )
@@ -111,7 +132,70 @@ public class FilterFactory
         }
     }
 
+    private static class GroupMatcherCategoryFilter
+        extends Filter
+    {
+
+        private AndGroupMatcher matcher;
+
+        public GroupMatcherCategoryFilter( GroupMatcher included, GroupMatcher excluded )
+        {
+            GroupMatcher invertedExclude = excluded == null ? null : new InverseGroupMatcher( excluded );
+            if ( included != null || invertedExclude != null )
+            {
+                matcher = new AndGroupMatcher();
+                if ( included != null )
+                {
+                    matcher.addMatcher( included );
+                }
+
+                if ( invertedExclude != null )
+                {
+                    matcher.addMatcher( invertedExclude );
+                }
+            }
+        }
+
+        @Override
+        public boolean shouldRun( Description description )
+        {
+            if ( matcher == null )
+            {
+                return true;
+            }
+
+            Category cat = description.getAnnotation( Category.class );
+            if ( cat == null )
+            {
+                cat = description.getTestClass().getAnnotation( Category.class );
+            }
+
+            System.out.println( "\n\nMatcher: " + matcher );
+
+            if ( cat == null )
+            {
+                System.out.println( "\tChecking: " + description.getClassName() + "#" + description.getMethodName()
+                    + " with no category annotations... Enabled? " + ( matcher.enabled( (String) null ) ) );
+                return matcher.enabled( (String) null );
+            }
+
+            System.out.println( "\tChecking: " + description.getClassName() + "#" + description.getMethodName()
+                + " with category annotations:\n\t" + Arrays.toString( cat.value() ) + "\nEnabled? "
+                + ( matcher.enabled( cat.value() ) ) );
+
+            return matcher.enabled( cat.value() );
+        }
+
+        @Override
+        public String describe()
+        {
+            return matcher == null ? "ANY" : matcher.toString();
+        }
+
+    }
+
 
+    @SuppressWarnings( "unused" )
     private static class CombinedCategoryFilter
         extends Filter
     {

Added: maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/cat/First.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/cat/First.java?rev=1235412&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/cat/First.java (added)
+++ maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/cat/First.java Tue Jan 24 19:03:20 2012
@@ -0,0 +1,6 @@
+package org.apache.maven.surefire.common.junit48.fixture.cat;
+
+public class First
+{
+
+}

Propchange: maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/cat/First.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/cat/Second.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/cat/Second.java?rev=1235412&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/cat/Second.java (added)
+++ maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/cat/Second.java Tue Jan 24 19:03:20 2012
@@ -0,0 +1,6 @@
+package org.apache.maven.surefire.common.junit48.fixture.cat;
+
+public class Second
+{
+
+}

Propchange: maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/cat/Second.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/cat/Third.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/cat/Third.java?rev=1235412&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/cat/Third.java (added)
+++ maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/cat/Third.java Tue Jan 24 19:03:20 2012
@@ -0,0 +1,6 @@
+package org.apache.maven.surefire.common.junit48.fixture.cat;
+
+public class Third
+{
+
+}

Propchange: maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/cat/Third.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/test/FirstTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/test/FirstTest.java?rev=1235412&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/test/FirstTest.java (added)
+++ maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/test/FirstTest.java Tue Jan 24 19:03:20 2012
@@ -0,0 +1,10 @@
+package org.apache.maven.surefire.common.junit48.fixture.test;
+
+import org.apache.maven.surefire.common.junit48.fixture.cat.First;
+import org.junit.experimental.categories.Category;
+
+@Category( First.class )
+public class FirstTest
+{
+
+}

Propchange: maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/test/FirstTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/test/SecondTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/test/SecondTest.java?rev=1235412&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/test/SecondTest.java (added)
+++ maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/test/SecondTest.java Tue Jan 24 19:03:20 2012
@@ -0,0 +1,10 @@
+package org.apache.maven.surefire.common.junit48.fixture.test;
+
+import org.apache.maven.surefire.common.junit48.fixture.cat.Second;
+import org.junit.experimental.categories.Category;
+
+@Category( Second.class )
+public class SecondTest
+{
+
+}

Propchange: maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/test/SecondTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/test/ThirdTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/test/ThirdTest.java?rev=1235412&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/test/ThirdTest.java (added)
+++ maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/test/ThirdTest.java Tue Jan 24 19:03:20 2012
@@ -0,0 +1,10 @@
+package org.apache.maven.surefire.common.junit48.fixture.test;
+
+import org.apache.maven.surefire.common.junit48.fixture.cat.Third;
+import org.junit.experimental.categories.Category;
+
+@Category( Third.class )
+public class ThirdTest
+{
+
+}

Propchange: maven/surefire/trunk/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/fixture/test/ThirdTest.java
------------------------------------------------------------------------------
    svn:eol-style = native