Search in sources :

Example 16 with AnsiTerminalPrinter

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

the class TestSummaryTest method testShouldPrintCachedStatus.

@Test
public void testShouldPrintCachedStatus() throws Exception {
    String expectedString = ANY_STRING + "\\(cached" + ANY_STRING;
    AnsiTerminalPrinter terminalPrinter = Mockito.mock(AnsiTerminalPrinter.class);
    TestSummary summary = createTestSummary(stubTarget, BlazeTestStatus.PASSED, CACHED);
    TestSummaryPrinter.print(summary, terminalPrinter, true, false);
    terminalPrinter.print(find(expectedString));
}
Also used : AnsiTerminalPrinter(com.google.devtools.build.lib.util.io.AnsiTerminalPrinter) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 17 with AnsiTerminalPrinter

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

the class TestSummaryTest method testCollectingFailedDetails.

@Test
public void testCollectingFailedDetails() throws Exception {
    TestCase rootCase = TestCase.newBuilder().setName("tests").setRunDurationMillis(5000L).addChild(newDetail("apple", TestCase.Status.FAILED, 1000L)).addChild(newDetail("banana", TestCase.Status.PASSED, 1000L)).addChild(newDetail("cherry", TestCase.Status.ERROR, 1000L)).build();
    TestSummary summary = getTemplateBuilder().collectFailedTests(rootCase).setStatus(BlazeTestStatus.FAILED).build();
    AnsiTerminalPrinter printer = Mockito.mock(AnsiTerminalPrinter.class);
    TestSummaryPrinter.print(summary, printer, true, true);
    verify(printer).print(contains("//package:name"));
    verify(printer).print(find("FAILED.*apple"));
    verify(printer).print(find("ERROR.*cherry"));
}
Also used : AnsiTerminalPrinter(com.google.devtools.build.lib.util.io.AnsiTerminalPrinter) TestCase(com.google.devtools.build.lib.view.test.TestStatus.TestCase) Test(org.junit.Test)

Example 18 with AnsiTerminalPrinter

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

the class TestSummaryTest method testNumberOfFailedRuns.

@Test
public void testNumberOfFailedRuns() throws Exception {
    String expectedString = ANY_STRING + "ERROR" + ANY_STRING + BlazeTestStatus.FAILED + ANY_STRING + "in 2 out of 3";
    AnsiTerminalPrinter terminalPrinter = Mockito.mock(AnsiTerminalPrinter.class);
    TestSummary summary = basicBuilder.setStatus(BlazeTestStatus.FAILED).addPassedLogs(getPathList("/a")).addFailedLogs(getPathList("/b", "/c")).build();
    TestSummaryPrinter.print(summary, terminalPrinter, true, false);
    terminalPrinter.print(find(expectedString));
}
Also used : AnsiTerminalPrinter(com.google.devtools.build.lib.util.io.AnsiTerminalPrinter) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 19 with AnsiTerminalPrinter

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

the class TestSummaryTest method testCoverageDataReferences.

@Test
public void testCoverageDataReferences() throws Exception {
    List<Path> paths = getPathList("/cov1.dat", "/cov2.dat", "/cov3.dat", "/cov4.dat");
    FileSystemUtils.writeContentAsLatin1(paths.get(1), "something");
    FileSystemUtils.writeContentAsLatin1(paths.get(3), "");
    FileSystemUtils.writeContentAsLatin1(paths.get(3), "something else");
    TestSummary summary = basicBuilder.addCoverageFiles(paths).build();
    AnsiTerminalPrinter terminalPrinter = Mockito.mock(AnsiTerminalPrinter.class);
    TestSummaryPrinter.print(summary, terminalPrinter, true, false);
    verify(terminalPrinter).print(find(ANY_STRING + "INFO" + ANY_STRING + BlazeTestStatus.PASSED));
    verify(terminalPrinter).print(find("  /cov2.dat"));
    verify(terminalPrinter).print(find("  /cov4.dat"));
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) AnsiTerminalPrinter(com.google.devtools.build.lib.util.io.AnsiTerminalPrinter) Test(org.junit.Test)

Example 20 with AnsiTerminalPrinter

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

the class TestSummaryTest method testNoTime.

@Test
public void testNoTime() throws Exception {
    // The last part matches anything not containing "in".
    String expectedString = ANY_STRING + "INFO" + ANY_STRING + BlazeTestStatus.PASSED + "(?!in)*";
    AnsiTerminalPrinter terminalPrinter = Mockito.mock(AnsiTerminalPrinter.class);
    TestSummary summary = basicBuilder.addTestTimes(ImmutableList.of(3412L)).build();
    TestSummaryPrinter.print(summary, terminalPrinter, false, false);
    terminalPrinter.print(find(expectedString));
}
Also used : AnsiTerminalPrinter(com.google.devtools.build.lib.util.io.AnsiTerminalPrinter) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

AnsiTerminalPrinter (com.google.devtools.build.lib.util.io.AnsiTerminalPrinter)22 Test (org.junit.Test)20 Matchers.anyString (org.mockito.Matchers.anyString)11 TestCase (com.google.devtools.build.lib.view.test.TestStatus.TestCase)6 ConfiguredTarget (com.google.devtools.build.lib.analysis.ConfiguredTarget)1 ExecutionOptions (com.google.devtools.build.lib.exec.ExecutionOptions)1 AggregatingTestListener (com.google.devtools.build.lib.runtime.AggregatingTestListener)1 TestSummaryOptions (com.google.devtools.build.lib.runtime.TerminalTestResultNotifier.TestSummaryOptions)1 TestResultAnalyzer (com.google.devtools.build.lib.runtime.TestResultAnalyzer)1 Path (com.google.devtools.build.lib.vfs.Path)1 ArrayList (java.util.ArrayList)1 InOrder (org.mockito.InOrder)1