From 038d1819e9b9880783ce187023e1404f5ea12db7 Mon Sep 17 00:00:00 2001 From: Roland Grunberg Date: Tue, 12 Jun 2012 10:12:53 -0400 Subject: [PATCH 3/4] Upstream builds against maven-surefire 2.10 but in rawhide we have 2.12. Change-Id: I69ceee1cb2abe86bc6ca080ddde6676bf995347a --- .../META-INF/MANIFEST.MF | 3 ++- .../org.eclipse.tycho.surefire.osgibooter/pom.xml | 7 +++++++ .../surefire/osgibooter/OsgiSurefireBooter.java | 15 ++++++++------- .../osgibooter/TychoClasspathConfiguration.java | 5 +++++ .../java/org/eclipse/tycho/surefire/TestMojo.java | 4 ++-- 5 files changed, 24 insertions(+), 10 deletions(-) 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 index c2c4c8c..9fa7626 100644 --- a/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/META-INF/MANIFEST.MF +++ b/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/META-INF/MANIFEST.MF @@ -6,7 +6,8 @@ Eclipse-AutoStart: true Bundle-ClassPath: ., jars/surefire-booter-2.10.jar, jars/surefire-api-2.10.jar, - jars/plexus-utils-3.0.jar + jars/plexus-utils-3.0.jar, + jars/maven-surefire-common-2.10.jar Bundle-Version: 0.15.0 Bundle-Name: Tycho Surefire OSGi Booter Eclipse Application (Incubation) Bundle-ManifestVersion: 2 diff --git a/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/pom.xml b/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/pom.xml index 7a13f1d..275c95e 100644 --- a/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/pom.xml +++ b/tycho-surefire/org.eclipse.tycho.surefire.osgibooter/pom.xml @@ -56,6 +56,13 @@ org.codehaus.plexus plexus-utils ${plexusUtilsVersion} + + + + org.apache.maven.surefire + maven-surefire-common + ${surefire-version} + 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 index 8d46bdb..162a706 100644 --- 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 @@ -26,13 +26,14 @@ import java.util.Set; import org.apache.maven.surefire.booter.ClassLoaderConfiguration; import org.apache.maven.surefire.booter.ProviderConfiguration; 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.plugin.surefire.StartupReportConfiguration; +import org.apache.maven.plugin.surefire.InPluginVMSurefireStarter; import org.apache.maven.surefire.report.ReporterConfiguration; import org.apache.maven.surefire.suite.RunResult; import org.apache.maven.surefire.testset.DirectoryScannerParameters; import org.apache.maven.surefire.testset.TestRequest; import org.apache.maven.surefire.util.RunOrder; +import org.apache.maven.surefire.testset.RunOrderParameters; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -63,22 +64,22 @@ public class OsgiSurefireBooter { boolean printSummary = true; boolean disableXmlReport = false; ClassLoader testClassLoader = getBundleClassLoader(plugin); - ClassLoader surefireClassLoader = SurefireStarter.class.getClassLoader(); + ClassLoader surefireClassLoader = InPluginVMSurefireStarter.class.getClassLoader(); TychoClasspathConfiguration classPathConfig = new TychoClasspathConfiguration(testClassLoader, surefireClassLoader); StartupConfiguration startupConfiguration = new StartupConfiguration(provider, classPathConfig, new ClassLoaderConfiguration(useSystemClassloader, useManifestOnlyJar), forkMode, inForkedVM); DirectoryScannerParameters dirScannerParams = new DirectoryScannerParameters(testClassesDir, includes, - excludes, failIfNoTests, RunOrder.FILESYSTEM); + excludes, null, failIfNoTests, RunOrder.FILESYSTEM.name()); ReporterConfiguration reporterConfig = new ReporterConfiguration(reportsDir, trimStacktrace); TestRequest testRequest = new TestRequest(null, testClassesDir, null); - ProviderConfiguration providerConfiguration = new ProviderConfiguration(dirScannerParams, failIfNoTests, + ProviderConfiguration providerConfiguration = new ProviderConfiguration(dirScannerParams, RunOrderParameters.DEFAULT(), failIfNoTests, reporterConfig, null, testRequest, new Properties(), null); StartupReportConfiguration startupReportConfig = new StartupReportConfiguration(useFile, printSummary, StartupReportConfiguration.PLAIN_REPORT_FORMAT, redirectTestOutputToFile, disableXmlReport, reportsDir, - trimStacktrace); - SurefireStarter surefireStarter = new SurefireStarter(startupConfiguration, providerConfiguration, + trimStacktrace, null, "TESTHASH", false); + InPluginVMSurefireStarter surefireStarter = new InPluginVMSurefireStarter(startupConfiguration, providerConfiguration, startupReportConfig); RunResult result = surefireStarter.runSuitesInProcess(); 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..6c732a5 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 @@ -30,6 +30,11 @@ public class TychoClasspathConfiguration extends ClasspathConfiguration { } @Override + public ClassLoader createInprocSurefireClassLoader(ClassLoader parent) throws SurefireExecutionException { + return surefireClassLoader; + } + + @Override public ClassLoader createTestClassLoader() throws SurefireExecutionException { return testClassLoader; } 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 index a8857f1..83f0e0f 100644 --- 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 @@ -589,7 +589,7 @@ public class TestMojo extends AbstractMojo { case 0: getLog().info("All tests passed!"); break; - case RunResult.NO_TESTS: + case 254: String message = "No tests found."; if (failIfNoTests) { throw new MojoFailureException(message); @@ -597,7 +597,7 @@ public class TestMojo extends AbstractMojo { getLog().warn(message); } break; - case RunResult.FAILURE: + case 255: String errorMessage = "There are test failures.\n\nPlease refer to " + reportsDirectory + " for the individual test results."; if (testFailureIgnore) { -- 1.7.7.6