From ac4181c71bd6e7ad1f564c88405c18c60e365b0f Mon Sep 17 00:00:00 2001 From: Joel Jeske Date: Mon, 26 Aug 2024 03:36:29 -0500 Subject: [PATCH] [bugfix] normalize paths to enable running external tests (#1598) --- src/java/io/bazel/rulesscala/scala_test/Runner.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/java/io/bazel/rulesscala/scala_test/Runner.java b/src/java/io/bazel/rulesscala/scala_test/Runner.java index 905a0b60f..134181b70 100644 --- a/src/java/io/bazel/rulesscala/scala_test/Runner.java +++ b/src/java/io/bazel/rulesscala/scala_test/Runner.java @@ -5,6 +5,7 @@ import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; import java.util.Map; @@ -48,7 +49,9 @@ private static String[] extendFromFileArgs(String[] args) throws IOException { if (workspace == null || workspace.trim().isEmpty()) throw new IllegalArgumentException(RULES_SCALA_MAIN_WS_NAME + " is null or empty."); - String runnerArgsFilePath = Runfiles.create().rlocation(workspace + "/" + runnerArgsFileKey); + + Path runnerArgsUnresolvedFileLocation = Paths.get(workspace + "/" + runnerArgsFileKey).normalize(); + String runnerArgsFilePath = Runfiles.create().rlocation(runnerArgsUnresolvedFileLocation.toString()); if (runnerArgsFilePath == null) throw new IllegalArgumentException("rlocation value is null for key: " + runnerArgsFileKey); @@ -90,7 +93,8 @@ private static void rlocateRunpathValue(String rulesWorkspace, List runn String[] runpathElements = runnerArgs.get(runpathFlag + 1).split(File.pathSeparator); Runfiles runfiles = Runfiles.create(); for (int i = 0; i < runpathElements.length; i++) { - runpathElements[i] = runfiles.rlocation(rulesWorkspace + "/" + runpathElements[i]); + Path runPathElementPath = Paths.get(rulesWorkspace + "/" + runpathElements[i]).normalize(); + runpathElements[i] = runfiles.rlocation(runPathElementPath.toString()); } String runpath = String.join(File.separator, runpathElements); runnerArgs.set(runpathFlag + 1, runpath);