Skip to content

Commit

Permalink
Ensure that test status artifacts are reported as top-level artifacts.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 373218930
  • Loading branch information
justinhorvitz authored and Copybara-Service committed May 11, 2021
1 parent f572d3b commit e3c78c4
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

package com.google.devtools.build.lib.analysis;

import static com.google.common.base.MoreObjects.firstNonNull;
import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.test.TestProvider;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSet.Node;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
Expand Down Expand Up @@ -137,20 +137,24 @@ public static ImmutableSet<Artifact> findAllTopLevelArtifacts(AnalysisResult ana
ImmutableSet.Builder<Artifact> artifacts = ImmutableSet.builder();
artifacts.addAll(analysisResult.getArtifactsToBuild());

Iterable<ProviderCollection> providers =
Iterables.concat(
analysisResult.getTargetsToBuild(),
analysisResult.getAspectsMap().values(),
firstNonNull(analysisResult.getTargetsToTest(), ImmutableList.of()));
TopLevelArtifactContext ctx = analysisResult.getTopLevelContext();
Set<NestedSet.Node> visited = new HashSet<>();

for (ProviderCollection provider : providers) {
for (ProviderCollection provider :
Iterables.concat(
analysisResult.getTargetsToBuild(), analysisResult.getAspectsMap().values())) {
for (ArtifactsInOutputGroup group :
getAllArtifactsToBuild(provider, ctx).getAllArtifactsByOutputGroup().values()) {
memoizedAddAll(group.getArtifacts(), artifacts, visited);
}
}

if (analysisResult.getTargetsToTest() != null) {
for (ConfiguredTarget testTarget : analysisResult.getTargetsToTest()) {
artifacts.addAll(TestProvider.getTestStatusArtifacts(testTarget));
}
}

return artifacts.build();
}
}
Expand Down

0 comments on commit e3c78c4

Please sign in to comment.