Also report individual test results via BEP
Only having a test summary for each test target is not enough for timely
error reporting. Also individual test actions and attempts are of interest.
Report those by making TestResult an instance of BuildEvent.
--
Change-Id: Iee1c988b6d467ebda8230b9edacbe3b66600c30e
Reviewed-on: https://cr.bazel.build/8532
PiperOrigin-RevId: 146342845
MOS_MIGRATED_REVID=146342845
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/TargetCompleteEvent.java b/src/main/java/com/google/devtools/build/lib/analysis/TargetCompleteEvent.java
index b4cd606..971c003 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/TargetCompleteEvent.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/TargetCompleteEvent.java
@@ -22,9 +22,11 @@
import com.google.devtools.build.lib.buildeventstream.GenericBuildEvent;
import com.google.devtools.build.lib.buildeventstream.PathConverter;
import com.google.devtools.build.lib.causes.Cause;
+import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.collect.nestedset.Order;
+import com.google.devtools.build.lib.rules.test.TestProvider;
import com.google.devtools.build.lib.util.Preconditions;
import com.google.devtools.build.skyframe.SkyValue;
import java.util.Collection;
@@ -101,7 +103,17 @@
childrenBuilder.add(BuildEventId.fromCause(cause));
}
if (isTest) {
- childrenBuilder.add(BuildEventId.testSummary(target.getTarget().getLabel()));
+ // For tests, announce all the test actions that will minimally happen (except for
+ // interruption). If after the result of a test action another attempt is necessary,
+ // it will be announced with the action that made the new attempt necessary.
+ Label label = target.getTarget().getLabel();
+ TestProvider.TestParams params = target.getProvider(TestProvider.class).getTestParams();
+ for (int run = 0; run < Math.max(params.getRuns(), 1); run++) {
+ for (int shard = 0; shard < Math.max(params.getShards(), 1); shard++) {
+ childrenBuilder.add(BuildEventId.testResult(label, run, shard));
+ }
+ }
+ childrenBuilder.add(BuildEventId.testSummary(label));
}
return childrenBuilder.build();
}