use of com.google.devtools.build.lib.buildeventstream.BuildEventId in project bazel by bazelbuild.
the class BuildEventStreamerTest method testMissingPrerequisits.
@Test
public void testMissingPrerequisits() {
// Verify that an event where the prerequisite is never coming till the end of
// the build still gets posted, with the prerequisite aborted.
RecordingBuildEventTransport transport = new RecordingBuildEventTransport();
BuildEventStreamer streamer = new BuildEventStreamer(ImmutableSet.<BuildEventTransport>of(transport));
BuildEventId expectedId = testId("the target");
BuildEvent startEvent = new GenericBuildEvent(testId("Initial"), ImmutableSet.<BuildEventId>of(ProgressEvent.INITIAL_PROGRESS_UPDATE, expectedId, BuildEventId.buildFinished()));
BuildEventId rootCauseId = testId("failure event");
BuildEvent failedTarget = new GenericOrderEvent(expectedId, ImmutableSet.<BuildEventId>of(rootCauseId));
streamer.buildEvent(startEvent);
streamer.buildEvent(failedTarget);
streamer.buildEvent(new BuildCompleteEvent(new BuildResult(0)));
List<BuildEvent> allEventsSeen = transport.getEvents();
assertThat(allEventsSeen).hasSize(6);
assertEquals(startEvent.getEventId(), allEventsSeen.get(0).getEventId());
assertEquals(BuildEventId.buildFinished(), allEventsSeen.get(1).getEventId());
BuildEvent linkEvent = allEventsSeen.get(2);
assertEquals(ProgressEvent.INITIAL_PROGRESS_UPDATE, linkEvent.getEventId());
assertEquals(rootCauseId, allEventsSeen.get(3).getEventId());
assertEquals(failedTarget.getEventId(), allEventsSeen.get(4).getEventId());
}
use of com.google.devtools.build.lib.buildeventstream.BuildEventId in project bazel by bazelbuild.
the class BuildEventStreamer method post.
/**
* Post a new event to all transports; simultaneously keep track of the events we announce to
* still come.
*
* <p>Moreover, link unannounced events to the progress stream; we only expect failure events to
* come before their parents.
*/
private void post(BuildEvent event) {
BuildEvent linkEvent = null;
BuildEventId id = event.getEventId();
synchronized (this) {
if (announcedEvents == null) {
announcedEvents = new HashSet<>();
postedEvents = new HashSet<>();
if (!event.getChildrenEvents().contains(ProgressEvent.INITIAL_PROGRESS_UPDATE)) {
linkEvent = ProgressEvent.progressChainIn(progressCount, event.getEventId());
progressCount++;
announcedEvents.addAll(linkEvent.getChildrenEvents());
postedEvents.add(linkEvent.getEventId());
}
} else {
if (!announcedEvents.contains(id)) {
linkEvent = ProgressEvent.progressChainIn(progressCount, id);
progressCount++;
announcedEvents.addAll(linkEvent.getChildrenEvents());
postedEvents.add(linkEvent.getEventId());
}
postedEvents.add(id);
}
announcedEvents.addAll(event.getChildrenEvents());
}
for (BuildEventTransport transport : transports) {
try {
if (linkEvent != null) {
transport.sendBuildEvent(linkEvent);
}
transport.sendBuildEvent(event);
} catch (IOException e) {
// TODO(aehlig): signal that the build ought to be aborted
log.severe("Failed to write to build event transport: " + e);
}
}
}
use of com.google.devtools.build.lib.buildeventstream.BuildEventId in project bazel by bazelbuild.
the class BuildEventStreamer method clearPendingEvents.
/** Clear pending events by generating aborted events for all their requisits. */
private void clearPendingEvents() {
while (!pendingEvents.isEmpty()) {
BuildEventId id = pendingEvents.keySet().iterator().next();
buildEvent(new AbortedEvent(id, abortReason, ""));
}
}
use of com.google.devtools.build.lib.buildeventstream.BuildEventId in project bazel by bazelbuild.
the class BuildEventStreamerTest method testReodering.
@Test
public void testReodering() {
// Verify that an event requiring to be posted after another one is indeed.
RecordingBuildEventTransport transport = new RecordingBuildEventTransport();
BuildEventStreamer streamer = new BuildEventStreamer(ImmutableSet.<BuildEventTransport>of(transport));
BuildEventId expectedId = testId("the target");
BuildEvent startEvent = new GenericBuildEvent(testId("Initial"), ImmutableSet.<BuildEventId>of(ProgressEvent.INITIAL_PROGRESS_UPDATE, expectedId));
BuildEvent rootCause = new GenericBuildEvent(testId("failure event"), ImmutableSet.<BuildEventId>of());
BuildEvent failedTarget = new GenericOrderEvent(expectedId, ImmutableSet.<BuildEventId>of(rootCause.getEventId()));
streamer.buildEvent(startEvent);
streamer.buildEvent(failedTarget);
streamer.buildEvent(rootCause);
List<BuildEvent> allEventsSeen = transport.getEvents();
assertThat(allEventsSeen).hasSize(4);
assertEquals(startEvent.getEventId(), allEventsSeen.get(0).getEventId());
BuildEvent linkEvent = allEventsSeen.get(1);
assertEquals(ProgressEvent.INITIAL_PROGRESS_UPDATE, linkEvent.getEventId());
assertEquals(rootCause.getEventId(), allEventsSeen.get(2).getEventId());
assertEquals(failedTarget.getEventId(), allEventsSeen.get(3).getEventId());
}
Aggregations