diff --git a/src/main/java/com/google/devtools/build/lib/bazel/SpawnLogModule.java b/src/main/java/com/google/devtools/build/lib/bazel/SpawnLogModule.java index 55779abed37185..dea75cf9938187 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/SpawnLogModule.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/SpawnLogModule.java @@ -91,7 +91,7 @@ private void initOutputs(CommandEnvironment env) throws IOException { AsynchronousFileOutputStream outStream = null; if (executionOptions.executionLogFile != null) { - rawOutput = env.getRuntime().getFileSystem().getPath(executionOptions.executionLogFile); + rawOutput = workingDirectory.getRelative(executionOptions.executionLogFile); outStream = new AsynchronousFileOutputStream( workingDirectory.getRelative(executionOptions.executionLogFile)); diff --git a/src/test/shell/bazel/bazel_execlog_test.sh b/src/test/shell/bazel/bazel_execlog_test.sh index 389e6da6a411c8..6dfbdc251048f8 100755 --- a/src/test/shell/bazel/bazel_execlog_test.sh +++ b/src/test/shell/bazel/bazel_execlog_test.sh @@ -107,4 +107,16 @@ EOF fi } +function test_dir_relative() { + cat > BUILD <<'EOF' +genrule( + name = "rule", + outs = ["out.txt"], + cmd = "echo hello > $(location out.txt)" +) +EOF + bazel build //:all --experimental_execution_log_file output 2>&1 >> $TEST_log || fail "could not build" + wc output || fail "no output produced" +} + run_suite "execlog_tests"