From 017e06355eb32a53c5bd64b6b02776a33a92a800 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Fri, 11 Oct 2024 15:18:17 +0200 Subject: [PATCH] Set runfiles vars to absolute paths when debugging Go tests (#6883) Otherwise they will be incorrectly interpreted relative to the modified working directory. --- .../blaze/golang/run/BlazeGoRunConfigurationRunner.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/golang/src/com/google/idea/blaze/golang/run/BlazeGoRunConfigurationRunner.java b/golang/src/com/google/idea/blaze/golang/run/BlazeGoRunConfigurationRunner.java index 2f1ce2cc197..193341030ba 100644 --- a/golang/src/com/google/idea/blaze/golang/run/BlazeGoRunConfigurationRunner.java +++ b/golang/src/com/google/idea/blaze/golang/run/BlazeGoRunConfigurationRunner.java @@ -440,10 +440,13 @@ private static ExecutableInfo parseScriptPathFile( if (args.size() < 3) { throw new ExecutionException("Failed to parse args in script_path: " + scriptPath); } - envVars.put("TEST_SRCDIR", testScrDir.group(1)); + // Make paths used for runfiles discovery absolute as the working directory is changed below. + envVars.put("TEST_SRCDIR", workspaceRoot.absolutePathFor(testScrDir.group(1)).toString()); Matcher runfilesVars = RUNFILES_VAR.matcher(text); while (runfilesVars.find()) { - envVars.put(String.format("RUNFILES_%s", runfilesVars.group(1)), runfilesVars.group(2)); + envVars.put( + String.format("RUNFILES_%s", runfilesVars.group(1)), + workspaceRoot.absolutePathFor(runfilesVars.group(2)).toString()); } String workspaceName = execRoot.getName(); binary =