From dd9ac13f7e3b71bdf2eca717bc7681bdd12389a2 Mon Sep 17 00:00:00 2001 From: Googler Date: Fri, 17 May 2019 14:19:04 -0700 Subject: [PATCH] Fix a bug when a relative path is used for the execution log Fixes #8364 RELNOTES: None PiperOrigin-RevId: 248786565 --- .../devtools/build/lib/bazel/SpawnLogModule.java | 2 +- src/test/shell/bazel/bazel_execlog_test.sh | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) 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"