You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ol...@apache.org on 2021/06/21 21:15:49 UTC
[sling-org-apache-sling-clam] 01/02: SLING-9699 Enable code
coverage with JaCoCo
This is an automated email from the ASF dual-hosted git repository.
olli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-clam.git
commit 991ba9db0b88898b8ff446a91c8267dd7e614e7a
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Mon Jun 21 22:37:40 2021 +0200
SLING-9699 Enable code coverage with JaCoCo
inherit system properties from parent and check command
---
pom.xml | 35 ++--------------------
.../sling/clam/it/tests/ClamTestSupport.java | 13 +++++++-
2 files changed, 15 insertions(+), 33 deletions(-)
diff --git a/pom.xml b/pom.xml
index d15d2ca..debbc27 100644
--- a/pom.xml
+++ b/pom.xml
@@ -85,40 +85,11 @@
</executions>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
- <systemProperties>
- <property>
- <name>bundle.filename</name>
- <value>${basedir}/target/${project.build.finalName}.jar</value>
- </property>
- <property>
- <name>jacoco.command</name>
- <value>${jacoco.command}</value>
- </property>
- </systemProperties>
+ <systemPropertyVariables combine.children="append">
+ <bundle.filename>${basedir}/target/${project.build.finalName}.jar</bundle.filename>
+ </systemPropertyVariables>
</configuration>
</plugin>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>prepare-agent</id>
- <configuration>
- <propertyName>jacoco.command</propertyName>
- </configuration>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- </execution>
- <execution>
- <id>report</id>
- <phase>post-integration-test</phase>
- <goals>
- <goal>report</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
diff --git a/src/test/java/org/apache/sling/clam/it/tests/ClamTestSupport.java b/src/test/java/org/apache/sling/clam/it/tests/ClamTestSupport.java
index 3ca1ce9..bd15523 100644
--- a/src/test/java/org/apache/sling/clam/it/tests/ClamTestSupport.java
+++ b/src/test/java/org/apache/sling/clam/it/tests/ClamTestSupport.java
@@ -19,6 +19,7 @@
package org.apache.sling.clam.it.tests;
import java.util.Collections;
+import java.util.Objects;
import java.util.regex.Pattern;
import javax.inject.Inject;
@@ -35,6 +36,8 @@ import org.apache.sling.jcr.api.SlingRepository;
import org.apache.sling.testing.paxexam.TestSupport;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.options.ModifiableCompositeOption;
+import org.ops4j.pax.exam.options.OptionalCompositeOption;
+import org.ops4j.pax.exam.options.extra.VMOption;
import org.osgi.framework.BundleContext;
import static org.apache.sling.testing.paxexam.SlingOptions.awaitility;
@@ -47,6 +50,7 @@ import static org.ops4j.pax.exam.CoreOptions.composite;
import static org.ops4j.pax.exam.CoreOptions.junitBundles;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.vmOption;
+import static org.ops4j.pax.exam.CoreOptions.when;
import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.factoryConfiguration;
import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
@@ -96,10 +100,17 @@ public abstract class ClamTestSupport extends TestSupport {
awaitility(),
restassured(),
testcontainers(),
- vmOption(System.getProperty("jacoco.command"))
+ jacoco() // remove with Testing PaxExam 4.0
);
}
+ // remove with Testing PaxExam 4.0
+ protected OptionalCompositeOption jacoco() {
+ final String jacocoCommand = System.getProperty("jacoco.command");
+ final VMOption option = Objects.nonNull(jacocoCommand) && !jacocoCommand.trim().isEmpty() ? vmOption(jacocoCommand) : null;
+ return when(Objects.nonNull(option)).useOptions(option);
+ }
+
protected Option quickstart() {
final int httpPort = findFreePort();
final String workingDirectory = workingDirectory();