You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2021/12/01 21:53:56 UTC

[GitHub] [geode] upthewaterspout commented on a change in pull request #7151: Fixing the support for jacoco code coverage reports

upthewaterspout commented on a change in pull request #7151:
URL: https://github.com/apache/geode/pull/7151#discussion_r760599489



##########
File path: buildSrc/src/main/java/org/apache/geode/gradle/testing/isolation/WorkingDirectoryIsolator.java
##########
@@ -65,6 +69,21 @@ public void accept(ProcessBuilder processBuilder) {
     List<String> command = processBuilder.command();
     findGradleWorkerClasspathArg(command)
         .ifPresent(i -> updateGradleWorkerClasspathFile(command, i, newWorkingDirectory));
+
+    upgradeRelativePaths(command);
+    log.debug("WorkingDirectoryIsolator updated command. New Working directory: {}, Command: {}", newWorkingDirectory, command);
+  }
+
+  /**
+   * Replace all occurrences of "../" that are not proceeded by a / in the command with "../../"
+   * to match the new working directory of the process. This fixes issues with java agent commands
+   * like jacoco that pass relative paths, eg "-agentlib:../tmp/jacocoXXX=../jacoco/test.txt
+   * @param command the commmand line to upgrade. It will be modified in place.
+   */
+  private void upgradeRelativePaths(List<String> command) {
+    for(int i =0 ; i < command.size(); i++) {
+      command.set(i, command.get(i).replaceAll( "(?<!/)\\.\\./", "../../"));
+    }

Review comment:
       Done. The problem is - we may not have any relative paths unless trying to run with code coverage on windows. I updated the code to handle both types of paths just in case. I don't really know if gradle uses windows style paths at all - java theoretically will accept unix paths even when running on windows.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org