maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krosenv...@apache.org
Subject svn commit: r1049118 - in /maven/surefire/trunk: maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/ maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ maven-surefire-common/src/main/java/org/apache/maven/plugin/sur...
Date Tue, 14 Dec 2010 14:55:53 GMT
Author: krosenvold
Date: Tue Dec 14 14:55:52 2010
New Revision: 1049118

URL: http://svn.apache.org/viewvc?rev=1049118&view=rev
Log:
[SUREFIRE-321] Added runOrder mojo attribute, including documentation.

Also added IT for the various runOrder settings.
Also fixed minor regression in selection of reporters

Added:
    maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/RunOrderIT.java
  (with props)
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/pom.xml  
(with props)
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/src/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/src/test/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/src/test/java/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/src/test/java/junit/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/src/test/java/junit/runOrder/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/src/test/java/junit/runOrder/TestA.java
  (with props)
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/src/test/java/junit/runOrder/TestB.java
  (with props)
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/src/test/java/junit/runOrder/TestC.java
  (with props)
Modified:
    maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
    maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
    maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
    maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/testset/DirectoryScannerParameters.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/SurefireDirectoryScannerTest.java
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java
    maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java

Modified: maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java?rev=1049118&r1=1049117&r2=1049118&view=diff
==============================================================================
--- maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
(original)
+++ maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
Tue Dec 14 14:55:52 2010
@@ -595,6 +595,20 @@ public class IntegrationTestMojo
     private Boolean parallelMavenExecution;
 
     /**
+      * Defines the order the tests will be run in. Supported values are alphabetical, reversealphabetical
+      * random, hourly (alphabetical on even hours, reverse alphabetical on odd hours).
+      *
+      * Not supplying a value for this setting will run tests in filesystem order.
+      *
+      * Odd/Even is determined at the time the of scanning the classpath, meaning it could
change during
+      * a multi-module build.
+      *
+      * @parameter
+      * @since 2.7
+      */
+     private String runOrder;
+
+    /**
      * @component
      */
     private ToolchainManager toolchainManager;
@@ -1332,5 +1346,13 @@ public class IntegrationTestMojo
         return parallelMavenExecution != null && parallelMavenExecution.booleanValue();
     }
 
+    public String getRunOrder()
+    {
+        return runOrder;
+    }
 
+    public void setRunOrder( String runOrder )
+    {
+        this.runOrder = runOrder;
+    }
 }

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=1049118&r1=1049117&r2=1049118&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 Dec 14 14:55:52 2010
@@ -292,7 +292,8 @@ public abstract class AbstractSurefireMo
             List includes = getIncludeList();
             List excludes = getExcludeList();
             directoryScannerParameters = new DirectoryScannerParameters( getTestClassesDirectory(),
includes, excludes,
-                                                                         Boolean.valueOf(
failIfNoTests ) );
+                                                                         Boolean.valueOf(
failIfNoTests ),
+                                                                         getRunOrder() );
         }
 
         Properties providerProperties = getProperties();
