Skip to content

Commit

Permalink
aquery: Add option to include/exclude the command line of actions.
Browse files Browse the repository at this point in the history
RELNOTES: None
PiperOrigin-RevId: 211810138
  • Loading branch information
meisterT authored and Copybara-Service committed Sep 6, 2018
1 parent 73eccc2 commit 2217614
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public class ActionGraphProtoOutputFormatterCallback extends AqueryThreadsafeCal
SkyframeExecutor skyframeExecutor,
TargetAccessor<ConfiguredTargetValue> accessor) {
super(reporter, options, out, skyframeExecutor, accessor);
// TODO(twerth): Allow users to include action command lines.
actionGraphDump = new ActionGraphDump(/* includeActionCmdLine */ false);
actionGraphDump = new ActionGraphDump(options.includeCommandline);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,18 @@ private void writeAction(ActionAnalysisMetadata action, PrintStream printStream)
.append("]\n");
}

// TODO(twerth): Add option to only optionally include the command line.
stringBuilder
.append(" Command Line: ")
.append(
CommandFailureUtils.describeCommand(
CommandDescriptionForm.COMPLETE,
/* prettyPrintArgs= */ true,
spawnAction.getArguments(),
/* environment= */ null,
/* cwd= */ null))
.append("\n");
if (options.includeCommandline) {
stringBuilder
.append(" Command Line: ")
.append(
CommandFailureUtils.describeCommand(
CommandDescriptionForm.COMPLETE,
/* prettyPrintArgs= */ true,
spawnAction.getArguments(),
/* environment= */ null,
/* cwd= */ null))
.append("\n");
}
}

if (action instanceof ExecutionInfoSpecifier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,12 @@ public class AqueryOptions extends CommonQueryOptions {
effectTags = {OptionEffectTag.TERMINAL_OUTPUT},
help = "The format in which the aquery results should be printed.")
public String outputFormat;

@Option(
name = "include_commandline",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.QUERY,
effectTags = {OptionEffectTag.TERMINAL_OUTPUT},
help = "Includes the content of the action command lines in the output (potentially large).")
public boolean includeCommandline;
}
5 changes: 5 additions & 0 deletions src/test/shell/integration/aquery_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ EOF
else
assert_contains "Command Line: (" output
fi

assert_contains "echo unused" output
bazel aquery --noinclude_commandline "//$pkg:bar" > output \
2> "$TEST_log" || fail "Expected success"
assert_not_contains "echo unused" output
}

function test_aquery_skylark_env() {
Expand Down

0 comments on commit 2217614

Please sign in to comment.