Propagate JaCoCo argLine to Karaf as needed 62/97962/3
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 17 Oct 2021 20:23:02 +0000 (22:23 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Sun, 17 Oct 2021 21:13:06 +0000 (23:13 +0200)
We have disabled JaCoCo execution reports because they do not work
with SFT correctly. This problem boils down to running the right JVM
with JaCoCo options -- it should not be the surefire JVM, but rather
Karaf we start from it.

Use @{argLine} special handling in surefire to pass the argLine (set by
JaCoCo) as a system property rather than it being a JVM argument.

This does not solve integration with Sonar, as we still need to deal
with the XML report being empty, but it is a start and an example for
others using pax-exam.

JIRA: ODLPARENT-274
Change-Id: I9b33e5b5c9b3b3b2b347f4f4ef034acb677d501a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
features-test/src/main/java/org/opendaylight/odlparent/featuretest/SingleFeatureTest.java
single-feature-parent/pom.xml

index 652c2849079c538a5e8d2733988283db1d261249..8f36764087ae806f455885d20070d55f48ccfff0 100644 (file)
@@ -226,6 +226,9 @@ public class SingleFeatureTest {
             // Install SCR
             features(maven().groupId("org.apache.karaf.features").artifactId("standard").type("xml")
                 .classifier("features").versionAsInProject(), "scr"),
+
+            // Enable JaCoCo, if present
+            jacocoOption(),
         };
 
         if (JavaVersionUtil.getMajorVersion() <= 8) {
@@ -260,6 +263,11 @@ public class SingleFeatureTest {
             new VMOption("lib/jdk9plus/*" + File.pathSeparator + "lib/boot/*"));
     }
 
+    private static Option jacocoOption() {
+        final String sftArgLine = System.getProperty("sftArgLine");
+        return sftArgLine == null || sftArgLine.isBlank() ? null : new VMOption(sftArgLine);
+    }
+
     private static String getNewJFRFile() throws IOException {
         return File.createTempFile("SingleFeatureTest-Karaf-JavaFlightRecorder", ".jfr").getAbsolutePath();
     }
index d0812a86cfc43b91a99261b4164573668106ea80..758b83dcdd1439a4f6b2f57e56009544f69f2179 100644 (file)
                     </additionalClasspathElements>
                     <skip>${skip.karaf.featureTest}</skip>
                     <systemPropertyVariables>
-                      <!-- Use the same repository for Pax Exam as is used for Maven -->
-                      <org.ops4j.pax.url.mvn.localRepository>${settings.localRepository}</org.ops4j.pax.url.mvn.localRepository>
+                        <!-- Use the same repository for Pax Exam as is used for Maven -->
+                        <org.ops4j.pax.url.mvn.localRepository>${settings.localRepository}</org.ops4j.pax.url.mvn.localRepository>
                     </systemPropertyVariables>
+
+                    <!-- Disable argLine if present, but pass it to SFT -->
+                    <argLine>-DsftArgLine='@{argLine}'</argLine>
                 </configuration>
                 <executions>
                     <execution>