aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/test/TestAttempt.java
diff options
context:
space:
mode:
authorGravatar Klaus Aehlig <aehlig@google.com>2017-02-10 14:36:43 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2017-02-10 15:37:00 +0000
commit89512a7cbc4ff5d25415fc87b5d5d050452fa195 (patch)
treecbb48259566d852b85e39de1ee41061bd6d3fb5d /src/main/java/com/google/devtools/build/lib/rules/test/TestAttempt.java
parent733f4c76cabe086b3ff544b915bae202dd183383 (diff)
BEP: Provide more useful data in TestResult events
For individual test actions, more useful data can be provided than just the success status. Do so. Also, to keep each log reported only once, send a new TestAttempt event for the final test attempt, but don't have the TestResult (which contains to union of all test files) an instance of the BuildEvent. As we now report test results in a separate object, drop the test data and directly pass in the files created. In this way, we also get all the moved files reported correctly in the individual attempts. -- Change-Id: Ic04b7bad4f92a381bd4d1b4ec91f743b89f81f84 Reviewed-on: https://cr.bazel.build/8694 PiperOrigin-RevId: 147149025 MOS_MIGRATED_REVID=147149025
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/test/TestAttempt.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/test/TestAttempt.java56
1 files changed, 43 insertions, 13 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/test/TestAttempt.java b/src/main/java/com/google/devtools/build/lib/rules/test/TestAttempt.java
index dc076b7adb..0364c731ec 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/test/TestAttempt.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/test/TestAttempt.java
@@ -20,16 +20,18 @@ 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.buildeventstream.PathConverter;
+import com.google.devtools.build.lib.util.Pair;
+import com.google.devtools.build.lib.vfs.Path;
import java.util.Collection;
-/**
- * This event is raised whenever a an individual test attempt is completed that is not the final
- * attempt for the given test, shard, and run.
- */
+/** This event is raised whenever a an individual test attempt is completed. */
public class TestAttempt implements BuildEvent {
private final TestRunnerAction testAction;
+ private final boolean success;
private final int attempt;
+ private final boolean lastAttempt;
+ private final Collection<Pair<String, Path>> files;
/**
* Construct the event given the test action and attempt number.
@@ -37,9 +39,25 @@ public class TestAttempt implements BuildEvent {
* @param testAction The test that was run.
* @param attempt The number of the attempt for this action.
*/
- public TestAttempt(TestRunnerAction testAction, Integer attempt) {
+ public TestAttempt(
+ TestRunnerAction testAction,
+ Integer attempt,
+ boolean success,
+ Collection<Pair<String, Path>> files,
+ boolean lastAttempt) {
this.testAction = testAction;
this.attempt = attempt;
+ this.success = success;
+ this.files = files;
+ this.lastAttempt = lastAttempt;
+ }
+
+ public TestAttempt(
+ TestRunnerAction testAction,
+ Integer attempt,
+ boolean success,
+ Collection<Pair<String, Path>> files) {
+ this(testAction, attempt, success, files, false);
}
@Override
@@ -53,18 +71,30 @@ public class TestAttempt implements BuildEvent {
@Override
public Collection<BuildEventId> getChildrenEvents() {
- return ImmutableList.of(
- BuildEventId.testResult(
- testAction.getOwner().getLabel(),
- testAction.getRunNumber(),
- testAction.getShardNum(),
- attempt + 1));
+ if (lastAttempt) {
+ return ImmutableList.of();
+ } else {
+ return ImmutableList.of(
+ BuildEventId.testResult(
+ testAction.getOwner().getLabel(),
+ testAction.getRunNumber(),
+ testAction.getShardNum(),
+ attempt + 1));
+ }
}
@Override
public BuildEventStreamProtos.BuildEvent asStreamProto(PathConverter pathConverter) {
- BuildEventStreamProtos.TestResult.Builder resultBuilder =
+ BuildEventStreamProtos.TestResult.Builder builder =
BuildEventStreamProtos.TestResult.newBuilder();
- return GenericBuildEvent.protoChaining(this).setTestResult(resultBuilder.build()).build();
+ builder.setSuccess(success);
+ for (Pair<String, Path> file : files) {
+ builder.addTestActionOutput(
+ BuildEventStreamProtos.File.newBuilder()
+ .setName(file.getFirst())
+ .setUri(pathConverter.apply(file.getSecond()))
+ .build());
+ }
+ return GenericBuildEvent.protoChaining(this).setTestResult(builder.build()).build();
}
}