aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/runtime
diff options
context:
space:
mode:
authorGravatar Klaus Aehlig <aehlig@google.com>2016-11-02 17:24:46 +0000
committerGravatar Laszlo Csomor <laszlocsomor@google.com>2016-11-02 17:28:04 +0000
commit8d25362bcb49286feb546b306657b6453712f2b3 (patch)
tree1969c243185b72476f22d6d4f22b511a269b6c78 /src/main/java/com/google/devtools/build/lib/runtime
parent2d431b4a80cb702a6538864db762e0956251c0a4 (diff)
Also provide test summaries in the build-event stream
For each test target, also have a test summary as children to this event. As test summaries are posted on the event bus anyway, it is enough to make then an instance of BuildEvent. -- Change-Id: Id53e5f1760548a1fa621b1667fdb4470f51a52e8 Reviewed-on: https://bazel-review.googlesource.com/#/c/6931 MOS_MIGRATED_REVID=137961100
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/runtime')
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/TestSummary.java42
1 files changed, 35 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/TestSummary.java b/src/main/java/com/google/devtools/build/lib/runtime/TestSummary.java
index b7fb391c94..5b78bef4ff 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/TestSummary.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/TestSummary.java
@@ -20,29 +20,32 @@ import com.google.common.collect.Multimap;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import com.google.devtools.build.lib.analysis.FilesToRunProvider;
+import com.google.devtools.build.lib.buildeventstream.BuildEvent;
+import com.google.devtools.build.lib.buildeventstream.BuildEventId;
+import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos;
+import com.google.devtools.build.lib.buildeventstream.GenericBuildEvent;
import com.google.devtools.build.lib.util.Preconditions;
import com.google.devtools.build.lib.util.io.AnsiTerminalPrinter.Mode;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.view.test.TestStatus.BlazeTestStatus;
import com.google.devtools.build.lib.view.test.TestStatus.FailedTestCasesStatus;
import com.google.devtools.build.lib.view.test.TestStatus.TestCase;
-
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
/**
- * Test summary entry. Stores summary information for a single test rule.
- * Also used to sort summary output by status.
+ * Test summary entry. Stores summary information for a single test rule. Also used to sort summary
+ * output by status.
*
- * <p>Invariant:
- * All TestSummary mutations should be performed through the Builder.
- * No direct TestSummary methods (except the constructor) may mutate the object.
+ * <p>Invariant: All TestSummary mutations should be performed through the Builder. No direct
+ * TestSummary methods (except the constructor) may mutate the object.
*/
@VisibleForTesting // Ideally package-scoped.
-public class TestSummary implements Comparable<TestSummary> {
+public class TestSummary implements Comparable<TestSummary>, BuildEvent {
/**
* Builder class responsible for creating and altering TestSummary objects.
*/
@@ -446,4 +449,29 @@ public class TestSummary implements Comparable<TestSummary> {
? Mode.INFO
: (status == BlazeTestStatus.FLAKY ? Mode.WARNING : Mode.ERROR);
}
+
+ @Override
+ public BuildEventId getEventId() {
+ return BuildEventId.testSummary(target.getTarget().getLabel());
+ }
+
+ @Override
+ public Collection<BuildEventId> getChildrenEvents() {
+ return ImmutableList.of();
+ }
+
+ @Override
+ public BuildEventStreamProtos.BuildEvent asStreamProto() {
+ BuildEventStreamProtos.TestSummary.Builder summaryBuilder =
+ BuildEventStreamProtos.TestSummary.newBuilder().setTotalRunCount(totalRuns());
+ for (Path path : getFailedLogs()) {
+ summaryBuilder.addFailed(
+ BuildEventStreamProtos.File.newBuilder().setUri(path.toString()).build());
+ }
+ for (Path path : getPassedLogs()) {
+ summaryBuilder.addPassed(
+ BuildEventStreamProtos.File.newBuilder().setUri(path.toString()).build());
+ }
+ return GenericBuildEvent.protoChaining(this).setTestSummary(summaryBuilder.build()).build();
+ }
}