Skip to content

Commit

Permalink
Set runfiles vars to absolute paths when debugging Go tests
Browse files Browse the repository at this point in the history
Otherwise they will be incorrectly interpreted relative to the modified working directory.
  • Loading branch information
fmeum committed Oct 11, 2024
1 parent 034175e commit c860a29
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit c860a29

Please sign in to comment.