Search in sources :

Example 11 with LoggingTerminalWriter

use of com.google.devtools.build.lib.util.io.LoggingTerminalWriter in project bazel by bazelbuild.

the class ExperimentalEventHandler method addProgressBar.

private synchronized void addProgressBar() throws IOException {
    LineCountingAnsiTerminalWriter countingTerminalWriter = new LineCountingAnsiTerminalWriter(terminal);
    AnsiTerminalWriter terminalWriter = countingTerminalWriter;
    lastRefreshMillis = clock.currentTimeMillis();
    if (cursorControl) {
        terminalWriter = new LineWrappingAnsiTerminalWriter(terminalWriter, terminalWidth - 1);
    }
    stateTracker.writeProgressBar(terminalWriter, /* shortVersion=*/
    !cursorControl);
    terminalWriter.newline();
    numLinesProgressBar = countingTerminalWriter.getWrittenLines();
    if (progressInTermTitle) {
        LoggingTerminalWriter stringWriter = new LoggingTerminalWriter(true);
        stateTracker.writeProgressBar(stringWriter, true);
        terminal.setTitle(stringWriter.getTranscript());
    }
}
Also used : LineCountingAnsiTerminalWriter(com.google.devtools.build.lib.util.io.LineCountingAnsiTerminalWriter) LineWrappingAnsiTerminalWriter(com.google.devtools.build.lib.util.io.LineWrappingAnsiTerminalWriter) LineCountingAnsiTerminalWriter(com.google.devtools.build.lib.util.io.LineCountingAnsiTerminalWriter) AnsiTerminalWriter(com.google.devtools.build.lib.util.io.AnsiTerminalWriter) LineWrappingAnsiTerminalWriter(com.google.devtools.build.lib.util.io.LineWrappingAnsiTerminalWriter) LoggingTerminalWriter(com.google.devtools.build.lib.util.io.LoggingTerminalWriter)

Example 12 with LoggingTerminalWriter

use of com.google.devtools.build.lib.util.io.LoggingTerminalWriter in project bazel by bazelbuild.

the class ExperimentalStateTrackerTest method testActionVisible.

@Test
public void testActionVisible() throws IOException {
    // If there is only one action running, it should be visible
    // somewhere in the progress bar, and also the short version thereof.
    String message = "Building foo";
    ManualClock clock = new ManualClock();
    clock.advanceMillis(120000);
    ExperimentalStateTracker stateTracker = new ExperimentalStateTracker(clock);
    stateTracker.actionStarted(new ActionStartedEvent(mockAction(message, "bar/foo"), 123456789));
    LoggingTerminalWriter terminalWriter = new LoggingTerminalWriter(/*discardHighlight=*/
    true);
    stateTracker.writeProgressBar(terminalWriter);
    String output = terminalWriter.getTranscript();
    assertTrue("Action message '" + message + "' should be present in output: " + output, output.contains(message));
    terminalWriter = new LoggingTerminalWriter();
    stateTracker.writeProgressBar(terminalWriter, /* shortVersion=*/
    true);
    output = terminalWriter.getTranscript();
    assertTrue("Action message '" + message + "' should be present in short output: " + output, output.contains(message));
}
Also used : ManualClock(com.google.devtools.build.lib.testutil.ManualClock) ActionStartedEvent(com.google.devtools.build.lib.actions.ActionStartedEvent) LoggingTerminalWriter(com.google.devtools.build.lib.util.io.LoggingTerminalWriter) Test(org.junit.Test)

Example 13 with LoggingTerminalWriter

use of com.google.devtools.build.lib.util.io.LoggingTerminalWriter in project bazel by bazelbuild.

the class ExperimentalStateTrackerTest method testPassedVisible.

@Test
public void testPassedVisible() throws Exception {
    // The last test should still be visible in the long status bar, and colored as ok if it passed.
    ManualClock clock = new ManualClock();
    ExperimentalStateTracker stateTracker = new ExperimentalStateTracker(clock);
    TestFilteringCompleteEvent filteringComplete = Mockito.mock(TestFilteringCompleteEvent.class);
    Label labelA = Label.parseAbsolute("//foo/bar:baz");
    ConfiguredTarget targetA = Mockito.mock(ConfiguredTarget.class);
    when(targetA.getLabel()).thenReturn(labelA);
    ConfiguredTarget targetB = Mockito.mock(ConfiguredTarget.class);
    when(filteringComplete.getTestTargets()).thenReturn(ImmutableSet.of(targetA, targetB));
    TestSummary testSummary = Mockito.mock(TestSummary.class);
    when(testSummary.getStatus()).thenReturn(BlazeTestStatus.PASSED);
    when(testSummary.getTarget()).thenReturn(targetA);
    stateTracker.testFilteringComplete(filteringComplete);
    stateTracker.testSummary(testSummary);
    LoggingTerminalWriter terminalWriter = new LoggingTerminalWriter();
    stateTracker.writeProgressBar(terminalWriter);
    String output = terminalWriter.getTranscript();
    String expected = LoggingTerminalWriter.OK + labelA;
    assertTrue("Sequence '" + expected + "' should be present in colored progress bar: " + output, output.contains(expected));
}
Also used : ManualClock(com.google.devtools.build.lib.testutil.ManualClock) Label(com.google.devtools.build.lib.cmdline.Label) ConfiguredTarget(com.google.devtools.build.lib.analysis.ConfiguredTarget) TestFilteringCompleteEvent(com.google.devtools.build.lib.buildtool.buildevent.TestFilteringCompleteEvent) LoggingTerminalWriter(com.google.devtools.build.lib.util.io.LoggingTerminalWriter) Test(org.junit.Test)

