Make --subcommands and --verbose_failures imply --materialize_param_files.
CL/201225566 promised to do this, but for whatever reason it was never implemented.
RELNOTES: Make either --subcommands or --verbose_failures imply --materialize_param_files
PiperOrigin-RevId: 261534671
diff --git a/src/main/java/com/google/devtools/build/lib/exec/ExecutionOptions.java b/src/main/java/com/google/devtools/build/lib/exec/ExecutionOptions.java
index fe41141..318ac9e 100644
--- a/src/main/java/com/google/devtools/build/lib/exec/ExecutionOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/exec/ExecutionOptions.java
@@ -15,6 +15,7 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
+import com.google.devtools.build.lib.actions.ActionExecutionContext;
import com.google.devtools.build.lib.actions.ActionExecutionContext.ShowSubcommands;
import com.google.devtools.build.lib.actions.LocalHostCapacity;
import com.google.devtools.build.lib.actions.ResourceSet;
@@ -134,9 +135,17 @@
effectTags = {OptionEffectTag.UNKNOWN},
help =
"Writes intermediate parameter files to output tree even when using "
- + "remote action execution. Useful when debugging actions. ")
+ + "remote action execution. Useful when debugging actions. "
+ + "This is implied by --subcommands or --verbose_failures.")
public boolean materializeParamFiles;
+ public boolean shouldMaterializeParamFiles() {
+ // Implied by --subcommands or --verbose_failures
+ return materializeParamFiles
+ || showSubcommands != ActionExecutionContext.ShowSubcommands.FALSE
+ || verboseFailures;
+ }
+
@Option(
name = "verbose_failures",
defaultValue = "false",
diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java
index e5873a4..82754f8 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java
@@ -335,7 +335,7 @@
}
private void maybeWriteParamFilesLocally(Spawn spawn) throws IOException {
- if (!executionOptions.materializeParamFiles) {
+ if (!executionOptions.shouldMaterializeParamFiles()) {
return;
}
for (ActionInput actionInput : spawn.getInputFiles()) {
diff --git a/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerTest.java b/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerTest.java
index 21f8805..aa60c3b 100644
--- a/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/remote/RemoteSpawnRunnerTest.java
@@ -813,8 +813,21 @@
@Test
public void testMaterializeParamFiles() throws Exception {
- ExecutionOptions executionOptions =
- Options.parse(ExecutionOptions.class, "--materialize_param_files").getOptions();
+ testParamFilesAreMaterializedForFlag("--materialize_param_files");
+ }
+
+ @Test
+ public void testMaterializeParamFilesIsImpliedBySubcommands() throws Exception {
+ testParamFilesAreMaterializedForFlag("--subcommands");
+ }
+
+ @Test
+ public void testMaterializeParamFilesIsImpliedByVerboseFailures() throws Exception {
+ testParamFilesAreMaterializedForFlag("--verbose_failures");
+ }
+
+ private void testParamFilesAreMaterializedForFlag(String flag) throws Exception {
+ ExecutionOptions executionOptions = Options.parse(ExecutionOptions.class, flag).getOptions();
executionOptions.materializeParamFiles = true;
RemoteSpawnRunner runner =
new RemoteSpawnRunner(