Search in sources :

Example 11 with ActionStartedEvent

use of com.google.devtools.build.lib.actions.ActionStartedEvent in project bazel by bazelbuild.

the class ExperimentalStateTrackerTest method testCompletedActionNotShown.

@Test
public void testCompletedActionNotShown() throws IOException {
    // Completed actions should not be reported in the progress bar, nor in the
    // short progress bar.
    String messageFast = "Running quick action";
    String messageSlow = "Running slow action";
    ManualClock clock = new ManualClock();
    clock.advanceMillis(120000);
    Action fastAction = mockAction(messageFast, "foo/fast");
    Action slowAction = mockAction(messageSlow, "bar/slow");
    ExperimentalStateTracker stateTracker = new ExperimentalStateTracker(clock);
    stateTracker.actionStarted(new ActionStartedEvent(fastAction, 123456789));
    stateTracker.actionStarted(new ActionStartedEvent(slowAction, 123456999));
    stateTracker.actionCompletion(new ActionCompletionEvent(20, fastAction));
    LoggingTerminalWriter terminalWriter = new LoggingTerminalWriter(/*discardHighlight=*/
    true);
    stateTracker.writeProgressBar(terminalWriter);
    String output = terminalWriter.getTranscript();
    assertFalse("Completed action '" + messageFast + "' should not be present in output: " + output, output.contains(messageFast));
    assertTrue("Only running action '" + messageSlow + "' should be present in output: " + output, output.contains(messageSlow));
    terminalWriter = new LoggingTerminalWriter();
    stateTracker.writeProgressBar(terminalWriter, /* shortVersion=*/
    true);
    output = terminalWriter.getTranscript();
    assertFalse("Completed action '" + messageFast + "' should not be present in short output: " + output, output.contains(messageFast));
    assertTrue("Only running action '" + messageSlow + "' should be present in short output: " + output, output.contains(messageSlow));
}
Also used : ManualClock(com.google.devtools.build.lib.testutil.ManualClock) Action(com.google.devtools.build.lib.actions.Action) ActionStartedEvent(com.google.devtools.build.lib.actions.ActionStartedEvent) ActionCompletionEvent(com.google.devtools.build.lib.actions.ActionCompletionEvent) LoggingTerminalWriter(com.google.devtools.build.lib.util.io.LoggingTerminalWriter) Test(org.junit.Test)

Aggregations

ActionStartedEvent (com.google.devtools.build.lib.actions.ActionStartedEvent)11 ManualClock (com.google.devtools.build.lib.testutil.ManualClock)10 LoggingTerminalWriter (com.google.devtools.build.lib.util.io.LoggingTerminalWriter)9 Test (org.junit.Test)9 Action (com.google.devtools.build.lib.actions.Action)5 ActionOwner (com.google.devtools.build.lib.actions.ActionOwner)3 Label (com.google.devtools.build.lib.cmdline.Label)3 ActionCompletionEvent (com.google.devtools.build.lib.actions.ActionCompletionEvent)2 ConfiguredTarget (com.google.devtools.build.lib.analysis.ConfiguredTarget)2 TestFilteringCompleteEvent (com.google.devtools.build.lib.buildtool.buildevent.TestFilteringCompleteEvent)2 ActionExecutionMetadata (com.google.devtools.build.lib.actions.ActionExecutionMetadata)1 ActionExecutionStatusReporter (com.google.devtools.build.lib.actions.ActionExecutionStatusReporter)1 Artifact (com.google.devtools.build.lib.actions.Artifact)1 Path (com.google.devtools.build.lib.vfs.Path)1 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)1 IOException (java.io.IOException)1