tycho/tycho-maven-surefire.patch

449 lines
23 KiB
Diff
Raw Normal View History

2014-07-25 15:45:40 +00:00
From 2100439cf0625cb1e4b480de2d90d7105443a6ef Mon Sep 17 00:00:00 2001
2012-09-24 21:06:48 +00:00
From: Jan Sievers <jan.sievers@sap.com>
Date: Tue, 4 Sep 2012 16:02:52 +0200
2014-03-25 13:46:29 +00:00
Subject: [PATCH] POC 386481 update maven surefire to latest version 2.17
2012-06-12 15:06:31 +00:00
2012-09-24 21:06:48 +00:00
while SUREFIRE-825 and SUREFIRE-876 are fixed,
there are several new problems:
1. The junit47 provider is broken again (probably
due to junit bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=318299
2. the internal structure of surefire chnaged significantly
(new jars need to be pulled into OSGi, the Surefire
booter/starter API changed, directory scanning must now
be done in the TestMojo already
3. The most sever issue here is that we don't have the dependencies
of surefire under control and what used to be more or less self-contained
(surefire-api and surefire-booter) now drags in lots of dependencies
which we don't really want to wrap in OSGi. I only added those actually
needed by what we are using, the correct list of dependent jars would
be much longer.
Change-Id: Ibcb439a24add880c4cdafe67b42e29ca3cb14ff1
2012-06-12 15:06:31 +00:00
---
2013-10-24 18:52:56 +00:00
.../META-INF/MANIFEST.MF | 2 +-
.../build.properties | 2 +-
.../META-INF/MANIFEST.MF | 2 +-
.../build.properties | 2 +-
.../META-INF/MANIFEST.MF | 7 +++--
2014-03-25 13:46:29 +00:00
.../build.properties | 2 +-
2013-10-24 18:52:56 +00:00
.../org.eclipse.tycho.surefire.junit47/pom.xml | 10 ++++++
2014-03-25 13:46:29 +00:00
.../junitcore/OsgiEnabledJUnitCoreProvider.java | 4 +--
2013-10-24 18:52:56 +00:00
.../META-INF/MANIFEST.MF | 6 ++--
.../org.eclipse.tycho.surefire.osgibooter/pom.xml | 10 ++++++
.../surefire/osgibooter/OsgiSurefireBooter.java | 36 ++++++++++++++--------
.../osgibooter/TychoClasspathConfiguration.java | 35 +++++++++++++++------
tycho-surefire/pom.xml | 2 +-
tycho-surefire/tycho-surefire-plugin/pom.xml | 5 +++
.../java/org/eclipse/tycho/surefire/TestMojo.java | 29 +++++++++++++++--
.../surefire/provider/impl/JUnit47Provider.java | 2 +-
2014-03-25 13:46:29 +00:00
16 files changed, 118 insertions(+), 38 deletions(-)
2012-06-12 15:06:31 +00:00
2012-09-24 21:06:48 +00:00
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit/META-INF/MANIFEST.MF b/tycho-surefire/org.eclipse.tycho.surefire.junit/META-INF/MANIFEST.MF
2014-07-25 15:45:40 +00:00
index a2522b5..0063b71 100644
2012-09-24 21:06:48 +00:00
--- a/tycho-surefire/org.eclipse.tycho.surefire.junit/META-INF/MANIFEST.MF
+++ b/tycho-surefire/org.eclipse.tycho.surefire.junit/META-INF/MANIFEST.MF
@@ -7,5 +7,5 @@ Fragment-Host: org.eclipse.tycho.surefire.osgibooter;bundle-version="0.14.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5,
JavaSE-1.6
Require-Bundle: org.junit;bundle-version="[3.8.0,4.0.0)"
-Bundle-ClassPath: jars/surefire-junit3-2.10.jar
2013-07-09 14:36:03 +00:00
+Bundle-ClassPath: jars/surefire-junit3-2.15.jar
2012-09-24 21:06:48 +00:00
Bundle-Vendor: %providerName
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit/build.properties b/tycho-surefire/org.eclipse.tycho.surefire.junit/build.properties
index 499ce76..fe88b19 100644
--- a/tycho-surefire/org.eclipse.tycho.surefire.junit/build.properties
+++ b/tycho-surefire/org.eclipse.tycho.surefire.junit/build.properties
@@ -9,5 +9,5 @@
# Sonatype Inc. - initial API and implementation
###############################################################################
bin.includes = META-INF/,\
- jars/surefire-junit3-2.10.jar,\
+ jars/,\
plugin.properties
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit4/META-INF/MANIFEST.MF b/tycho-surefire/org.eclipse.tycho.surefire.junit4/META-INF/MANIFEST.MF
2014-07-25 15:45:40 +00:00
index 8597932..861e0d7 100644
2012-09-24 21:06:48 +00:00
--- a/tycho-surefire/org.eclipse.tycho.surefire.junit4/META-INF/MANIFEST.MF
+++ b/tycho-surefire/org.eclipse.tycho.surefire.junit4/META-INF/MANIFEST.MF
2014-07-25 15:45:40 +00:00
@@ -6,7 +6,7 @@ Bundle-Version: 0.21.0
2012-09-24 21:06:48 +00:00
Fragment-Host: org.eclipse.tycho.surefire.osgibooter;bundle-version="0.14.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5,
JavaSE-1.6
-Bundle-ClassPath: jars/surefire-junit4-2.10.jar
2013-07-09 14:36:03 +00:00
+Bundle-ClassPath: jars/surefire-junit4-2.15.jar
2012-09-24 21:06:48 +00:00
Import-Package: junit.framework;version="3.0.0",
org.junit;version="4.0.0",
org.junit.runner;version="4.0.0",
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit4/build.properties b/tycho-surefire/org.eclipse.tycho.surefire.junit4/build.properties
index b787149..fe88b19 100644
--- a/tycho-surefire/org.eclipse.tycho.surefire.junit4/build.properties
+++ b/tycho-surefire/org.eclipse.tycho.surefire.junit4/build.properties
@@ -9,5 +9,5 @@
# Sonatype Inc. - initial API and implementation
###############################################################################
bin.includes = META-INF/,\
- jars/surefire-junit4-2.10.jar,\
+ jars/,\
plugin.properties
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit47/META-INF/MANIFEST.MF b/tycho-surefire/org.eclipse.tycho.surefire.junit47/META-INF/MANIFEST.MF
2014-07-25 15:45:40 +00:00
index a26db94..6e0cebb 100644
2012-09-24 21:06:48 +00:00
--- a/tycho-surefire/org.eclipse.tycho.surefire.junit47/META-INF/MANIFEST.MF
+++ b/tycho-surefire/org.eclipse.tycho.surefire.junit47/META-INF/MANIFEST.MF
2014-07-25 15:45:40 +00:00
@@ -6,11 +6,14 @@ Bundle-Version: 0.21.0
2012-09-24 21:06:48 +00:00
Fragment-Host: org.eclipse.tycho.surefire.osgibooter;bundle-version="0.16.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ClassPath: .,
- jars/surefire-junit47-2.10.jar
2013-07-09 14:36:03 +00:00
+ jars/surefire-junit47-2.15.jar,
+ jars/common-junit48-2.15.jar,
+ jars/surefire-grouper-2.15.jar
2012-09-24 21:06:48 +00:00
Import-Package: junit.framework;version="3.0.0",
org.junit;version="[4.7,5)",
org.junit.runner;version="[4.7,5)",
org.junit.runner.notification;version="[4.7,5)",
org.junit.runners;version="[4.7,5)",
- org.junit.runners.model;version="[4.7,5)"
+ org.junit.runners.model;version="[4.7,5)",
+ org.junit.runner.manipulation;version="[4.7,5)"
Bundle-Vendor: %providerName
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit47/build.properties b/tycho-surefire/org.eclipse.tycho.surefire.junit47/build.properties
2014-03-25 13:46:29 +00:00
index 61905c2..41bdc39 100644
2012-09-24 21:06:48 +00:00
--- a/tycho-surefire/org.eclipse.tycho.surefire.junit47/build.properties
+++ b/tycho-surefire/org.eclipse.tycho.surefire.junit47/build.properties
2014-03-25 13:46:29 +00:00
@@ -10,7 +10,7 @@
2012-09-24 21:06:48 +00:00
###############################################################################
bin.includes = .,\
META-INF/,\
- jars/surefire-junit47-2.10.jar,\
+ jars/,\
plugin.properties,\
about.html,\
about_files/
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit47/pom.xml b/tycho-surefire/org.eclipse.tycho.surefire.junit47/pom.xml
2014-07-25 15:45:40 +00:00
index 9e0bfb6..e217cdf 100644
2012-09-24 21:06:48 +00:00
--- a/tycho-surefire/org.eclipse.tycho.surefire.junit47/pom.xml
+++ b/tycho-surefire/org.eclipse.tycho.surefire.junit47/pom.xml
@@ -44,6 +44,16 @@
<artifactId>surefire-junit47</artifactId>
<version>${surefire-version}</version>
</artifactItem>
+ <artifactItem>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>common-junit48</artifactId>
+ <version>${surefire-version}</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-grouper</artifactId>
+ <version>${surefire-version}</version>
+ </artifactItem>
</artifactItems>
</configuration>
</execution>
2014-03-25 13:46:29 +00:00
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.junit47/src/main/java/org/apache/maven/surefire/junitcore/OsgiEnabledJUnitCoreProvider.java b/tycho-surefire/org.eclipse.tycho.surefire.junit47/src/main/java/org/apache/maven/surefire/junitcore/OsgiEnabledJUnitCoreProvider.java
index eaa8dc4..3b8ca14 100644
--- a/tycho-surefire/org.eclipse.tycho.surefire.junit47/src/main/java/org/apache/maven/surefire/junitcore/OsgiEnabledJUnitCoreProvider.java
+++ b/tycho-surefire/org.eclipse.tycho.surefire.junit47/src/main/java/org/apache/maven/surefire/junitcore/OsgiEnabledJUnitCoreProvider.java
@@ -105,7 +105,7 @@ public class OsgiEnabledJUnitCoreProvider
}
final Map<String, TestSet> testSetMap = new ConcurrentHashMap<String, TestSet>();
- RunListener listener = ConcurrentReporterManager.createInstance( testSetMap, reporterFactory,
+ RunListener listener = ConcurrentRunListener.createInstance( testSetMap, reporterFactory,
jUnitCoreParameters.isParallelClasses(),
jUnitCoreParameters.isParallelBoth(),
consoleLogger );
@@ -115,7 +115,7 @@ public class OsgiEnabledJUnitCoreProvider
org.junit.runner.notification.RunListener jUnit4RunListener = new OsgiEnabledJUnitCoreRunListener( listener, testSetMap );
customRunListeners.add( 0, jUnit4RunListener );
- JUnitCoreWrapper.execute( testsToRun, jUnitCoreParameters, customRunListeners );
+ JUnitCoreWrapper.execute( testsToRun, jUnitCoreParameters, customRunListeners, org.junit.runner.manipulation.Filter.ALL );
return reporterFactory.close();
}
2012-06-12 15:06:31 +00:00
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/META-INF/MANIFEST.MF b/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/META-INF/MANIFEST.MF
2014-07-25 15:45:40 +00:00
index fb1165d..6d4b688 100644
2012-06-12 15:06:31 +00:00
--- a/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/META-INF/MANIFEST.MF
+++ b/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/META-INF/MANIFEST.MF
2012-09-24 21:06:48 +00:00
@@ -4,8 +4,10 @@ Require-Bundle: org.eclipse.osgi;bundle-version="3.2.2",
org.eclipse.core.runtime;bundle-version="3.2.0"
Eclipse-AutoStart: true
Bundle-ClassPath: .,
2012-09-24 21:06:48 +00:00
- jars/surefire-booter-2.10.jar,
- jars/surefire-api-2.10.jar
2013-07-09 14:36:03 +00:00
+ jars/surefire-booter-2.15.jar,
+ jars/surefire-api-2.15.jar,
+ jars/maven-surefire-common-2.15.jar,
2012-09-24 21:06:48 +00:00
+ jars/plexus-utils-3.0.jar
2014-07-25 15:45:40 +00:00
Bundle-Version: 0.21.0
Bundle-Name: Tycho Surefire OSGi Booter Eclipse Application (Incubation)
Bundle-ManifestVersion: 2
2012-06-12 15:06:31 +00:00
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/pom.xml b/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/pom.xml
2014-07-25 15:45:40 +00:00
index 36b75b6..27aa6f6 100644
2012-06-12 15:06:31 +00:00
--- a/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/pom.xml
+++ b/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/pom.xml
2012-09-24 21:06:48 +00:00
@@ -52,6 +52,16 @@
<artifactId>surefire-booter</artifactId>
<version>${surefire-version}</version>
</artifactItem>
2012-06-12 15:06:31 +00:00
+ <artifactItem>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>maven-surefire-common</artifactId>
+ <version>${surefire-version}</version>
2012-09-24 21:06:48 +00:00
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>3.0</version>
+ </artifactItem>
2012-06-12 15:06:31 +00:00
</artifactItems>
</configuration>
2012-09-24 21:06:48 +00:00
</execution>
2012-06-12 15:06:31 +00:00
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/OsgiSurefireBooter.java b/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/OsgiSurefireBooter.java
2014-07-25 15:45:40 +00:00
index c1de8ec..b81b853 100644
2012-06-12 15:06:31 +00:00
--- a/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/OsgiSurefireBooter.java
+++ b/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/OsgiSurefireBooter.java
2014-07-25 15:45:40 +00:00
@@ -19,20 +19,25 @@ import java.io.IOException;
2012-09-24 21:06:48 +00:00
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
+import org.apache.maven.plugin.surefire.StartupReportConfiguration;
+import org.apache.maven.plugin.surefire.report.DefaultReporterFactory;
import org.apache.maven.surefire.booter.ClassLoaderConfiguration;
2012-09-24 21:06:48 +00:00
+import org.apache.maven.surefire.booter.ForkedBooter;
import org.apache.maven.surefire.booter.ProviderConfiguration;
2012-09-24 21:06:48 +00:00
+import org.apache.maven.surefire.booter.ProviderFactory;
import org.apache.maven.surefire.booter.StartupConfiguration;
-import org.apache.maven.surefire.booter.StartupReportConfiguration;
-import org.apache.maven.surefire.booter.SurefireStarter;
import org.apache.maven.surefire.report.ReporterConfiguration;
2012-09-24 21:06:48 +00:00
+import org.apache.maven.surefire.report.ReporterFactory;
import org.apache.maven.surefire.suite.RunResult;
import org.apache.maven.surefire.testset.DirectoryScannerParameters;
2012-09-24 21:06:48 +00:00
+import org.apache.maven.surefire.testset.RunOrderParameters;
import org.apache.maven.surefire.testset.TestRequest;
import org.apache.maven.surefire.util.RunOrder;
import org.eclipse.core.runtime.CoreException;
2014-07-25 15:45:40 +00:00
@@ -57,7 +62,7 @@ public class OsgiSurefireBooter {
2012-09-24 21:06:48 +00:00
List<String> includes = getIncludesExcludes(testProps.getProperty("includes"));
List<String> excludes = getIncludesExcludes(testProps.getProperty("excludes"));
- String forkMode = "never";
+ boolean forkRequested = true;
boolean inForkedVM = true;
boolean trimStacktrace = true;
boolean useSystemClassloader = false;
2014-07-25 15:45:40 +00:00
@@ -66,26 +71,31 @@ public class OsgiSurefireBooter {
boolean printSummary = true;
boolean disableXmlReport = false;
ClassLoader testClassLoader = getBundleClassLoader(plugin);
- ClassLoader surefireClassLoader = SurefireStarter.class.getClassLoader();
2012-09-24 21:06:48 +00:00
+ ClassLoader surefireClassLoader = ForkedBooter.class.getClassLoader();
TychoClasspathConfiguration classPathConfig = new TychoClasspathConfiguration(testClassLoader,
surefireClassLoader);
StartupConfiguration startupConfiguration = new StartupConfiguration(provider, classPathConfig,
2012-09-24 21:06:48 +00:00
- new ClassLoaderConfiguration(useSystemClassloader, useManifestOnlyJar), forkMode, inForkedVM);
+ new ClassLoaderConfiguration(useSystemClassloader, useManifestOnlyJar), forkRequested, inForkedVM);
DirectoryScannerParameters dirScannerParams = new DirectoryScannerParameters(testClassesDir, includes,
2013-10-24 18:52:56 +00:00
- excludes, failIfNoTests, RunOrder.valueOf(runOrder));
+ excludes, Collections.emptyList(), failIfNoTests, RunOrder.valueOf(runOrder).toString());
ReporterConfiguration reporterConfig = new ReporterConfiguration(reportsDir, trimStacktrace);
TestRequest testRequest = new TestRequest(null, testClassesDir, null);
- ProviderConfiguration providerConfiguration = new ProviderConfiguration(dirScannerParams, failIfNoTests,
2012-09-24 21:06:48 +00:00
- reporterConfig, null, testRequest, extractProviderProperties(testProps), null);
+ ProviderConfiguration providerConfiguration = new ProviderConfiguration(dirScannerParams,
2013-07-09 14:36:03 +00:00
+ new RunOrderParameters((String) null, null), failIfNoTests, reporterConfig, null, testRequest,
+ extractProviderProperties(testProps), null, false);
StartupReportConfiguration startupReportConfig = new StartupReportConfiguration(useFile, printSummary,
StartupReportConfiguration.PLAIN_REPORT_FORMAT, redirectTestOutputToFile, disableXmlReport, reportsDir,
- trimStacktrace);
- SurefireStarter surefireStarter = new SurefireStarter(startupConfiguration, providerConfiguration,
2012-09-24 21:06:48 +00:00
- startupReportConfig);
+ trimStacktrace, null, "TESTHASH", false);
2012-09-24 21:06:48 +00:00
- RunResult result = surefireStarter.runSuitesInProcess();
- return result.getForkedProcessCode();
2013-07-09 14:36:03 +00:00
+ RunResult result = ProviderFactory.invokeProvider(null, classPathConfig.createMergedClassLoader(),
+ createReporterFactory(startupReportConfig), providerConfiguration, false, startupConfiguration, true);
+
+ return result.getFailsafeCode() == null ? 0 : result.getFailsafeCode();
+ }
+
+ private static ReporterFactory createReporterFactory(StartupReportConfiguration startupReportConfig) {
+ return new DefaultReporterFactory(startupReportConfig);
}
2012-09-24 21:06:48 +00:00
/*
2013-07-09 14:36:03 +00:00
diff --git a/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/TychoClasspathConfiguration.java b/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/TychoClasspathConfiguration.java
index c94d3ea..fc606b0 100644
--- a/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/TychoClasspathConfiguration.java
+++ b/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/src/main/java/org/eclipse/tycho/surefire/osgibooter/TychoClasspathConfiguration.java
@@ -25,18 +25,35 @@ public class TychoClasspathConfiguration extends ClasspathConfiguration {
}
@Override
- public ClassLoader createSurefireClassLoader(ClassLoader parent) throws SurefireExecutionException {
- return surefireClassLoader;
+ public ClassLoader createMergedClassLoader() throws SurefireExecutionException {
+ return new MergedClassLoader(null, new ClassLoader[] { testClassLoader, surefireClassLoader });
}
- @Override
- public ClassLoader createTestClassLoader() throws SurefireExecutionException {
- return testClassLoader;
- }
+ private class MergedClassLoader extends ClassLoader {
+
+ private ClassLoader[] delegateClassLoaders;
+
+ public MergedClassLoader(ClassLoader parent, ClassLoader[] delegateClassLoaders) {
+ super(parent);
+ this.delegateClassLoaders = delegateClassLoaders;
+ }
+
+ @Override
+ public Class<?> loadClass(String name) throws ClassNotFoundException {
+ return findClass(name);
+ }
+
+ @Override
+ protected Class<?> findClass(String name) throws ClassNotFoundException {
+ for (ClassLoader delegate : delegateClassLoaders) {
+ try {
+ return delegate.loadClass(name);
+ } catch (ClassNotFoundException e) {
+ }
+ }
+ throw new ClassNotFoundException();
+ }
- @Override
- public ClassLoader createTestClassLoader(boolean childDelegation) throws SurefireExecutionException {
- return testClassLoader;
}
}
2012-09-24 21:06:48 +00:00
diff --git a/tycho-surefire/pom.xml b/tycho-surefire/pom.xml
2014-07-25 15:45:40 +00:00
index 476ffd9..6e16c20 100644
2012-09-24 21:06:48 +00:00
--- a/tycho-surefire/pom.xml
+++ b/tycho-surefire/pom.xml
@@ -26,7 +26,7 @@
<name>Tycho Surefire Parent (Incubation)</name>
<properties>
- <surefire-version>2.10</surefire-version>
2013-07-09 14:36:03 +00:00
+ <surefire-version>2.15</surefire-version>
2012-09-24 21:06:48 +00:00
</properties>
<modules>
diff --git a/tycho-surefire/tycho-surefire-plugin/pom.xml b/tycho-surefire/tycho-surefire-plugin/pom.xml
2014-07-25 15:45:40 +00:00
index 0106500..c7a601a 100644
2012-09-24 21:06:48 +00:00
--- a/tycho-surefire/tycho-surefire-plugin/pom.xml
+++ b/tycho-surefire/tycho-surefire-plugin/pom.xml
2014-07-25 15:45:40 +00:00
@@ -106,5 +106,10 @@
2013-10-24 18:52:56 +00:00
<artifactId>tycho-p2-facade</artifactId>
<version>${project.version}</version>
2012-09-24 21:06:48 +00:00
</dependency>
+ <dependency>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>maven-surefire-common</artifactId>
+ <version>${surefire-version}</version>
+ </dependency>
</dependencies>
</project>
2012-06-12 15:06:31 +00:00
diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/TestMojo.java b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/TestMojo.java
2014-07-25 15:45:40 +00:00
index 2305a2a..bd0cf5c 100644
2012-06-12 15:06:31 +00:00
--- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/TestMojo.java
+++ b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/TestMojo.java
2014-07-25 15:45:40 +00:00
@@ -19,6 +19,7 @@ import java.io.IOException;
import java.net.MalformedURLException;
2012-09-24 21:06:48 +00:00
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
2014-07-25 15:45:40 +00:00
import java.util.LinkedHashMap;
2012-09-24 21:06:48 +00:00
import java.util.List;
import java.util.Map;
2014-07-25 15:45:40 +00:00
@@ -40,9 +41,10 @@ import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
2012-09-24 21:06:48 +00:00
+import org.apache.maven.plugin.surefire.util.DirectoryScanner;
import org.apache.maven.project.MavenProject;
import org.apache.maven.repository.RepositorySystem;
-import org.apache.maven.surefire.suite.RunResult;
+import org.apache.maven.surefire.util.DefaultScanResult;
import org.apache.maven.toolchain.Toolchain;
import org.apache.maven.toolchain.ToolchainManager;
import org.codehaus.plexus.util.FileUtils;
2014-07-25 15:45:40 +00:00
@@ -858,6 +860,27 @@ public class TestMojo extends AbstractMojo {
2013-10-24 18:52:56 +00:00
result.put("perCoreThreadCount", String.valueOf(perCoreThreadCount));
result.put("useUnlimitedThreads", String.valueOf(useUnlimitedThreads));
2012-09-24 21:06:48 +00:00
}
+
+ List<String> defaultIncludes = Arrays.asList("**/Test*.class", "**/*Test.class", "**/*TestCase.class");
+ List<String> defaultExcludes = Arrays.asList("**/Abstract*Test.class", "**/Abstract*TestCase.class", "**/*$*");
+ List<String> includeList;
+ if (test != null) {
+ String test = this.test;
+ test = test.replace('.', '/');
+ test = test.endsWith(".class") ? test : test + ".class";
+ test = test.startsWith("**/") ? test : "**/" + test;
+ includeList = Collections.singletonList(test);
+ } else if (testClass != null) {
+ includeList = Collections.singletonList(testClass.replace('.', '/') + ".class");
+ } else if (includes != null) {
+ includeList = includes;
+ } else {
+ includeList = defaultIncludes;
+ }
+ DirectoryScanner scanner = new DirectoryScanner(testClassesDirectory, includeList, excludes != null ? excludes
+ : defaultExcludes, Collections.<String> emptyList());
+ DefaultScanResult scanResult = scanner.scan();
2013-10-24 18:52:56 +00:00
+ scanResult.writeTo(result);
return result;
}
2014-07-25 15:45:40 +00:00
@@ -902,7 +925,7 @@ public class TestMojo extends AbstractMojo {
2012-06-12 15:06:31 +00:00
case 0:
getLog().info("All tests passed!");
break;
- case RunResult.NO_TESTS:
2012-09-24 21:06:48 +00:00
+ case 254/* RunResult.NO_TESTS */:
2012-06-12 15:06:31 +00:00
String message = "No tests found.";
if (failIfNoTests) {
throw new MojoFailureException(message);
2014-07-25 15:45:40 +00:00
@@ -910,7 +933,7 @@ public class TestMojo extends AbstractMojo {
2012-06-12 15:06:31 +00:00
getLog().warn(message);
}
break;
- case RunResult.FAILURE:
2012-09-24 21:06:48 +00:00
+ case 255/* RunResult.FAILURE */:
2012-06-12 15:06:31 +00:00
String errorMessage = "There are test failures.\n\nPlease refer to " + reportsDirectory
+ " for the individual test results.";
if (testFailureIgnore) {
2012-09-24 21:06:48 +00:00
diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit47Provider.java b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit47Provider.java
2013-10-24 18:52:56 +00:00
index edcc46a..5d62d3d 100644
2012-09-24 21:06:48 +00:00
--- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit47Provider.java
+++ b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit47Provider.java
@@ -44,7 +44,7 @@ public class JUnit47Provider extends AbstractJUnitProvider {
}
public String getSurefireProviderClassName() {
- return "org.apache.maven.surefire.junitcore.OsgiEnabledJUnitCoreProvider";
+ return "org.apache.maven.surefire.junitcore.JUnitCoreProvider";
}
public Version getVersion() {
2012-06-12 15:06:31 +00:00
--
2014-07-25 15:45:40 +00:00
1.9.3
2012-06-12 15:06:31 +00:00