@@ -855,9 +856,12 @@ public abstract class AbstractSurefireMo
      */
     private String getConsoleReporter( boolean forking )
     {
-        if ( isUseFile() && isPrintSummary() )
+        if ( isUseFile() )
         {
-            return forking ? ForkingConsoleReporter.class.getName() : ConsoleReporter.class.getName();
+            if ( isPrintSummary() )
+            {
+                return forking ? ForkingConsoleReporter.class.getName() : ConsoleReporter.class.getName();
+            }
         }
         else if ( BRIEF_REPORT_FORMAT.equals( getReportFormat() ) )
         {

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java?rev=1049118&r1=1049117&r2=1049118&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java
(original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java
Tue Dec 14 14:55:52 2010
@@ -269,4 +269,8 @@ public interface SurefireExecutionParame
 
     boolean isMavenParallel();
 
+    void setRunOrder(String runOrder);
+
+    String getRunOrder();
+
 }

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java?rev=1049118&r1=1049117&r2=1049118&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
(original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
Tue Dec 14 14:55:52 2010
@@ -102,6 +102,8 @@ public class BooterSerializer
             properties.addList( directoryScannerParameters.getExcludes(), BooterConstants.EXCLUDES_PROPERTY_PREFIX
);
             properties.setProperty( BooterConstants.TEST_CLASSES_DIRECTORY,
                                     directoryScannerParameters.getTestClassesDirectory()
);
+            properties.setProperty( BooterConstants.RUN_ORDER,
+                                    directoryScannerParameters.getRunOrder() );
         }
 
         ReporterConfiguration reporterConfiguration = booterConfiguration.getReporterConfiguration();

Modified: maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java?rev=1049118&r1=1049117&r2=1049118&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
(original)
+++ maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
Tue Dec 14 14:55:52 2010
@@ -172,7 +172,7 @@ public class BooterDeserializerProviderC
         excludes.add( "xx1" );
         excludes.add( "xx2" );
 
-        return new DirectoryScannerParameters( aDir, includes, excludes, Boolean.TRUE );
+        return new DirectoryScannerParameters( aDir, includes, excludes, Boolean.TRUE, null
);
     }
 
     private ProviderConfiguration saveAndReload( ProviderConfiguration booterConfiguration,

Modified: maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java?rev=1049118&r1=1049117&r2=1049118&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
(original)
+++ maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
Tue Dec 14 14:55:52 2010
@@ -129,7 +129,7 @@ public class BooterDeserializerStartupCo
 
         File cwd = new File( "." );
         DirectoryScannerParameters directoryScannerParameters =
-            new DirectoryScannerParameters( cwd, new ArrayList(), new ArrayList(), Boolean.TRUE
);
+            new DirectoryScannerParameters( cwd, new ArrayList(), new ArrayList(), Boolean.TRUE,
"hourly" );
         ReporterConfiguration reporterConfiguration = new ReporterConfiguration( new ArrayList(),
cwd, Boolean.TRUE );
         TestRequest testSuiteDefinition =
             new TestRequest( Arrays.asList( getSuiteXmlFileStrings()), getTestSourceDirectory(),
aUserRequestedTest );

Modified: maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java?rev=1049118&r1=1049117&r2=1049118&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
(original)
+++ maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
Tue Dec 14 14:55:52 2010
@@ -445,7 +445,6 @@ public class SurefirePlugin
      * (JUnit 4.7 provider) Supports values classes/methods/both to run in separate threads,
as controlled by threadCount.
      *
      * @parameter expression="${parallel}"
-     * @todo test how this works with forking, and console/file output parallelism
      * @since 2.2
      */
     private String parallel;
@@ -559,6 +558,20 @@ public class SurefirePlugin
     private Boolean parallelMavenExecution;
 
     /**
+     * Defines the order the tests will be run in. Supported values are alphabetical, reversealphabetical
+     * random, hourly (alphabetical on even hours, reverse alphabetical on odd hours).
+     *
+     * Not supplying a value for this setting will run tests in filesystem order.
+     *
+     * Odd/Even is determined at the time the of scanning the classpath, meaning it could
change during
+     * a multi-module build.
+     *
+     * @parameter
+     * @since 2.7
+     */
+    private String runOrder;
+
+    /**
      * @component
      */
     private ToolchainManager toolchainManager;
@@ -1236,5 +1249,13 @@ public class SurefirePlugin
         return parallelMavenExecution != null && parallelMavenExecution.booleanValue();
     }
 
+    public String getRunOrder()
+    {
+        return runOrder;
+    }
 
+    public void setRunOrder( String runOrder )
+    {
+        this.runOrder = runOrder;
+    }
 }

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java?rev=1049118&r1=1049117&r2=1049118&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java
(original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java
Tue Dec 14 14:55:52 2010
@@ -61,7 +61,8 @@ public class BaseProviderFactory
         }
         return new DefaultDirectoryScanner( directoryScannerParameters.getTestClassesDirectory(),
                                             directoryScannerParameters.getIncludes(),
-                                            directoryScannerParameters.getExcludes() );
+                                            directoryScannerParameters.getExcludes(),
+                                            directoryScannerParameters.getRunOrder());
     }
 
     public ReporterFactory getReporterFactory()

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java?rev=1049118&r1=1049117&r2=1049118&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
(original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
Tue Dec 14 14:55:52 2010
@@ -156,13 +156,14 @@ public class SurefireReflector
         {
             return null;
         }
-        Class[] arguments = { File.class, List.class, List.class, Boolean.class };
+        Class[] arguments = { File.class, List.class, List.class, Boolean.class, String.class
};
         Constructor constructor = ReflectionUtils.getConstructor( this.directoryScannerParameters,
arguments );
         return ReflectionUtils.newInstance( constructor,
                                             new Object[]{ directoryScannerParameters.getTestClassesDirectory(),
                                                 directoryScannerParameters.getIncludes(),
                                                 directoryScannerParameters.getExcludes(),
-                                                directoryScannerParameters.isFailIfNoTests()
} );
+                                                directoryScannerParameters.isFailIfNoTests(),
+                                                directoryScannerParameters.getRunOrder()
} );
     }
 
     Object createTestArtifactInfo( TestArtifactInfo testArtifactInfo )

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java?rev=1049118&r1=1049117&r2=1049118&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java
(original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java
Tue Dec 14 14:55:52 2010
@@ -63,7 +63,8 @@ public abstract class AbstractDirectoryT
 
     protected AbstractDirectoryTestSuite( File basedir, List includes, List excludes )
     {
-        this.surefireDirectoryScanner = new DefaultDirectoryScanner( basedir, includes, excludes
);
+        this.surefireDirectoryScanner = new DefaultDirectoryScanner( basedir, includes, excludes,
+                                                                     "filesystem" );
     }
 
     public Map locateTestSets( ClassLoader classLoader )

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/testset/DirectoryScannerParameters.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/testset/DirectoryScannerParameters.java?rev=1049118&r1=1049117&r2=1049118&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/testset/DirectoryScannerParameters.java
(original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/testset/DirectoryScannerParameters.java
Tue Dec 14 14:55:52 2010
@@ -35,13 +35,15 @@ public class DirectoryScannerParameters
 
     private final Boolean failIfNoTests;
 
+    private final String runOrder;
 
-    public DirectoryScannerParameters( File testClassesDirectory, List includes, List excludes,
Boolean failIfNoTests )
+    public DirectoryScannerParameters( File testClassesDirectory, List includes, List excludes,
Boolean failIfNoTests, String runOrder )
     {
         this.testClassesDirectory = testClassesDirectory;
         this.includes = includes;
         this.excludes = excludes;
         this.failIfNoTests = failIfNoTests;
+        this.runOrder = runOrder;
     }
 
     /**
@@ -79,4 +81,9 @@ public class DirectoryScannerParameters
     {
         return failIfNoTests;
     }
+
+    public String getRunOrder()
+    {
+        return runOrder;
+    }
 }

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=1049118&r1=1049117&r2=1049118&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 Dec 14 14:55:52 2010
@@ -21,6 +21,9 @@ package org.apache.maven.surefire.util;
 
 import java.io.File;
 import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.List;
 
 /**
@@ -49,12 +52,18 @@ public class DefaultDirectoryScanner
 
     private final List classesSkippedByValidation = new ArrayList();
 
+    private final Comparator sortOrder;
 
-    public DefaultDirectoryScanner( File basedir, List includes, List excludes )
+    private final String runOrder;
+
+
+    public DefaultDirectoryScanner( File basedir, List includes, List excludes, String runOrder
)
     {
         this.basedir = basedir;
         this.includes = includes;
         this.excludes = excludes;
+        this.runOrder = runOrder;
+        this.sortOrder = getSortOrderComparator( runOrder );
     }
 
     public TestsToRun locateTestClasses( ClassLoader classLoader, ScannerFilter scannerFilter
)
@@ -77,6 +86,14 @@ public class DefaultDirectoryScanner
                 classesSkippedByValidation.add( testClass );
             }
         }
+        if ( "random".equals( runOrder ) )
+        {
+            Collections.shuffle( result );
+        }
+        else if ( sortOrder != null )
+        {
+            Collections.sort( result, sortOrder );
+        }
         return new TestsToRun( result );
     }
 
@@ -161,4 +178,48 @@ public class DefaultDirectoryScanner
     {
         return classesSkippedByValidation;
     }
+
+    private Comparator getSortOrderComparator( String runOrder )
+    {
+        if ( "alphabetical".equals( runOrder ) )
+        {
+            return getAlphabeticalComparator();
+        }
+
+        else if ( "reversealphabetical".equals( runOrder ) )
+        {
+            return getReverseAlphabeticalComparator();
+        }
+        else if ( "hourly".equals( runOrder ) )
+        {
+            final int hour = Calendar.getInstance().get( Calendar.HOUR_OF_DAY );
+            return ( ( hour % 2 ) == 0 )
+                ? getAlphabeticalComparator()
+                : getReverseAlphabeticalComparator();
+        }
+        return null;
+    }
+
+    private Comparator getReverseAlphabeticalComparator()
+    {
+        return new Comparator()
+        {
+            public int compare( Object o1, Object o2 )
+            {
+                return ( (Class) o2 ).getName().compareTo( ( (Class) o1 ).getName() );
+            }
+        };
+    }
+
+    private Comparator getAlphabeticalComparator()
+    {
+        return new Comparator()
+        {
+            public int compare( Object o1, Object o2 )
+            {
+                return ( (Class) o1 ).getName().compareTo( ( (Class) o2 ).getName() );
+            }
+        };
+    }
+
 }

Modified: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/SurefireDirectoryScannerTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/SurefireDirectoryScannerTest.java?rev=1049118&r1=1049117&r2=1049118&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/SurefireDirectoryScannerTest.java
(original)
+++ maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/SurefireDirectoryScannerTest.java
Tue Dec 14 14:55:52 2010
@@ -20,13 +20,12 @@ package org.apache.maven.surefire.util;
  */
 
 import junit.framework.TestCase;
+import org.apache.maven.surefire.testset.TestSetFailedException;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.List;
 import java.util.ArrayList;
-
-import org.apache.maven.surefire.testset.TestSetFailedException;
+import java.util.List;
 
 /**
  * Test of the directory scanner.
@@ -42,7 +41,8 @@ public class SurefireDirectoryScannerTes
         include.add( "**/*ZT*A.java" );
         List exclude = new ArrayList();
 
-        DefaultDirectoryScanner surefireDirectoryScanner = new DefaultDirectoryScanner( baseDir,
include, exclude );
+        DefaultDirectoryScanner surefireDirectoryScanner = new DefaultDirectoryScanner( baseDir,
include, exclude,
+                                                                                        "filesystem"
);
         String[] classNames = surefireDirectoryScanner.collectTests();
         assertNotNull( classNames );
         assertEquals( 4, classNames.length );

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java?rev=1049118&r1=1049117&r2=1049118&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java
(original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java
Tue Dec 14 14:55:52 2010
@@ -47,6 +47,7 @@ public interface BooterConstants
     String REQUESTEDTEST = "requestedTest";
     String SOURCE_DIRECTORY = "testSuiteDefinitionTestSourceDirectory";
     String TEST_CLASSES_DIRECTORY = "testClassesDirectory";
+    String RUN_ORDER = "runOrder";
     String TEST_SUITE_XML_FILES = "testSuiteXmlFiles";
     String PROVIDER_CONFIGURATION = "providerConfiguration";
     String FORKTESTSET = "forkTestSet";

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=1049118&r1=1049117&r2=1049118&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 Dec 14 14:55:52 2010
@@ -72,12 +72,13 @@ public class BooterDeserializer
         final List excludesList = properties.getStringList( EXCLUDES_PROPERTY_PREFIX );
         final List includesList = properties.getStringList( INCLUDES_PROPERTY_PREFIX );
 
-        List testSuiteXmlFiles = properties.getStringList( TEST_SUITE_XML_FILES );
+        final List testSuiteXmlFiles = properties.getStringList( TEST_SUITE_XML_FILES );
         final File testClassesDirectory = properties.getFileProperty( TEST_CLASSES_DIRECTORY
);
+        final String runOrder = properties.getProperty( RUN_ORDER );
 
         DirectoryScannerParameters dirScannerParams =
             new DirectoryScannerParameters( testClassesDirectory, includesList, excludesList,
-                                            valueOf( properties.getBooleanProperty( FAILIFNOTESTS
) ) );
+                                            valueOf( properties.getBooleanProperty( FAILIFNOTESTS
) ) , runOrder);
 
         TestArtifactInfo testNg = new TestArtifactInfo( testNgVersion, testArtifactClassifier
);
         TestRequest testSuiteDefinition = new TestRequest( testSuiteXmlFiles, sourceDirectory,
requestedTest );

Modified: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java?rev=1049118&r1=1049117&r2=1049118&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
(original)
+++ maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
Tue Dec 14 14:55:52 2010
@@ -45,7 +45,7 @@ public class SurefireReflectorTest
         Object foo = getFoo();
 
         DirectoryScannerParameters directoryScannerParameters =
-            new DirectoryScannerParameters( new File( "ABC" ), new ArrayList(), new ArrayList(),
Boolean.FALSE );
+            new DirectoryScannerParameters( new File( "ABC" ), new ArrayList(), new ArrayList(),
Boolean.FALSE, "hourly" );
         surefireReflector.setDirectoryScannerParameters( foo, directoryScannerParameters
);
         assertTrue( isCalled( foo ).booleanValue());
 

Added: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/RunOrderIT.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/RunOrderIT.java?rev=1049118&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/RunOrderIT.java
(added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/RunOrderIT.java
Tue Dec 14 14:55:52 2010
@@ -0,0 +1,131 @@
+package org.apache.maven.surefire.its;
+/*
+ * 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.
+ */
+
+import org.apache.maven.it.VerificationException;
+import org.apache.maven.it.Verifier;
+import org.apache.maven.it.util.ResourceExtractor;
+import org.apache.maven.reporting.MavenReportException;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Verifies the runOrder setting and its effect
+ *
+ * @author Kristian Rosenvold
+ */
+public class RunOrderIT
+    extends AbstractSurefireIntegrationTestClass
+{
+    // testing random is left as an exercise to the reader. Patches welcome
+
+    public void testAlphabetical()
+        throws Exception
+    {
+        checkOrder( "alphabetical", getAlphabetical() );
+    }
+
+
+    public void testReverseAlphabetical()
+        throws Exception
+    {
+        checkOrder( "reversealphabetical", getReverseAlphabetical() );
+    }
+
+
+    public void testHourly()
+        throws Exception
+    {
+        int startHour = Calendar.getInstance().get( Calendar.HOUR_OF_DAY );
+        final List actual = executeWithRunOrder( "hourly" );
+        int endHour = Calendar.getInstance().get( Calendar.HOUR_OF_DAY );
+        if ( startHour != endHour )
+        {
+            return; // Race condition, cannot test when hour changed mid-run
+        }
+
+        List expected = ( ( startHour % 2 ) == 0 ) ? getAlphabetical() : getReverseAlphabetical();
+        if ( !contains( actual, expected ) )
+        {
+            throw new VerificationException( "Response does not contain expected item" );
+        }
+    }
+
+    private boolean contains( List items, List expected )
+    {
+        Iterator expectedIterator = expected.iterator();
+        String next = (String) expectedIterator.next();
+        Iterator content = items.iterator();
+        while ( content.hasNext() )
+        {
+            String line = (String) content.next();
+            if ( line.startsWith( next ) )
+            {
+                if ( !expectedIterator.hasNext() )
+                {
+                    return true;
+                }
+                next = (String) expectedIterator.next();
+            }
+        }
+        return content.hasNext();
+    }
+
+    private void checkOrder( String alphabetical, List expected )
+        throws VerificationException, MavenReportException, IOException
+    {
+        final List list = executeWithRunOrder( alphabetical );
+        if ( !contains( list, expected ) )
+        {
+            throw new VerificationException( "Response does not contain expected item" );
+        }
+    }
+
+    private List executeWithRunOrder( String runOrder )
+        throws IOException, VerificationException, MavenReportException
+    {
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/runOrder"
);
+        Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+
+        List goals = getInitialGoals();
+        goals.add( "-DrunOrder=" + runOrder );
+        goals.add( "test" );
+        this.executeGoals( verifier, goals );
+        verifier.verifyErrorFreeLog();
+        verifier.resetStreams();
+        HelperAssertions.assertTestSuiteResults( 3, 0, 0, 0, testDir );
+        return verifier.loadFile( verifier.getBasedir(), verifier.getLogFileName(), false
);
+    }
+
+    private List getAlphabetical()
+    {
+        return Arrays.asList( new String[]{ "TA", "TB", "TC" } );
+    }
+
+    private List getReverseAlphabetical()
+    {
+        return Arrays.asList( new String[]{ "TC", "TB", "TA" } );
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/RunOrderIT.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/pom.xml?rev=1049118&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/pom.xml (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/pom.xml Tue
Dec 14 14:55:52 2010
@@ -0,0 +1,62 @@
+<?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.plugins.surefire</groupId>
+  <artifactId>runOrder</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <name>Test for runOrder</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>${surefire.version}</version>
+        <configuration>
+          <forkMode>once</forkMode>
+          <printSummary>false</printSummary>
+          <runOrder>${runOrder}</runOrder>
+        </configuration>
+        <dependencies>
+          <!-- dependency>
+              <groupId>org.apache.maven.surefire</groupId>
+              <artifactId>${testProvider}</artifactId>
+              <version>${surefire.version}</version>
+          </dependency -->
+        </dependencies>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/src/test/java/junit/runOrder/TestA.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/src/test/java/junit/runOrder/TestA.java?rev=1049118&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/src/test/java/junit/runOrder/TestA.java
(added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/src/test/java/junit/runOrder/TestA.java
Tue Dec 14 14:55:52 2010
@@ -0,0 +1,11 @@
+package junit.runOrder;
+import junit.framework.TestCase;
+
+
+public class TestA
+    extends TestCase
+{
+    public void testTwo() {
+        System.out.println("TA");
+    }
+}

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/src/test/java/junit/runOrder/TestA.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/src/test/java/junit/runOrder/TestB.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/src/test/java/junit/runOrder/TestB.java?rev=1049118&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/src/test/java/junit/runOrder/TestB.java
(added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/src/test/java/junit/runOrder/TestB.java
Tue Dec 14 14:55:52 2010
@@ -0,0 +1,11 @@
+package junit.runOrder;
+import junit.framework.TestCase;
+
+
+public class TestB
+    extends TestCase
+{
+    public void testTwo() {
+        System.out.println("TB");
+    }
+}

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/src/test/java/junit/runOrder/TestB.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/src/test/java/junit/runOrder/TestC.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/src/test/java/junit/runOrder/TestC.java?rev=1049118&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/src/test/java/junit/runOrder/TestC.java
(added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/src/test/java/junit/runOrder/TestC.java
Tue Dec 14 14:55:52 2010
@@ -0,0 +1,11 @@
+package junit.runOrder;
+import junit.framework.TestCase;
+
+
+public class TestC
+    extends TestCase
+{
+    public void testTwo() {
+        System.out.println("TC");
+    }
+}

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/runOrder/src/test/java/junit/runOrder/TestC.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message