aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Klaus Aehlig <aehlig@google.com>2018-02-07 05:37:56 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-02-07 05:39:26 -0800
commite00dc41957a75099780988157ae5bed751cc4e13 (patch)
tree482abc9c1f89940059ece9e611eb96f62a4105f6 /src
parent2db45c7a0c0ecae16f4faa3acc2fcaff9b95ee88 (diff)
BEP: ensure that TestAttempts are reported after their target
Ensure that each test attempt is only reported after the report of the completion of the build of the corresponding test target. Normally this should happen anyway, but due to races on the internal event bus, the order of the report might be messed up. So add an explicit order constraint. Change-Id: I4d325bc31a46dcdf8763ba5416b5135a0978536e PiperOrigin-RevId: 184825306
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/exec/TestAttempt.java11
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/TestSummary.java11
2 files changed, 18 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/exec/TestAttempt.java b/src/main/java/com/google/devtools/build/lib/exec/TestAttempt.java
index 9c8c62d048..ac9c7b3a9f 100644
--- a/src/main/java/com/google/devtools/build/lib/exec/TestAttempt.java
+++ b/src/main/java/com/google/devtools/build/lib/exec/TestAttempt.java
@@ -19,10 +19,10 @@ import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.test.TestResult;
import com.google.devtools.build.lib.analysis.test.TestRunnerAction;
-import com.google.devtools.build.lib.buildeventstream.BuildEvent;
import com.google.devtools.build.lib.buildeventstream.BuildEventConverters;
import com.google.devtools.build.lib.buildeventstream.BuildEventId;
import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos;
+import com.google.devtools.build.lib.buildeventstream.BuildEventWithOrderConstraint;
import com.google.devtools.build.lib.buildeventstream.GenericBuildEvent;
import com.google.devtools.build.lib.buildeventstream.PathConverter;
import com.google.devtools.build.lib.runtime.BuildEventStreamerUtils;
@@ -34,7 +34,7 @@ import java.util.Collection;
import java.util.List;
/** This event is raised whenever an individual test attempt is completed. */
-public class TestAttempt implements BuildEvent {
+public class TestAttempt implements BuildEventWithOrderConstraint {
private final TestRunnerAction testAction;
private final BlazeTestStatus status;
@@ -154,6 +154,13 @@ public class TestAttempt implements BuildEvent {
}
@Override
+ public Collection<BuildEventId> postedAfter() {
+ return ImmutableList.of(
+ BuildEventId.targetCompleted(
+ testAction.getOwner().getLabel(), testAction.getConfiguration().getEventId()));
+ }
+
+ @Override
public Collection<BuildEventId> getChildrenEvents() {
if (lastAttempt) {
return ImmutableList.of();
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 ea7fe04ff2..da47d3ce90 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
@@ -22,10 +22,10 @@ import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder;
import com.google.devtools.build.lib.analysis.AliasProvider;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
-import com.google.devtools.build.lib.buildeventstream.BuildEvent;
import com.google.devtools.build.lib.buildeventstream.BuildEventConverters;
import com.google.devtools.build.lib.buildeventstream.BuildEventId;
import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos;
+import com.google.devtools.build.lib.buildeventstream.BuildEventWithOrderConstraint;
import com.google.devtools.build.lib.buildeventstream.GenericBuildEvent;
import com.google.devtools.build.lib.buildeventstream.PathConverter;
import com.google.devtools.build.lib.cmdline.Label;
@@ -49,7 +49,7 @@ import java.util.TreeMap;
* TestSummary methods (except the constructor) may mutate the object.
*/
@VisibleForTesting // Ideally package-scoped.
-public class TestSummary implements Comparable<TestSummary>, BuildEvent {
+public class TestSummary implements Comparable<TestSummary>, BuildEventWithOrderConstraint {
/**
* Builder class responsible for creating and altering TestSummary objects.
*/
@@ -468,6 +468,13 @@ public class TestSummary implements Comparable<TestSummary>, BuildEvent {
}
@Override
+ public Collection<BuildEventId> postedAfter() {
+ return ImmutableList.of(
+ BuildEventId.targetCompleted(
+ AliasProvider.getDependencyLabel(target), target.getConfiguration().getEventId()));
+ }
+
+ @Override
public BuildEventStreamProtos.BuildEvent asStreamProto(BuildEventConverters converters) {
PathConverter pathConverter = converters.pathConverter();
BuildEventStreamProtos.TestSummary.Builder summaryBuilder =