Skip to content

Commit

Permalink
Make --subcommands and --verbose_failures imply --materialize_param_f…
Browse files Browse the repository at this point in the history
…iles.

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
  • Loading branch information
tomlu authored and copybara-github committed Aug 4, 2019
1 parent b98ad77 commit b5a727a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -134,9 +135,17 @@ public class ExecutionOptions extends OptionsBase {
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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public boolean canExec(Spawn spawn) {
}

private void maybeWriteParamFilesLocally(Spawn spawn) throws IOException {
if (!executionOptions.materializeParamFiles) {
if (!executionOptions.shouldMaterializeParamFiles()) {
return;
}
for (ActionInput actionInput : spawn.getInputFiles()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -813,8 +813,21 @@ public void testExitCode_executionfailure() throws Exception {

@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(
Expand Down

0 comments on commit b5a727a

Please sign in to comment.