Allow negation of log file paths

Previously when passing `experimental_execution_log_file`, you could pass a second empty version of this like `--experimental_execution_log_file=` to negate previous callers. This broke recently and the replacement flags didn't support this behavior. Now this is supported for all the related flags.

Fixes: https://github.com/bazelbuild/bazel/issues/8393

Closes #8428.

PiperOrigin-RevId: 249638447
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 dea75cf..237481e 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
@@ -73,7 +73,8 @@
     FileSystem fileSystem = env.getRuntime().getFileSystem();
     Path workingDirectory = env.getWorkingDirectory();
 
-    if (executionOptions.executionLogBinaryFile != null) {
+    if (executionOptions.executionLogBinaryFile != null
+        && !executionOptions.executionLogBinaryFile.isEmpty()) {
       outputStreams.addStream(
           new BinaryOutputStreamWrapper(
               workingDirectory
@@ -81,7 +82,8 @@
                   .getOutputStream()));
     }
 
-    if (executionOptions.executionLogJsonFile != null) {
+    if (executionOptions.executionLogJsonFile != null
+        && !executionOptions.executionLogJsonFile.isEmpty()) {
       outputStreams.addStream(
           new JsonOutputStreamWrapper(
               workingDirectory
@@ -90,7 +92,7 @@
     }
 
     AsynchronousFileOutputStream outStream = null;
-    if (executionOptions.executionLogFile != null) {
+    if (executionOptions.executionLogFile != null && !executionOptions.executionLogFile.isEmpty()) {
       rawOutput = workingDirectory.getRelative(executionOptions.executionLogFile);
       outStream =
           new AsynchronousFileOutputStream(
diff --git a/src/test/shell/bazel/bazel_execlog_test.sh b/src/test/shell/bazel/bazel_execlog_test.sh
index 6dfbdc2..89b9e84 100755
--- a/src/test/shell/bazel/bazel_execlog_test.sh
+++ b/src/test/shell/bazel/bazel_execlog_test.sh
@@ -119,4 +119,28 @@
   wc output || fail "no output produced"
 }
 
+function test_negating_flags() {
+  cat > BUILD <<'EOF'
+genrule(
+      name = "rule",
+      outs = ["out.txt"],
+      cmd = "echo hello > $(location out.txt)"
+)
+EOF
+  bazel build //:all --experimental_execution_log_file=output --experimental_execution_log_file= 2>&1 >> $TEST_log || fail "could not build"
+  if [[ -e output ]]; then
+    fail "file shouldn't exist"
+  fi
+
+  bazel build //:all --execution_log_json_file=output --execution_log_json_file= 2>&1 >> $TEST_log || fail "could not build"
+  if [[ -e output ]]; then
+    fail "file shouldn't exist"
+  fi
+
+  bazel build //:all --execution_log_binary_file=output --execution_log_binary_file= 2>&1 >> $TEST_log || fail "could not build"
+  if [[ -e output ]]; then
+    fail "file shouldn't exist"
+  fi
+}
+
 run_suite "execlog_tests"