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/15 23:20:01 UTC

[sling-org-apache-sling-testing-paxexam] 04/04: SLING-10490 Add jacoco command when set to base configuration

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-testing-paxexam.git

commit f68a8964b1a451fe9d983186daac1882968bb396
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Wed Jun 16 01:19:39 2021 +0200

    SLING-10490 Add jacoco command when set to base configuration
---
 .../java/org/apache/sling/testing/paxexam/TestSupport.java  | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/testing/paxexam/TestSupport.java b/src/main/java/org/apache/sling/testing/paxexam/TestSupport.java
index 9189a02..72312fa 100644
--- a/src/main/java/org/apache/sling/testing/paxexam/TestSupport.java
+++ b/src/main/java/org/apache/sling/testing/paxexam/TestSupport.java
@@ -22,6 +22,7 @@ import java.io.File;
 import java.io.IOException;
 import java.net.ServerSocket;
 import java.util.Dictionary;
+import java.util.Objects;
 import java.util.UUID;
 
 import javax.inject.Inject;
@@ -29,6 +30,8 @@ import javax.inject.Inject;
 import org.ops4j.pax.exam.CoreOptions;
 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.ops4j.pax.exam.util.PathUtils;
 import org.ops4j.pax.tinybundles.core.TinyBundle;
 import org.osgi.service.cm.ConfigurationAdmin;
@@ -43,6 +46,7 @@ import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 import static org.ops4j.pax.exam.CoreOptions.repository;
 import static org.ops4j.pax.exam.CoreOptions.streamBundle;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.CoreOptions.vmOption;
 import static org.ops4j.pax.exam.CoreOptions.when;
 import static org.ops4j.pax.tinybundles.core.TinyBundles.withBnd;
 
@@ -62,6 +66,12 @@ public abstract class TestSupport {
         return Integer.parseInt(properties.get("org.osgi.service.http.port").toString());
     }
 
+    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);
+    }
+
     private ModifiableCompositeOption configuration() {
         return composite(
             failOnUnresolvedBundles(),
@@ -71,7 +81,8 @@ public abstract class TestSupport {
             CoreOptions.workingDirectory(workingDirectory()),
             paxTinybundles(),
             backing(),
-            spifly()
+            spifly(),
+            jacoco()
         );
     }