Search in sources :

Example 1 with BuildCompleteEvent

use of com.google.devtools.build.lib.buildtool.buildevent.BuildCompleteEvent 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());
}
Also used : GenericBuildEvent(com.google.devtools.build.lib.buildeventstream.GenericBuildEvent) BuildResult(com.google.devtools.build.lib.buildtool.BuildResult) BuildEventId(com.google.devtools.build.lib.buildeventstream.BuildEventId) BuildEvent(com.google.devtools.build.lib.buildeventstream.BuildEvent) GenericBuildEvent(com.google.devtools.build.lib.buildeventstream.GenericBuildEvent) BuildCompleteEvent(com.google.devtools.build.lib.buildtool.buildevent.BuildCompleteEvent) Test(org.junit.Test)

Example 2 with BuildCompleteEvent

use of com.google.devtools.build.lib.buildtool.buildevent.BuildCompleteEvent in project bazel by bazelbuild.

the class BuildEventStreamer method buildEvent.

@Subscribe
public void buildEvent(BuildEvent event) {
    if (isActionWithoutError(event) || bufferUntilPrerequisitesReceived(event)) {
        return;
    }
    post(event);
    // Reconsider all events blocked by the event just posted.
    Collection<BuildEvent> toReconsider = pendingEvents.removeAll(event.getEventId());
    for (BuildEvent freedEvent : toReconsider) {
        buildEvent(freedEvent);
    }
    if (event instanceof BuildCompleteEvent) {
        buildComplete();
    }
}
Also used : BuildEvent(com.google.devtools.build.lib.buildeventstream.BuildEvent) NoBuildEvent(com.google.devtools.build.lib.analysis.NoBuildEvent) BuildCompleteEvent(com.google.devtools.build.lib.buildtool.buildevent.BuildCompleteEvent) Subscribe(com.google.common.eventbus.Subscribe)

Example 3 with BuildCompleteEvent

use of com.google.devtools.build.lib.buildtool.buildevent.BuildCompleteEvent in project bazel by bazelbuild.

the class BuildTool method stopRequest.

/**
   * Stops processing the specified request.
   *
   * <p>This logs the build result, cleans up and stops the clock.
   *
   * @param crash Any unexpected RuntimeException or Error. May be null
   * @param exitCondition A suggested exit condition from either the build logic or
   *        a thrown exception somewhere along the way.
   */
public void stopRequest(BuildResult result, Throwable crash, ExitCode exitCondition) {
    Preconditions.checkState((crash == null) || !exitCondition.equals(ExitCode.SUCCESS));
    result.setUnhandledThrowable(crash);
    result.setExitCondition(exitCondition);
    // The stop time has to be captured before we send the BuildCompleteEvent.
    result.setStopTime(runtime.getClock().currentTimeMillis());
    env.getEventBus().post(new BuildCompleteEvent(result));
}
Also used : BuildCompleteEvent(com.google.devtools.build.lib.buildtool.buildevent.BuildCompleteEvent)

Example 4 with BuildCompleteEvent

use of com.google.devtools.build.lib.buildtool.buildevent.BuildCompleteEvent 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);
}
Also used : GenericBuildEvent(com.google.devtools.build.lib.buildeventstream.GenericBuildEvent) BuildResult(com.google.devtools.build.lib.buildtool.BuildResult) BuildEvent(com.google.devtools.build.lib.buildeventstream.BuildEvent) GenericBuildEvent(com.google.devtools.build.lib.buildeventstream.GenericBuildEvent) BuildCompleteEvent(com.google.devtools.build.lib.buildtool.buildevent.BuildCompleteEvent) BuildEventWithOrderConstraint(com.google.devtools.build.lib.buildeventstream.BuildEventWithOrderConstraint) Test(org.junit.Test)

Example 5 with BuildCompleteEvent

use of com.google.devtools.build.lib.buildtool.buildevent.BuildCompleteEvent 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());
}
Also used : GenericBuildEvent(com.google.devtools.build.lib.buildeventstream.GenericBuildEvent) BuildResult(com.google.devtools.build.lib.buildtool.BuildResult) BuildEvent(com.google.devtools.build.lib.buildeventstream.BuildEvent) GenericBuildEvent(com.google.devtools.build.lib.buildeventstream.GenericBuildEvent) BuildCompleteEvent(com.google.devtools.build.lib.buildtool.buildevent.BuildCompleteEvent) Test(org.junit.Test)

Aggregations

BuildCompleteEvent (com.google.devtools.build.lib.buildtool.buildevent.BuildCompleteEvent)5 BuildEvent (com.google.devtools.build.lib.buildeventstream.BuildEvent)4 GenericBuildEvent (com.google.devtools.build.lib.buildeventstream.GenericBuildEvent)3 BuildResult (com.google.devtools.build.lib.buildtool.BuildResult)3 Test (org.junit.Test)3 Subscribe (com.google.common.eventbus.Subscribe)1 NoBuildEvent (com.google.devtools.build.lib.analysis.NoBuildEvent)1 BuildEventId (com.google.devtools.build.lib.buildeventstream.BuildEventId)1 BuildEventWithOrderConstraint (com.google.devtools.build.lib.buildeventstream.BuildEventWithOrderConstraint)1