From 7c92cfcf9a88933c29334f6271ad3f086f7f36f4 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Fri, 5 Feb 2021 00:49:25 -0800 Subject: [PATCH] Ignore empty virtual artifacts when spawn-logging inputs. Fixes https://github.com/bazelbuild/bazel/issues/12816. Closes #12819. PiperOrigin-RevId: 355800567 --- .../build/lib/exec/SpawnLogContext.java | 3 +++ src/test/shell/bazel/bazel_execlog_test.sh | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java b/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java index e5116f09406805..262c35f1672fbc 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java +++ b/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java @@ -91,6 +91,9 @@ public void logSpawn( try { for (Map.Entry e : inputMap.entrySet()) { ActionInput input = e.getValue(); + if (input instanceof VirtualActionInput.EmptyActionInput) { + continue; + } Path inputPath = execRoot.getRelative(input.getExecPathString()); if (inputPath.isDirectory()) { listDirectoryContents(inputPath, builder::addInputs, metadataProvider); diff --git a/src/test/shell/bazel/bazel_execlog_test.sh b/src/test/shell/bazel/bazel_execlog_test.sh index 11412e0687a463..6652833006c955 100755 --- a/src/test/shell/bazel/bazel_execlog_test.sh +++ b/src/test/shell/bazel/bazel_execlog_test.sh @@ -119,6 +119,26 @@ EOF wc output || fail "no output produced" } +function test_empty_file_in_runfiles() { + mkdir d + touch d/main.py + cat > BUILD <<'EOF' +py_binary( + name = "py_tool", + main = "d/main.py", + srcs = ["d/main.py"], +) +genrule( + name = "rule", + outs = ["out.txt"], + tools = [":py_tool"], + cmd = "echo hello > $(location out.txt)" +) +EOF + bazel build //:rule --experimental_execution_log_file output 2>&1 >> $TEST_log || fail "could not build" + [[ -e output ]] || fail "no output produced" +} + function test_negating_flags() { cat > BUILD <<'EOF' genrule(