Skip to content

Commit e3c78c4

Browse files
justinhorvitzcopybara-github
authored andcommitted
Ensure that test status artifacts are reported as top-level artifacts.
PiperOrigin-RevId: 373218930
1 parent f572d3b commit e3c78c4

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/main/java/com/google/devtools/build/lib/analysis/TopLevelArtifactHelper.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414

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

17-
import static com.google.common.base.MoreObjects.firstNonNull;
1817
import static com.google.common.base.Preconditions.checkNotNull;
1918

2019
import com.google.common.collect.ImmutableList;
2120
import com.google.common.collect.ImmutableMap;
2221
import com.google.common.collect.ImmutableSet;
2322
import com.google.common.collect.Iterables;
2423
import com.google.devtools.build.lib.actions.Artifact;
24+
import com.google.devtools.build.lib.analysis.test.TestProvider;
2525
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
2626
import com.google.devtools.build.lib.collect.nestedset.NestedSet.Node;
2727
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
@@ -137,20 +137,24 @@ public static ImmutableSet<Artifact> findAllTopLevelArtifacts(AnalysisResult ana
137137
ImmutableSet.Builder<Artifact> artifacts = ImmutableSet.builder();
138138
artifacts.addAll(analysisResult.getArtifactsToBuild());
139139

140-
Iterable<ProviderCollection> providers =
141-
Iterables.concat(
142-
analysisResult.getTargetsToBuild(),
143-
analysisResult.getAspectsMap().values(),
144-
firstNonNull(analysisResult.getTargetsToTest(), ImmutableList.of()));
145140
TopLevelArtifactContext ctx = analysisResult.getTopLevelContext();
146141
Set<NestedSet.Node> visited = new HashSet<>();
147142

148-
for (ProviderCollection provider : providers) {
143+
for (ProviderCollection provider :
144+
Iterables.concat(
145+
analysisResult.getTargetsToBuild(), analysisResult.getAspectsMap().values())) {
149146
for (ArtifactsInOutputGroup group :
150147
getAllArtifactsToBuild(provider, ctx).getAllArtifactsByOutputGroup().values()) {
151148
memoizedAddAll(group.getArtifacts(), artifacts, visited);
152149
}
153150
}
151+
152+
if (analysisResult.getTargetsToTest() != null) {
153+
for (ConfiguredTarget testTarget : analysisResult.getTargetsToTest()) {
154+
artifacts.addAll(TestProvider.getTestStatusArtifacts(testTarget));
155+
}
156+
}
157+
154158
return artifacts.build();
155159
}
156160
}

0 commit comments

Comments
 (0)