Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
import org.apache.maven.plugin.surefire.booterclient.ProviderDetector;
import org.apache.maven.plugin.surefire.log.PluginConsoleLogger;
import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
import org.apache.maven.plugin.surefire.runorder.api.RunOrder;
import org.apache.maven.plugin.surefire.runorder.impl.RunOrderLoader;
import org.apache.maven.plugin.surefire.util.DependencyScanner;
import org.apache.maven.plugin.surefire.util.DirectoryScanner;
import org.apache.maven.plugins.annotations.Component;
Expand Down Expand Up @@ -75,7 +77,6 @@
import org.apache.maven.surefire.testset.TestRequest;
import org.apache.maven.surefire.testset.TestSetFailedException;
import org.apache.maven.surefire.util.DefaultScanResult;
import org.apache.maven.surefire.util.RunOrder;
import org.apache.maven.surefire.util.SurefireReflectionException;
import org.apache.maven.toolchain.DefaultToolchain;
import org.apache.maven.toolchain.Toolchain;
Expand Down Expand Up @@ -107,6 +108,9 @@
import static org.apache.commons.lang3.JavaVersion.JAVA_RECENT;
import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS;
import static org.apache.commons.lang3.SystemUtils.isJavaVersionAtLeast;
import static org.apache.maven.plugin.surefire.runorder.impl.RunOrderLoader.defaultRunOrder;
import static org.apache.maven.plugin.surefire.runorder.model.RunOrderFactory.BALANCED;
import static org.apache.maven.plugin.surefire.runorder.model.RunOrderFactory.FAILEDFIRST;
import static org.apache.maven.shared.utils.StringUtils.capitalizeFirstLetter;
import static org.apache.maven.shared.utils.StringUtils.isEmpty;
import static org.apache.maven.shared.utils.StringUtils.isNotBlank;
Expand Down Expand Up @@ -1530,14 +1534,15 @@ String getEffectiveForkMode()
private List<RunOrder> getRunOrders()
{
String runOrderString = getRunOrder();
RunOrder[] runOrder = runOrderString == null ? RunOrder.DEFAULT : RunOrder.valueOfMulti( runOrderString );
RunOrder[] runOrder = runOrderString == null ? defaultRunOrder()
: RunOrderLoader.runOrdersOf( runOrderString );
return Arrays.asList( runOrder );
}

private boolean requiresRunHistory()
{
final List<RunOrder> runOrders = getRunOrders();
return runOrders.contains( RunOrder.BALANCED ) || runOrders.contains( RunOrder.FAILEDFIRST );
return runOrders.contains( BALANCED ) || runOrders.contains( FAILEDFIRST );
}

private boolean getEffectiveFailIfNoTests()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import java.io.File;
import java.io.IOException;
import java.util.List;

import org.apache.maven.plugin.surefire.SurefireProperties;
import org.apache.maven.plugin.surefire.runorder.impl.RunOrderLoader;
import org.apache.maven.surefire.booter.ClassLoaderConfiguration;
import org.apache.maven.surefire.booter.ClasspathConfiguration;
import org.apache.maven.surefire.booter.KeyValueSource;
Expand All @@ -37,7 +37,6 @@
import org.apache.maven.surefire.testset.TestArtifactInfo;
import org.apache.maven.surefire.testset.TestListResolver;
import org.apache.maven.surefire.testset.TestRequest;
import org.apache.maven.surefire.util.RunOrder;

