Skip to content

Commit

Permalink
set go DebugConfguration test working directory to match the run's (#…
Browse files Browse the repository at this point in the history
…6748)

Co-authored-by: Andrzej Głuszak <andrzej.gluszak@jetbrains.com>
  • Loading branch information
muldrik and agluszak authored Sep 12, 2024
1 parent 02ad803 commit 47517d0
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,8 @@ private static File findExecutable(Label target, List<File> outputs) {
private static final Pattern TEST_SRCDIR = Pattern.compile("TEST_SRCDIR=([^ ]+)");
// Matches RUNFILES_<NAME>=<value>
private static final Pattern RUNFILES_VAR = Pattern.compile("RUNFILES_([A-Z_]+)=([^ ]+)");
// Matches TEST_TARGET=//<package_path>:<target>
private static final Pattern TEST_TARGET = Pattern.compile("TEST_TARGET=//([^:]*):([^\\s]+)");
// Matches a space-delimited arg list. Supports wrapping arg in single quotes.
private static final Pattern ARGS = Pattern.compile("([^\']\\S*|\'.+?\')\\s*");

Expand Down Expand Up @@ -443,7 +445,6 @@ private static ExecutableInfo parseScriptPathFile(
while (runfilesVars.find()) {
envVars.put(String.format("RUNFILES_%s", runfilesVars.group(1)), runfilesVars.group(2));
}
workingDir = workspaceRoot.directory();
String workspaceName = execRoot.getName();
binary =
Paths.get(
Expand All @@ -452,6 +453,21 @@ private static ExecutableInfo parseScriptPathFile(
workspaceName,
args.get(1))
.toFile();

Matcher testTarget = TEST_TARGET.matcher(text);
if (testTarget.find()) {
String packagePath = testTarget.group(1);
workingDir =
Paths.get(
workspaceRoot.directory().getPath(),
testScrDir.group(1),
workspaceName,
packagePath)
.toFile();
} else {
workingDir = workspaceRoot.directory();
}

// Remove everything except the args.
args = args.subList(2, args.size() - 1);
} else {
Expand Down

0 comments on commit 47517d0

Please sign in to comment.