use of com.google.devtools.build.lib.buildeventstream.BuildEvent in project bazel by bazelbuild.
the class BuildEventStreamerTest method testReferPastEvent.
@Test
public void testReferPastEvent() {
// Verify that, if an event is refers to a previously done event, that duplicated
// late-referenced event is not expected again.
RecordingBuildEventTransport transport = new RecordingBuildEventTransport();
BuildEventStreamer streamer = new BuildEventStreamer(ImmutableSet.<BuildEventTransport>of(transport));
BuildEvent startEvent = new GenericBuildEvent(testId("Initial"), ImmutableSet.<BuildEventId>of(ProgressEvent.INITIAL_PROGRESS_UPDATE, BuildEventId.buildFinished()));
BuildEvent earlyEvent = new GenericBuildEvent(testId("unexpected"), ImmutableSet.<BuildEventId>of());
BuildEvent lateReference = new GenericBuildEvent(testId("late reference"), ImmutableSet.of(earlyEvent.getEventId()));
streamer.buildEvent(startEvent);
streamer.buildEvent(earlyEvent);
streamer.buildEvent(lateReference);
streamer.buildEvent(new BuildCompleteEvent(new BuildResult(0)));
List<BuildEvent> eventsSeen = transport.getEvents();
int earlyEventCount = 0;
for (BuildEvent event : eventsSeen) {
if (event.getEventId().equals(earlyEvent.getEventId())) {
earlyEventCount++;
}
}
// The early event should be reported precisely once.
assertEquals(1, earlyEventCount);
}
use of com.google.devtools.build.lib.buildeventstream.BuildEvent in project bazel by bazelbuild.
the class BuildEventStreamerTest method testSimpleStream.
@Test
public void testSimpleStream() {
// Verify that a well-formed event is passed through and that completion of the
// build clears the pending progress-update event.
RecordingBuildEventTransport transport = new RecordingBuildEventTransport();
BuildEventStreamer streamer = new BuildEventStreamer(ImmutableSet.<BuildEventTransport>of(transport));
BuildEvent startEvent = new GenericBuildEvent(testId("Initial"), ImmutableSet.of(ProgressEvent.INITIAL_PROGRESS_UPDATE, BuildEventId.buildFinished()));
streamer.buildEvent(startEvent);
List<BuildEvent> afterFirstEvent = transport.getEvents();
assertThat(afterFirstEvent).hasSize(1);
assertEquals(startEvent.getEventId(), afterFirstEvent.get(0).getEventId());
streamer.buildEvent(new BuildCompleteEvent(new BuildResult(0)));
List<BuildEvent> finalStream = transport.getEvents();
assertThat(finalStream).hasSize(3);
assertEquals(BuildEventId.buildFinished(), finalStream.get(1).getEventId());
assertEquals(ProgressEvent.INITIAL_PROGRESS_UPDATE, finalStream.get(2).getEventId());
}
use of com.google.devtools.build.lib.buildeventstream.BuildEvent 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