// CHECKSTYLE_OFF: imports
import static org.apache.maven.surefire.booter.BooterConstants.*;
Expand Down Expand Up @@ -119,7 +118,7 @@ File serialize( KeyValueSource sourceProperties, ProviderConfiguration booterCon
final RunOrderParameters runOrderParameters = booterConfiguration.getRunOrderParameters();
if ( runOrderParameters != null )
{
properties.setProperty( RUN_ORDER, RunOrder.asString( runOrderParameters.getRunOrder() ) );
properties.setProperty( RUN_ORDER, RunOrderLoader.asString( runOrderParameters.getRunOrders() ) );
properties.setProperty( RUN_STATISTICS_FILE, runOrderParameters.getRunStatisticsFile() );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@

import java.io.File;
import java.io.FileNotFoundException;

import org.apache.maven.plugin.surefire.runorder.impl.statistics.RunEntryStatisticsMap;
import org.apache.maven.surefire.report.ReportEntry;

import static org.apache.maven.plugin.surefire.runorder.RunEntryStatisticsMap.fromFile;
import static org.apache.maven.plugin.surefire.runorder.impl.statistics.RunEntryStatisticsMap.fromFile;

/**
* @author Kristian Rosenvold
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,36 @@
* under the License.
*/

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import junit.framework.Assert;
import junit.framework.TestCase;
import org.apache.maven.surefire.booter.*;
import org.apache.maven.plugin.surefire.runorder.impl.RunOrderLoader;
import org.apache.maven.surefire.booter.BooterDeserializer;
import org.apache.maven.surefire.booter.ClassLoaderConfiguration;
import org.apache.maven.surefire.booter.ClasspathConfiguration;
import org.apache.maven.surefire.booter.PropertiesWrapper;
import org.apache.maven.surefire.booter.ProviderConfiguration;
import org.apache.maven.surefire.booter.Shutdown;
import org.apache.maven.surefire.booter.StartupConfiguration;
import org.apache.maven.surefire.booter.TypeEncodedValue;
import org.apache.maven.surefire.cli.CommandLineOption;
import org.apache.maven.surefire.report.ReporterConfiguration;
import org.apache.maven.surefire.testset.*;
import org.apache.maven.surefire.util.RunOrder;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.*;

import org.apache.maven.surefire.testset.DirectoryScannerParameters;
import org.apache.maven.surefire.testset.ResolvedTest;
import org.apache.maven.surefire.testset.RunOrderParameters;
import org.apache.maven.surefire.testset.TestArtifactInfo;
import org.apache.maven.surefire.testset.TestListResolver;
import org.apache.maven.surefire.testset.TestRequest;

import static org.apache.maven.plugin.surefire.runorder.impl.RunOrderLoader.defaultRunOrder;
import static org.apache.maven.plugin.surefire.runorder.impl.RunOrderLoader.getRunOrderProvider;
import static org.apache.maven.surefire.cli.CommandLineOption.LOGGING_LEVEL_DEBUG;
import static org.apache.maven.surefire.cli.CommandLineOption.REACTOR_FAIL_FAST;
import static org.apache.maven.surefire.cli.CommandLineOption.SHOW_ERRORS;
Expand Down Expand Up @@ -199,7 +216,7 @@ private DirectoryScannerParameters getDirectoryScannerParametersWithoutSpecificT
excludes.add( "xx2" );

return new DirectoryScannerParameters( aDir, includes, excludes, Collections.<String>emptyList(), true,
RunOrder.asString( RunOrder.DEFAULT ) );
RunOrderLoader.asString( defaultRunOrder() ) );
}