Example 14 with LoggingTerminalWriter

use of com.google.devtools.build.lib.util.io.LoggingTerminalWriter in project bazel by bazelbuild.

the class ExperimentalStateTrackerTest method testTimesShown.

@Test
public void testTimesShown() throws IOException {
    // For sufficiently long running actions, the time that has passed since their start is shown.
    // In the short version of the progress bar, this should be true at least for the oldest action.
    ManualClock clock = new ManualClock();
    clock.advanceMillis(TimeUnit.SECONDS.toMillis(123));
    ExperimentalStateTracker stateTracker = new ExperimentalStateTracker(clock);
    clock.advanceMillis(TimeUnit.SECONDS.toMillis(2));
    stateTracker.actionStarted(new ActionStartedEvent(mockAction("First action", "foo"), clock.nanoTime()));
    clock.advanceMillis(TimeUnit.SECONDS.toMillis(7));
    stateTracker.actionStarted(new ActionStartedEvent(mockAction("Second action", "bar"), clock.nanoTime()));
    clock.advanceMillis(TimeUnit.SECONDS.toMillis(20));
    LoggingTerminalWriter terminalWriter = new LoggingTerminalWriter(/*discardHighlight=*/
    true);
    stateTracker.writeProgressBar(terminalWriter);
    String output = terminalWriter.getTranscript();
    assertTrue("Runtime of first action should be visible in output: " + output, output.contains("27s"));
    assertTrue("Runtime of second action should be visible in output: " + output, output.contains("20s"));
    terminalWriter = new LoggingTerminalWriter(/*discardHighlight=*/
    true);
    stateTracker.writeProgressBar(terminalWriter, /* shortVersion=*/
    true);
    output = terminalWriter.getTranscript();
    assertTrue("Runtime of first action should be visible in short output: " + output, output.contains("27s"));
}
Also used : ManualClock(com.google.devtools.build.lib.testutil.ManualClock) ActionStartedEvent(com.google.devtools.build.lib.actions.ActionStartedEvent) LoggingTerminalWriter(com.google.devtools.build.lib.util.io.LoggingTerminalWriter) Test(org.junit.Test)

Example 15 with LoggingTerminalWriter

use of com.google.devtools.build.lib.util.io.LoggingTerminalWriter 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

LoggingTerminalWriter (com.google.devtools.build.lib.util.io.LoggingTerminalWriter)16 ManualClock (com.google.devtools.build.lib.testutil.ManualClock)15 Test (org.junit.Test)14 ActionStartedEvent (com.google.devtools.build.lib.actions.ActionStartedEvent)9 Label (com.google.devtools.build.lib.cmdline.Label)6 Action (com.google.devtools.build.lib.actions.Action)5 ConfiguredTarget (com.google.devtools.build.lib.analysis.ConfiguredTarget)5 TestFilteringCompleteEvent (com.google.devtools.build.lib.buildtool.buildevent.TestFilteringCompleteEvent)5 ActionOwner (com.google.devtools.build.lib.actions.ActionOwner)3 DownloadProgressEvent (com.google.devtools.build.lib.bazel.repository.downloader.DownloadProgressEvent)2 URL (java.net.URL)2 ActionCompletionEvent (com.google.devtools.build.lib.actions.ActionCompletionEvent)1 ActionExecutionMetadata (com.google.devtools.build.lib.actions.ActionExecutionMetadata)1 Artifact (com.google.devtools.build.lib.actions.Artifact)1 LoadingPhaseStartedEvent (com.google.devtools.build.lib.skyframe.LoadingPhaseStartedEvent)1 PackageProgressReceiver (com.google.devtools.build.lib.skyframe.PackageProgressReceiver)1 AnsiTerminalWriter (com.google.devtools.build.lib.util.io.AnsiTerminalWriter)1 LineCountingAnsiTerminalWriter (com.google.devtools.build.lib.util.io.LineCountingAnsiTerminalWriter)1 LineWrappingAnsiTerminalWriter (com.google.devtools.build.lib.util.io.LineWrappingAnsiTerminalWriter)1 Path (com.google.devtools.build.lib.vfs.Path)1