You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2016/12/11 12:42:00 UTC
[1/4] maven-surefire git commit: [SUREFIRE] refactoring
Repository: maven-surefire
Updated Branches:
refs/heads/master d7bf6ce49 -> f841a16e4
[SUREFIRE] refactoring
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/68246e2f
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/68246e2f
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/68246e2f
Branch: refs/heads/master
Commit: 68246e2f93daeee0cbcbaf342fa4a4a485c72899
Parents: d7bf6ce
Author: Tibor17 <ti...@lycos.com>
Authored: Sun Dec 11 09:51:41 2016 +0100
Committer: Tibor17 <ti...@lycos.com>
Committed: Sun Dec 11 09:51:41 2016 +0100
----------------------------------------------------------------------
.../plugin/surefire/AbstractSurefireMojo.java | 8 ++++---
.../maven/surefire/util/UrlUtilsTest.java | 25 ++++----------------
2 files changed, 10 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/68246e2f/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
index 127ec82..3606be2 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
@@ -101,6 +101,8 @@ 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;
import static org.apache.maven.shared.utils.StringUtils.split;
+import static org.apache.maven.surefire.suite.RunResult.failure;
+import static org.apache.maven.surefire.suite.RunResult.noTestsRun;
/**
* Abstract base class for running tests using Surefire.
@@ -774,7 +776,7 @@ public abstract class AbstractSurefireMojo
throw new MojoFailureException(
"No tests were executed! (Set -DfailIfNoTests=false to ignore this error.)" );
}
- handleSummary( RunResult.noTestsRun(), null );
+ handleSummary( noTestsRun(), null );
return;
}
logReportsDirectory();
@@ -893,7 +895,7 @@ public abstract class AbstractSurefireMojo
{
List<ProviderInfo> providers = createProviders();
- RunResult current = RunResult.noTestsRun();
+ RunResult current = noTestsRun();
Exception firstForkException = null;
for ( ProviderInfo provider : providers )
@@ -927,7 +929,7 @@ public abstract class AbstractSurefireMojo
if ( firstForkException != null )
{
- current = RunResult.failure( current, firstForkException );
+ current = failure( current, firstForkException );
}
handleSummary( current, firstForkException );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/68246e2f/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java
index 3d9a07f..964fa10 100644
--- a/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java
+++ b/surefire-api/src/test/java/org/apache/maven/surefire/util/UrlUtilsTest.java
@@ -22,8 +22,7 @@ package org.apache.maven.surefire.util;
import junit.framework.TestCase;
import java.io.File;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
+import java.net.URI;
import java.net.URL;
import static org.apache.maven.surefire.util.internal.UrlUtils.toURL;
@@ -58,27 +57,13 @@ public class UrlUtilsTest
{
File f = new File( homeDir, fileName );
URL u = toURL( f );
+ URI uri = u.toURI();
+ File urlFile = new File( uri );
String url = u.toString();
+
assertStartsWith( url, "file:" );
assertEndsWith( url, expectedFileName );
-
- try
- {
- // use reflection to do "URI uri = u.toURI()" if JDK 1.5+
- Method toURI = URL.class.getMethod( "toURI", null );
- Object uri = toURI.invoke( u, null );
-
- // use reflection to do "File urlFile = new File( uri )" if JDK 1.4+
- Constructor newFile = File.class.getConstructor( new Class[]{ uri.getClass() } );
- File urlFile = (File) newFile.newInstance( uri );
-
- assertEquals( f, urlFile );
- }
- catch ( NoSuchMethodException e )
- {
- // URL.toURI() method in JDK 1.5+, not available currently
- // we won't be able to check for file equality...
- }
+ assertEquals( f, urlFile );
}
private void assertStartsWith( String string, String substring )
[4/4] maven-surefire git commit: [SUREFIRE-1313] Unify console report
result in SurefirePlugin and VerifyMojo
Posted by ti...@apache.org.
[SUREFIRE-1313] Unify console report result in SurefirePlugin and VerifyMojo
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/f841a16e
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/f841a16e
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/f841a16e
Branch: refs/heads/master
Commit: f841a16e4f85ffc28a39baa3f01454c08092f79d
Parents: 9478990
Author: Tibor17 <ti...@lycos.com>
Authored: Sun Dec 11 13:38:42 2016 +0100
Committer: Tibor17 <ti...@lycos.com>
Committed: Sun Dec 11 13:38:42 2016 +0100
----------------------------------------------------------------------
.../maven/plugin/failsafe/VerifyMojo.java | 2 +-
.../maven/plugin/surefire/SurefireHelper.java | 94 +++++++++++++-------
.../maven/plugin/surefire/SurefirePlugin.java | 13 +--
.../apache/maven/surefire/suite/RunResult.java | 3 +-
4 files changed, 65 insertions(+), 47 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/f841a16e/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
----------------------------------------------------------------------
diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
index 37199a3..5d0b035 100644
--- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
+++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
@@ -209,7 +209,7 @@ public class VerifyMojo
throw new MojoExecutionException( e.getMessage(), e );
}
- reportExecution( this, summary, getConsoleLogger() );
+ reportExecution( this, summary, getConsoleLogger(), null );
}
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/f841a16e/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
index 3f87c3c..e4b340a 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
@@ -26,6 +26,7 @@ import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.surefire.log.PluginConsoleLogger;
import org.apache.maven.surefire.cli.CommandLineOption;
import org.apache.maven.surefire.suite.RunResult;
+import org.apache.maven.surefire.testset.TestSetFailedException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -34,10 +35,10 @@ import java.util.Collection;
import java.util.List;
import static java.util.Collections.unmodifiableList;
+import static org.apache.maven.surefire.cli.CommandLineOption.LOGGING_LEVEL_DEBUG;
import static org.apache.maven.surefire.cli.CommandLineOption.LOGGING_LEVEL_ERROR;
-import static org.apache.maven.surefire.cli.CommandLineOption.LOGGING_LEVEL_WARN;
import static org.apache.maven.surefire.cli.CommandLineOption.LOGGING_LEVEL_INFO;
-import static org.apache.maven.surefire.cli.CommandLineOption.LOGGING_LEVEL_DEBUG;
+import static org.apache.maven.surefire.cli.CommandLineOption.LOGGING_LEVEL_WARN;
import static org.apache.maven.surefire.cli.CommandLineOption.SHOW_ERRORS;
/**
@@ -55,48 +56,26 @@ public final class SurefireHelper
}
public static void reportExecution( SurefireReportParameters reportParameters, RunResult result,
- PluginConsoleLogger log )
+ PluginConsoleLogger log, Exception firstForkException )
throws MojoFailureException, MojoExecutionException
{
- boolean timeoutOrOtherFailure = result.isFailureOrTimeout();
-
- if ( !timeoutOrOtherFailure )
+ if ( firstForkException == null && !result.isTimeout() && result.isErrorFree() )
{
- if ( result.getCompletedCount() == 0 )
+ if ( result.getCompletedCount() == 0 && failIfNoTests( reportParameters ) )
{
- if ( reportParameters.getFailIfNoTests() == null || !reportParameters.getFailIfNoTests() )
- {
- return;
- }
- throw new MojoFailureException(
- "No tests were executed! (Set -DfailIfNoTests=false to ignore this error.)" );
- }
-
- if ( result.isErrorFree() )
- {
- return;
+ throw new MojoFailureException( "No tests were executed! "
+ + "(Set -DfailIfNoTests=false to ignore this error.)" );
}
+ return;
}
- String msg = timeoutOrOtherFailure
- ? "There was a timeout or other error in the fork"
- : "There are test failures.\n\nPlease refer to " + reportParameters.getReportsDirectory()
- + " for the individual test results.";
-
if ( reportParameters.isTestFailureIgnore() )
{
- log.error( msg );
+ log.error( createErrorMessage( reportParameters, result, firstForkException ) );
}
else
{
- if ( result.isFailure() )
- {
- throw new MojoExecutionException( msg );
- }
- else
- {
- throw new MojoFailureException( msg );
- }
+ throwException( reportParameters, result, firstForkException );
}
}
@@ -181,4 +160,55 @@ public final class SurefireHelper
}
}
+ private static boolean failIfNoTests( SurefireReportParameters reportParameters )
+ {
+ return reportParameters.getFailIfNoTests() != null && reportParameters.getFailIfNoTests();
+ }
+
+ private static boolean isNotFatal( Exception firstForkException )
+ {
+ return firstForkException == null || firstForkException instanceof TestSetFailedException;
+ }
+
+ private static void throwException( SurefireReportParameters reportParameters, RunResult result,
+ Exception firstForkException )
+ throws MojoFailureException, MojoExecutionException
+ {
+ if ( isNotFatal( firstForkException ) )
+ {
+ throw new MojoFailureException( createErrorMessage( reportParameters, result, firstForkException ),
+ firstForkException );
+ }
+ else
+ {
+ throw new MojoExecutionException( createErrorMessage( reportParameters, result, firstForkException ),
+ firstForkException );
+ }
+ }
+
+ private static String createErrorMessage( SurefireReportParameters reportParameters, RunResult result,
+ Exception firstForkException )
+ {
+ StringBuilder msg = new StringBuilder( 128 );
+
+ if ( result.isTimeout() )
+ {
+ msg.append( "There was a timeout or other error in the fork" );
+ }
+ else
+ {
+ msg.append( "There are test failures.\n\nPlease refer to " )
+ .append( reportParameters.getReportsDirectory() )
+ .append( " for the individual test results." );
+ }
+
+ if ( firstForkException != null && firstForkException.getLocalizedMessage() != null )
+ {
+ msg.append( '\n' )
+ .append( firstForkException.getLocalizedMessage() );
+ }
+
+ return msg.toString();
+ }
+
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/f841a16e/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
----------------------------------------------------------------------
diff --git a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
index 97f1a79..943ed69 100644
--- a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
+++ b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
@@ -331,18 +331,7 @@ public class SurefirePlugin
protected void handleSummary( RunResult summary, Exception firstForkException )
throws MojoExecutionException, MojoFailureException
{
- assertNoException( firstForkException );
-
- reportExecution( this, summary, getConsoleLogger() );
- }
-
- private void assertNoException( Exception firstForkException )
- throws MojoFailureException
- {
- if ( firstForkException != null )
- {
- throw new MojoFailureException( firstForkException.getMessage(), firstForkException );
- }
+ reportExecution( this, summary, getConsoleLogger(), firstForkException );
}
protected boolean isSkipExecution()
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/f841a16e/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java b/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java
index 50102e0..a8466b2 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java
@@ -177,7 +177,7 @@ public class RunResult
/* Indicates test timeout or technical failure */
public boolean isFailureOrTimeout()
{
- return this.timeout || isFailure();
+ return isTimeout() || isFailure();
}
public boolean isFailure()
@@ -195,7 +195,6 @@ public class RunResult
return timeout;
}
-
public RunResult aggregate( RunResult other )
{
String failureMessage = getFailure() != null ? getFailure() : other.getFailure();
[3/4] maven-surefire git commit: [SUREFIRE-1312] Classpath containing
url special characters with Reflections not working
Posted by ti...@apache.org.
[SUREFIRE-1312] Classpath containing url special characters with Reflections not working
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/9478990e
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/9478990e
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/9478990e
Branch: refs/heads/master
Commit: 9478990e1e6f5ccb1c25cd3ba92e97a8b57c8228
Parents: fd293d8
Author: Tibor17 <ti...@lycos.com>
Authored: Sun Dec 11 13:32:27 2016 +0100
Committer: Tibor17 <ti...@lycos.com>
Committed: Sun Dec 11 13:32:27 2016 +0100
----------------------------------------------------------------------
.../plugin/surefire/booterclient/ForkConfiguration.java | 8 ++++----
.../java/org/apache/maven/surefire/booter/Classpath.java | 5 ++---
2 files changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/9478990e/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
index 6d43bd2..988af8f 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
@@ -39,8 +39,6 @@ import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
-import static org.apache.maven.surefire.util.internal.UrlUtils.toURL;
-
/**
* Configuration for forking tests.
*
@@ -287,8 +285,10 @@ public class ForkConfiguration
StringBuilder cp = new StringBuilder();
for ( String el : classPath )
{
- // NOTE: if File points to a directory, this entry MUST end in '/'.
- cp.append( toURL( new File( el ) ).toExternalForm() )
+ File file1 = new File( el );
+ String pathEnd = file1.isDirectory() ? "/" : "";
+ cp.append( file1.toURI().toASCIIString() )
+ .append( pathEnd )
.append( " " );
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/9478990e/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
index 13388c5..e7d97c8 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/Classpath.java
@@ -162,9 +162,9 @@ public class Classpath implements Iterable<String>
try
{
IsolatedClassLoader classLoader = new IsolatedClassLoader( parent, childDelegation, roleName );
- for ( URL url : getAsUrlList() )
+ for ( String classPathElement : unmodifiableElements )
{
- classLoader.addURL( url );
+ classLoader.addURL( new File( classPathElement ).toURL() );
}
if ( parent != null )
{
@@ -179,7 +179,6 @@ public class Classpath implements Iterable<String>
}
}
-
public int hashCode()
{
return unmodifiableElements.hashCode();
[2/4] maven-surefire git commit: [SUREFIRE] refactoring
Posted by ti...@apache.org.
[SUREFIRE] refactoring
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/fd293d89
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/fd293d89
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/fd293d89
Branch: refs/heads/master
Commit: fd293d8971c0c869fca6ee9cd9d17145b9a76bd1
Parents: 68246e2
Author: Tibor17 <ti...@lycos.com>
Authored: Sun Dec 11 13:28:37 2016 +0100
Committer: Tibor17 <ti...@lycos.com>
Committed: Sun Dec 11 13:28:37 2016 +0100
----------------------------------------------------------------------
.../apache/maven/surefire/booter/ClasspathConfiguration.java | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/fd293d89/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java
index d582f3c..3389a37 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ClasspathConfiguration.java
@@ -82,7 +82,7 @@ public class ClasspathConfiguration
throws SurefireExecutionException
{
return Classpath.join( inprocClasspath, classpathUrls )
- .createClassLoader( null, this.childDelegation, enableAssertions, "test" );
+ .createClassLoader( null, childDelegation, enableAssertions, "test" );
}
public Classpath getProviderClasspath()
@@ -90,8 +90,7 @@ public class ClasspathConfiguration
return surefireClasspathUrls;
}
-
- public Classpath getTestClasspath()
+ public Classpath getTestClasspath()
{
return classpathUrls;
}