private ProviderConfiguration saveAndReload( ProviderConfiguration booterConfiguration,
Expand Down Expand Up @@ -235,7 +252,7 @@ private ProviderConfiguration getTestProviderConfiguration( DirectoryScannerPara
new TestRequest( getSuiteXmlFileStrings(), getTestSourceDirectory(),
new TestListResolver( aUserRequestedTest + "#aUserRequestedTestMethod" ),
rerunFailingTestsCount );
RunOrderParameters runOrderParameters = new RunOrderParameters( RunOrder.DEFAULT, null );
RunOrderParameters runOrderParameters = new RunOrderParameters( defaultRunOrder(), null );
return new ProviderConfiguration( directoryScannerParameters, runOrderParameters, true, reporterConfiguration,
new TestArtifactInfo( "5.0", "ABC" ), testSuiteDefinition, new HashMap<String, String>(), aTestTyped,
readTestsFromInStream, cli, 0, Shutdown.DEFAULT, 0 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,31 @@
* under the License.
*/

import junit.framework.TestCase;
import org.apache.maven.surefire.booter.*;
import org.apache.maven.surefire.cli.CommandLineOption;
import org.apache.maven.surefire.report.ReporterConfiguration;
import org.apache.maven.surefire.testset.*;
import org.apache.maven.surefire.util.RunOrder;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import junit.framework.TestCase;
import org.apache.maven.surefire.booter.BooterDeserializer;
import org.apache.maven.surefire.booter.ClassLoaderConfiguration;
import org.apache.maven.surefire.booter.Classpath;
import org.apache.maven.surefire.booter.ClasspathConfiguration;
import org.apache.maven.surefire.booter.PropertiesWrapper;
import org.apache.maven.surefire.booter.ProviderConfiguration;
import org.apache.maven.surefire.booter.Shutdown;
import org.apache.maven.surefire.booter.StartupConfiguration;
import org.apache.maven.surefire.cli.CommandLineOption;
import org.apache.maven.surefire.report.ReporterConfiguration;
import org.apache.maven.surefire.testset.DirectoryScannerParameters;
import org.apache.maven.surefire.testset.RunOrderParameters;
import org.apache.maven.surefire.testset.TestArtifactInfo;
import org.apache.maven.surefire.testset.TestListResolver;
import org.apache.maven.surefire.testset.TestRequest;

import static org.apache.maven.plugin.surefire.runorder.impl.RunOrderLoader.defaultRunOrder;
import static org.apache.maven.surefire.cli.CommandLineOption.LOGGING_LEVEL_DEBUG;
import static org.apache.maven.surefire.cli.CommandLineOption.REACTOR_FAIL_FAST;
import static org.apache.maven.surefire.cli.CommandLineOption.SHOW_ERRORS;
Expand Down Expand Up @@ -142,7 +152,7 @@ private ProviderConfiguration getProviderConfiguration()
new TestRequest( Arrays.asList( getSuiteXmlFileStrings() ), getTestSourceDirectory(),
new TestListResolver( "aUserRequestedTest#aUserRequestedTestMethod" ));

RunOrderParameters runOrderParameters = new RunOrderParameters( RunOrder.DEFAULT, null );
RunOrderParameters runOrderParameters = new RunOrderParameters( defaultRunOrder(), null );
return new ProviderConfiguration( directoryScannerParameters, runOrderParameters, true, reporterConfiguration,
new TestArtifactInfo( "5.0", "ABC" ), testSuiteDefinition, new HashMap<String, String>(),
BooterDeserializerProviderConfigurationTest.aTestTyped, true, cli, 0, Shutdown.DEFAULT, 0 );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.apache.maven.plugin.surefire.runorder;
package org.apache.maven.plugin.surefire.runorder.impl.statistics;

/*
* Licensed to the Apache Software Foundation (ASF) under one
Expand All @@ -24,6 +24,7 @@
import java.io.StringReader;
import java.util.Arrays;
import java.util.List;

import org.apache.maven.surefire.report.ReportEntry;
import org.apache.maven.surefire.report.SimpleReportEntry;

Expand Down Expand Up @@ -62,9 +63,9 @@ public void testPrioritizedFailureFirst()

private StringReader getStatisticsFile()
{
String content = "0,17,testA(org.apache.maven.plugin.surefire.runorder.RunEntryStatisticsMapTest$A)\n" +
"2,42,testB(org.apache.maven.plugin.surefire.runorder.RunEntryStatisticsMapTest$B)\n" +
"1,100,testC(org.apache.maven.plugin.surefire.runorder.RunEntryStatisticsMapTest$C)\n";
String content = "0,17,testA(org.apache.maven.plugin.surefire.runorder.impl.statistics.RunEntryStatisticsMapTest$A)\n" +
"2,42,testB(org.apache.maven.plugin.surefire.runorder.impl.statistics.RunEntryStatisticsMapTest$B)\n" +
"1,100,testC(org.apache.maven.plugin.surefire.runorder.impl.statistics.RunEntryStatisticsMapTest$C)\n";
return new StringReader( content );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.apache.maven.plugin.surefire.report.DefaultReporterFactoryTest;
import org.apache.maven.plugin.surefire.report.StatelessXmlReporterTest;
import org.apache.maven.plugin.surefire.report.WrappedReportEntryTest;
import org.apache.maven.plugin.surefire.runorder.RunEntryStatisticsMapTest;
import org.apache.maven.plugin.surefire.runorder.impl.statistics.RunEntryStatisticsMapTest;
import org.apache.maven.plugin.surefire.util.DependenciesScannerTest;
import org.apache.maven.plugin.surefire.util.DirectoryScannerTest;
import org.apache.maven.plugin.surefire.util.SpecificFileFilterTest;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package org.apache.maven.plugin.surefire.runorder;

/*
* 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.plugin.surefire.runorder.api.RunOrder;

/**
* @author Dipak Pawar
*/
public class StringUtil
{

public static String joins( RunOrder[] runOrders )
{
StringJoiner stringJoiner = new StringJoiner( "," );

for ( RunOrder runOrder : runOrders )
{
final String runOrderName = runOrder.getName();

if ( runOrderName != null )
{
stringJoiner.add( runOrderName );
}
}

return stringJoiner.toString();
}

static class StringJoiner
{
private final String delimiter;
private StringBuilder value;

StringJoiner( CharSequence delimiter )
{
this.delimiter = delimiter.toString();
}

public String toString()
{
if ( this.value == null )
{
return "";
}
else
{
int initialLength = this.value.length();
String result = this.value.toString();
this.value.setLength( initialLength );
return result;
}
}

public StringJoiner add( CharSequence newElement )
{
this.prepareBuilder().append( newElement );
return this;
}

private StringBuilder prepareBuilder()
{
if ( this.value != null )
{
this.value.append( this.delimiter );
}
else
{
this.value = new StringBuilder();
}

return this.value;
}
}

}
Loading