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 2019/04/30 10:28:01 UTC
[maven-surefire] branch 1546-1222 updated: repaired low jacoco
coverage - OverlappingFileLockException in jacoco instrumentation (in next
commit: agent should be default as before and no implicit test
dependencies)
This is an automated email from the ASF dual-hosted git repository.
tibordigana pushed a commit to branch 1546-1222
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
The following commit(s) were added to refs/heads/1546-1222 by this push:
new 0bd1ac7 repaired low jacoco coverage - OverlappingFileLockException in jacoco instrumentation (in next commit: agent should be default as before and no implicit test dependencies)
0bd1ac7 is described below
commit 0bd1ac748fc7945c7e78f52199f296e567fcdb71
Author: tibordigana <ti...@apache.org>
AuthorDate: Tue Apr 30 12:27:40 2019 +0200
repaired low jacoco coverage - OverlappingFileLockException in jacoco instrumentation (in next commit: agent should be default as before and no implicit test dependencies)
---
maven-surefire-common/pom.xml | 16 +++++++++
.../AbstractSurefireMojoJava7PlusTest.java | 2 ++
.../plugin/surefire/AbstractSurefireMojoTest.java | 2 ++
.../booterclient/DefaultForkConfigurationTest.java | 2 ++
.../JarManifestForkConfigurationTest.java | 2 ++
.../plugin/surefire/report/TestSetStatsTest.java | 2 ++
.../StatelessTestsetInfoReporterTest.java | 2 ++
pom.xml | 23 +++++++++++--
surefire-api/pom.xml | 5 +++
surefire-booter/pom.xml | 16 ---------
.../maven/surefire/booter/SystemUtilsTest.java | 5 ++-
surefire-providers/surefire-junit4/pom.xml | 25 ++++++++++++++
.../maven/surefire/junit4/JUnit4SuiteTest.java | 39 ++++++++++++++++++++++
13 files changed, 122 insertions(+), 19 deletions(-)
diff --git a/maven-surefire-common/pom.xml b/maven-surefire-common/pom.xml
index 18fed62..91e12d2 100644
--- a/maven-surefire-common/pom.xml
+++ b/maven-surefire-common/pom.xml
@@ -125,6 +125,22 @@
<build>
<plugins>
<plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>build-test-classpath</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>build-classpath</goal>
+ </goals>
+ <configuration>
+ <includeScope>test</includeScope>
+ <outputFile>target/test-classpath/cp.txt</outputFile>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java
index 7770ab1..b178d64 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java
@@ -39,6 +39,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@@ -68,6 +69,7 @@ import static org.powermock.reflect.Whitebox.invokeMethod;
*/
@RunWith( PowerMockRunner.class )
@PrepareForTest( { AbstractSurefireMojo.class, ResolvePathsRequest.class } )
+@PowerMockIgnore( { "org.jacoco.agent.rt.*", "com.vladium.emma.rt.*" } )
public class AbstractSurefireMojoJava7PlusTest
{
@Mock
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java
index c71001b..e193eee 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java
@@ -50,6 +50,7 @@ import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@@ -90,6 +91,7 @@ import static org.powermock.reflect.Whitebox.invokeMethod;
*/
@RunWith( PowerMockRunner.class )
@PrepareForTest( AbstractSurefireMojo.class )
+@PowerMockIgnore( { "org.jacoco.agent.rt.*", "com.vladium.emma.rt.*" } )
public class AbstractSurefireMojoTest
{
@Mock
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/DefaultForkConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/DefaultForkConfigurationTest.java
index 6bedab9..a8f6c69 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/DefaultForkConfigurationTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/DefaultForkConfigurationTest.java
@@ -31,6 +31,7 @@ import org.apache.maven.surefire.booter.SurefireBooterForkException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@@ -58,6 +59,7 @@ import static org.powermock.reflect.Whitebox.invokeMethod;
*/
@RunWith( PowerMockRunner.class )
@PrepareForTest( { DefaultForkConfiguration.class, Relocator.class } )
+@PowerMockIgnore( { "org.jacoco.agent.rt.*", "com.vladium.emma.rt.*" } )
public class DefaultForkConfigurationTest
{
private Classpath booterClasspath;
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfigurationTest.java
index 5e71238..7e3249f 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfigurationTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/JarManifestForkConfigurationTest.java
@@ -47,6 +47,7 @@ import static org.powermock.api.mockito.PowerMockito.when;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@@ -55,6 +56,7 @@ import org.powermock.modules.junit4.PowerMockRunner;
*/
@RunWith( PowerMockRunner.class )
@PrepareForTest( { JarManifestForkConfiguration.class, InPluginProcessDumpSingleton.class } )
+@PowerMockIgnore( { "org.jacoco.agent.rt.*", "com.vladium.emma.rt.*" } )
public class JarManifestForkConfigurationTest
{
private static final File TMP = newTemporaryFolder();
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/TestSetStatsTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/TestSetStatsTest.java
index 7fdb51d..7aac381 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/TestSetStatsTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/TestSetStatsTest.java
@@ -23,6 +23,7 @@ import org.apache.maven.surefire.report.ReportEntry;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.modules.junit4.PowerMockRunner;
import static org.apache.maven.shared.utils.logging.MessageUtils.buffer;
@@ -36,6 +37,7 @@ import static org.mockito.Mockito.when;
* tests for {@link TestSetStats}.
*/
@RunWith( PowerMockRunner.class )
+@PowerMockIgnore( { "org.jacoco.agent.rt.*", "com.vladium.emma.rt.*" } )
public class TestSetStatsTest
{
@Mock
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/extensions/StatelessTestsetInfoReporterTest.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/extensions/StatelessTestsetInfoReporterTest.java
index 0ce6f7d..7967268 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/extensions/StatelessTestsetInfoReporterTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/extensions/StatelessTestsetInfoReporterTest.java
@@ -32,6 +32,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.modules.junit4.PowerMockRunner;
import java.io.File;
@@ -54,6 +55,7 @@ import static org.powermock.reflect.Whitebox.getInternalState;
* tests for {@link DefaultStatelessTestsetInfoReporter} and {@link JUnit5StatelessTestsetInfoReporter}.
*/
@RunWith( PowerMockRunner.class )
+@PowerMockIgnore( { "org.jacoco.agent.rt.*", "com.vladium.emma.rt.*" } )
public class StatelessTestsetInfoReporterTest
{
@Mock
diff --git a/pom.xml b/pom.xml
index ffdfee6..54ec65a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -102,6 +102,7 @@
<maven.compiler.testSource>1.${javaVersion}</maven.compiler.testSource>
<maven.compiler.testTarget>1.${javaVersion}</maven.compiler.testTarget>
<jvm.args.tests>-server -XX:+UseG1GC -Xms128m -Xmx144m -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:SoftRefLRUPolicyMSPerMB=50 -Djava.awt.headless=true -Djdk.net.URLClassPath.disableClassPathURLCheck=true</jvm.args.tests>
+ <jacoco.instrumentation.skip>false</jacoco.instrumentation.skip>
</properties>
<dependencyManagement>
@@ -493,7 +494,6 @@
<goal>check</goal>
</goals>
<configuration>
- <skip>true</skip>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java17</artifactId>
@@ -514,7 +514,7 @@
<redirectTestOutputToFile>false</redirectTestOutputToFile>
<jvm>${jdk.home}/bin/java</jvm>
<systemPropertyVariables>
- <jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
+ <jacoco-agent.destfile>${project.build.directory}/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables>
</configuration>
</plugin>
@@ -548,17 +548,29 @@
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
+ <id>jacoco-agent</id>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ </execution>
+ <execution>
<id>instrument</id>
<phase>generate-test-resources</phase>
<goals>
<goal>instrument</goal>
</goals>
+ <configuration>
+ <skip>${jacoco.instrumentation.skip}</skip>
+ </configuration>
</execution>
<execution>
<id>restore-classes</id>
<goals>
<goal>restore-instrumented-classes</goal>
</goals>
+ <configuration>
+ <skip>${jacoco.instrumentation.skip}</skip>
+ </configuration>
</execution>
<execution>
<id>jacoco-report</id>
@@ -569,7 +581,11 @@
</execution>
</executions>
<configuration>
+ <propertyName>jacoco.agent</propertyName>
+ <append>true</append>
+ <inclNoLocationClasses>true</inclNoLocationClasses>
<haltOnFailure>false</haltOnFailure>
+ <jmx>false</jmx>
<includes>
<include>**/failsafe/*</include>
<include>**/failsafe/**/*</include>
@@ -578,6 +594,9 @@
</includes>
<excludes>
<exclude>**/HelpMojo.class</exclude>
+ <exclude>**/shadefire/**/*</exclude>
+ <exclude>org/jacoco/**/*</exclude>
+ <exclude>com/vladium/emma/rt/*</exclude>
</excludes>
</configuration>
</plugin>
diff --git a/surefire-api/pom.xml b/surefire-api/pom.xml
index c42041b..b6e5145 100644
--- a/surefire-api/pom.xml
+++ b/surefire-api/pom.xml
@@ -31,6 +31,10 @@
<name>SureFire API</name>
<description>API used in Surefire and Failsafe MOJO, Booter, Common and test framework providers.</description>
+ <properties>
+ <jacoco.instrumentation.skip>true</jacoco.instrumentation.skip>
+ </properties>
+
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
@@ -62,6 +66,7 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
+ <argLine>${jvm.args.tests} ${jacoco.agent}</argLine>
<includes>
<include>**/JUnit4SuiteTest.java</include>
</includes>
diff --git a/surefire-booter/pom.xml b/surefire-booter/pom.xml
index 74cd93c..4ca6536 100644
--- a/surefire-booter/pom.xml
+++ b/surefire-booter/pom.xml
@@ -91,22 +91,6 @@
<build>
<plugins>
<plugin>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>build-test-classpath</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>build-classpath</goal>
- </goals>
- <configuration>
- <includeScope>test</includeScope>
- <outputFile>target/test-classpath/cp.txt</outputFile>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
<dependency>
diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SystemUtilsTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SystemUtilsTest.java
index a957d06..438cb00 100644
--- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SystemUtilsTest.java
+++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SystemUtilsTest.java
@@ -22,6 +22,7 @@ package org.apache.maven.surefire.booter;
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@@ -63,7 +64,8 @@ public class SystemUtilsTest
public void shouldMatchJavaSpecVersion() throws Exception
{
BigDecimal actual = invokeMethod( SystemUtils.class, "getJavaSpecificationVersion" );
- BigDecimal expected = new BigDecimal( System.getProperty( "java.specification.version" ) ).stripTrailingZeros();
+ BigDecimal expected =
+ new BigDecimal( System.getProperty( "java.specification.version" ) ).stripTrailingZeros();
assertThat( actual ).isEqualTo( expected );
assertThat( SystemUtils.JAVA_SPECIFICATION_VERSION ).isEqualTo( expected );
}
@@ -295,6 +297,7 @@ public class SystemUtilsTest
@RunWith( PowerMockRunner.class )
@PrepareForTest( SystemUtils.class )
+ @PowerMockIgnore( { "org.jacoco.agent.rt.*", "com.vladium.emma.rt.*" } )
public static class MockTest
{
diff --git a/surefire-providers/surefire-junit4/pom.xml b/surefire-providers/surefire-junit4/pom.xml
index d3816ad..1155cc9 100644
--- a/surefire-providers/surefire-junit4/pom.xml
+++ b/surefire-providers/surefire-junit4/pom.xml
@@ -31,6 +31,10 @@
<name>SureFire JUnit4 Runner</name>
<description>SureFire JUnit 4.0+ Runner</description>
+ <properties>
+ <jacoco.instrumentation.skip>true</jacoco.instrumentation.skip>
+ </properties>
+
<dependencies>
<dependency>
<groupId>junit</groupId>
@@ -44,4 +48,25 @@
<version>${project.version}</version>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <argLine>${jvm.args.tests} ${jacoco.agent}</argLine>
+ <includes>
+ <include>**/JUnit4SuiteTest.java</include>
+ </includes>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-shadefire</artifactId>
+ <version>3.0.0-M3</version> <!-- ${shadedVersion}, but resolved due to https://issues.apache.org/jira/browse/MRELEASE-799 -->
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4SuiteTest.java b/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4SuiteTest.java
new file mode 100644
index 0000000..0666fcb
--- /dev/null
+++ b/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4SuiteTest.java
@@ -0,0 +1,39 @@
+package org.apache.maven.surefire.junit4;
+
+/*
+ * 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 junit.framework.JUnit4TestAdapter;
+import junit.framework.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Adapt the JUnit4 tests which use only annotations to the JUnit3 test suite.
+ */
+@SuiteClasses( JUnit4ProviderTest.class )
+@RunWith( Suite.class )
+public class JUnit4SuiteTest
+{
+ public static Test suite()
+ {
+ return new JUnit4TestAdapter( JUnit4SuiteTest.class );
+ }
+}