Search in sources :

Example 6 with TestFilteringCompleteEvent

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

the class ExperimentalStateTrackerTest method testFailedVisible.

@Test
public void testFailedVisible() throws Exception {
    // The last test should still be visible in the long status bar, and colored as fail if it
    // did not pass.
    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.FAILED);
    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.FAIL + 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)

Aggregations

TestFilteringCompleteEvent (com.google.devtools.build.lib.buildtool.buildevent.TestFilteringCompleteEvent)6 ConfiguredTarget (com.google.devtools.build.lib.analysis.ConfiguredTarget)5 Label (com.google.devtools.build.lib.cmdline.Label)5 ManualClock (com.google.devtools.build.lib.testutil.ManualClock)5 LoggingTerminalWriter (com.google.devtools.build.lib.util.io.LoggingTerminalWriter)5 Test (org.junit.Test)4 Action (com.google.devtools.build.lib.actions.Action)2 ActionStartedEvent (com.google.devtools.build.lib.actions.ActionStartedEvent)2 Stopwatch (com.google.common.base.Stopwatch)1 ActionOwner (com.google.devtools.build.lib.actions.ActionOwner)1 AnalysisPhaseCompleteEvent (com.google.devtools.build.lib.analysis.AnalysisPhaseCompleteEvent)1 BuildView (com.google.devtools.build.lib.analysis.BuildView)1 AnalysisResult (com.google.devtools.build.lib.analysis.BuildView.AnalysisResult)1