Skip to content

Commit

Permalink
Add flag to skip printing specific aspects in build results
Browse files Browse the repository at this point in the history
We have an internal system which tacks an aspect onto all the builds it runs,
but no one really cares about the aspect's outputs, just that with the default
--show_result their normal results are suppressed. This lets us avoid that.

There are a few ways we could have implemented this, I decided to go with the
simplest - non-repeated flag with comma-separated values. Practically, we could
evolve this to allow multiple and do something like we do with --output_group
with adding/subtracting from the existing/default, but we can cross that bridge
when/if we get there.

PiperOrigin-RevId: 603229525
Change-Id: I8b1a387eeb7e67cceaf4f8e821bd29c12b136982
  • Loading branch information
michajlo authored and fbenkstein-db committed Jan 8, 2025
1 parent 4530ad2 commit 3bd39b2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,18 @@ public class BuildRequestOptions extends OptionsBase {
+ " under the threshold.")
public int maxResultTargets;

@Option(
name = "hide_aspect_results",
converter = Converters.CommaSeparatedOptionListConverter.class,
defaultValue = "",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.TERMINAL_OUTPUT},
help =
"Comma-separated list of aspect names to not display in results (see --show_result). "
+ "Useful for keeping aspects added by wrappers which are typically not interesting "
+ "to end users out of console output.")
public List<String> hideAspectResults;

@Option(
name = "symlink_prefix",
defaultValue = "null",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,15 @@ private boolean outputTargets(
// Splits aspects based on whether they are validation aspects.
final ImmutableSet<AspectKey> aspectsToPrint;
final ImmutableList<AspectKey> validationAspects;
final ImmutableSet<String> aspectsToIgnore =
ImmutableSet.copyOf(request.getBuildOptions().hideAspectResults);
final ImmutableSet<AspectKey> filteredAspects = aspects.keySet().stream()
.filter(k -> !aspectsToIgnore.contains(k.getAspectClass().getName()))
.collect(ImmutableSet.toImmutableSet());
if (request.useValidationAspect()) {
var aspectsToPrintBuilder = ImmutableSet.<AspectKey>builder();
var validationAspectsBuilder = ImmutableList.<AspectKey>builder();
for (AspectKey key : aspects.keySet()) {
for (AspectKey key : filteredAspects) {
if (Objects.equals(
key.getAspectClass().getName(), AspectCollection.VALIDATION_ASPECT_NAME)) {
validationAspectsBuilder.add(key);
Expand All @@ -116,7 +121,7 @@ private boolean outputTargets(
aspectsToPrint = aspectsToPrintBuilder.build();
validationAspects = validationAspectsBuilder.build();
} else {
aspectsToPrint = aspects.keySet();
aspectsToPrint = filteredAspects;
validationAspects = ImmutableList.of();
}

Expand Down

0 comments on commit 3bd39b2

Please sign in to comment.