You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2022/03/01 10:42:32 UTC
[maven-surefire] 02/03: fix record of jacoco coverage with surefire-its
This is an automated email from the ASF dual-hosted git repository.
olamy pushed a commit to branch ci-reporting
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
commit 3e64cbc62303cc44e761b18b377d0216a7eebba2
Author: Olivier Lamy <ol...@apache.org>
AuthorDate: Tue Mar 1 15:02:04 2022 +1000
fix record of jacoco coverage with surefire-its
Signed-off-by: Olivier Lamy <ol...@apache.org>
---
pom.xml | 17 ++++++++---------
surefire-its/pom.xml | 5 +++++
.../maven/surefire/its/fixture/MavenLauncher.java | 15 +++++++++++++++
.../maven/surefire/its/fixture/SurefireLauncher.java | 3 ---
4 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/pom.xml b/pom.xml
index 28247e9..516ae82 100644
--- a/pom.xml
+++ b/pom.xml
@@ -97,7 +97,7 @@
<mavenSharedUtilsVersion>3.3.4</mavenSharedUtilsVersion>
<powermockVersion>2.0.9</powermockVersion>
<mavenPluginToolsVersion>3.6.2</mavenPluginToolsVersion>
- <jacocoVersion>0.8.7</jacocoVersion>
+ <jacoco.version>0.8.7</jacoco.version>
<surefire-shared-utils.version>${project.version}</surefire-shared-utils.version>
<maven.surefire.scm.devConnection>scm:git:https://gitbox.apache.org/repos/asf/maven-surefire.git</maven.surefire.scm.devConnection>
<maven.site.path>surefire-archives/surefire-LATEST</maven.site.path>
@@ -334,7 +334,7 @@
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
<classifier>runtime</classifier>
- <version>${jacocoVersion}</version>
+ <version>${jacoco.version}</version>
</dependency>
<dependency>
<groupId>com.googlecode.junit-toolbox</groupId>
@@ -465,7 +465,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
- <version>${jacocoVersion}</version>
+ <version>${jacoco.version}</version>
<configuration>
<skip>${skipTests}</skip>
<!--<append>true</append>
@@ -476,16 +476,15 @@
<format>HTML</format>
</formats>
<includes>
- <include>**/failsafe/*</include>
- <include>**/failsafe/**/*</include>
- <include>**/surefire/*</include>
- <include>**/surefire/**/*</include>
+ <include>org/apache/maven/plugin/failsafe/**</include>
+ <include>org/apache/maven/plugin/surefire/**</include>
+ <include>org/apache/maven/plugins/surefire/**</include>
+ <include>org/apache/surefire/**</include>
+ <include>org/apache/maven/surefire/**</include>
</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-its/pom.xml b/surefire-its/pom.xml
index e63e7da..edbebd3 100644
--- a/surefire-its/pom.xml
+++ b/surefire-its/pom.xml
@@ -231,6 +231,11 @@
<artifactId>surefire-junit47</artifactId>
<version>3.0.0-M5</version> <!-- ${shadedVersion}, but resolved due to https://issues.apache.org/jira/browse/MRELEASE-799 -->
</dependency>
+ <dependency>
+ <groupId>org.jacoco</groupId>
+ <artifactId>org.jacoco.agent</artifactId>
+ <version>${jacoco.version}</version>
+ </dependency>
</dependencies>
<executions>
<execution>
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java
index 8dc2465..1336934 100755
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java
@@ -315,6 +315,21 @@ public final class MavenLauncher
String val = e.getValue();
goalsAndProps.add( val == null ? "-D" + key : "-D" + key + "=" + val );
}
+ String jacocoAgent = System.getProperty( "jacoco.agent", "" );
+ if ( jacocoAgent.length() > 0 )
+ {
+ System.out.println( "jacocoAgent:" + jacocoAgent );
+ String mavenOpts = envVars.get( "MAVEN_OPTS" );
+ if ( mavenOpts == null )
+ {
+ mavenOpts = jacocoAgent;
+ }
+ else
+ {
+ mavenOpts += " " + jacocoAgent;
+ }
+ envVars.put( "MAVEN_OPTS", mavenOpts );
+ }
getVerifier().setCliOptions( cliOptions );
getVerifier().executeGoals( goalsAndProps, envVars );
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
index 0394123..cf9752b 100755
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
@@ -96,9 +96,6 @@ public final class SurefireLauncher
goals.add( "-Dsurefire.version=" + surefireVersion );
- String jacocoAgent = System.getProperty( "jacoco.agent", "" );
- goals.add( "-Djacoco.agent=" + jacocoAgent );
-
goals.add( "-Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2" );
goals.add( "-nsu" );