use of com.google.devtools.build.lib.util.io.AnsiTerminalPrinter in project bazel by bazelbuild.
the class TestSummaryTest method testMessageShownForPartialResults.
@Test
public void testMessageShownForPartialResults() throws Exception {
ImmutableList<TestCase> testCases = ImmutableList.of(newDetail("orange", TestCase.Status.FAILED, 1500L));
TestSummary summary = createTestSummaryWithDetails(BlazeTestStatus.FAILED, testCases, FailedTestCasesStatus.PARTIAL);
AnsiTerminalPrinter printer = Mockito.mock(AnsiTerminalPrinter.class);
TestSummaryPrinter.print(summary, printer, true, true);
verify(printer).print(contains("//package:name"));
verify(printer).print(find("FAILED.*orange"));
verify(printer).print(contains("incomplete"));
}
use of com.google.devtools.build.lib.util.io.AnsiTerminalPrinter in project bazel by bazelbuild.
the class TestSummaryTest method testMessageShownWhenTestCasesMissing.
@Test
public void testMessageShownWhenTestCasesMissing() throws Exception {
ImmutableList<TestCase> emptyList = ImmutableList.of();
TestSummary summary = createTestSummaryWithDetails(BlazeTestStatus.FAILED, emptyList, FailedTestCasesStatus.NOT_AVAILABLE);
AnsiTerminalPrinter printer = Mockito.mock(AnsiTerminalPrinter.class);
TestSummaryPrinter.print(summary, printer, true, true);
verify(printer).print(contains("//package:name"));
verify(printer).print(contains("not available"));
}
use of com.google.devtools.build.lib.util.io.AnsiTerminalPrinter in project bazel by bazelbuild.
the class TestSummaryTest method testShouldPrintFailedStatus.
@Test
public void testShouldPrintFailedStatus() throws Exception {
String expectedString = ANY_STRING + "ERROR" + ANY_STRING + BlazeTestStatus.FAILED + ANY_STRING;
AnsiTerminalPrinter terminalPrinter = Mockito.mock(AnsiTerminalPrinter.class);
TestSummary summary = createTestSummary(stubTarget, BlazeTestStatus.FAILED, NOT_CACHED);
TestSummaryPrinter.print(summary, terminalPrinter, true, false);
terminalPrinter.print(find(expectedString));
}
use of com.google.devtools.build.lib.util.io.AnsiTerminalPrinter in project bazel by bazelbuild.
the class TestSummaryTest method testTestCaseNamesShownWhenNeeded.
@Test
public void testTestCaseNamesShownWhenNeeded() throws Exception {
TestCase detailPassed = newDetail("strawberry", TestCase.Status.PASSED, 1000L);
TestCase detailFailed = newDetail("orange", TestCase.Status.FAILED, 1500L);
TestSummary summaryPassed = createTestSummaryWithDetails(BlazeTestStatus.PASSED, Arrays.asList(detailPassed));
TestSummary summaryFailed = createTestSummaryWithDetails(BlazeTestStatus.FAILED, Arrays.asList(detailPassed, detailFailed));
assertEquals(BlazeTestStatus.FAILED, summaryFailed.getStatus());
AnsiTerminalPrinter printerPassed = Mockito.mock(AnsiTerminalPrinter.class);
TestSummaryPrinter.print(summaryPassed, printerPassed, true, true);
verify(printerPassed).print(contains("//package:name"));
AnsiTerminalPrinter printerFailed = Mockito.mock(AnsiTerminalPrinter.class);
TestSummaryPrinter.print(summaryFailed, printerFailed, true, true);
verify(printerFailed).print(contains("//package:name"));
verify(printerFailed).print(find("FAILED.*orange *\\(1\\.5"));
}
use of com.google.devtools.build.lib.util.io.AnsiTerminalPrinter in project bazel by bazelbuild.
the class TestSummaryTest method testTestCaseNamesOrdered.
@Test
public void testTestCaseNamesOrdered() throws Exception {
TestCase[] details = { newDetail("apple", TestCase.Status.FAILED, 1000L), newDetail("banana", TestCase.Status.FAILED, 1000L), newDetail("cranberry", TestCase.Status.FAILED, 1000L) };
// The exceedingly dumb approach: writing all the permutations down manually
// is simply easier than any way of generating them.
int[][] permutations = { { 0, 1, 2 }, { 0, 2, 1 }, { 1, 0, 2 }, { 1, 2, 0 }, { 2, 0, 1 }, { 2, 1, 0 } };
for (int[] permutation : permutations) {
List<TestCase> permutatedDetails = new ArrayList<>();
for (int element : permutation) {
permutatedDetails.add(details[element]);
}
TestSummary summary = createTestSummaryWithDetails(BlazeTestStatus.FAILED, permutatedDetails);
// A mock that checks the ordering of method calls
AnsiTerminalPrinter printer = Mockito.mock(AnsiTerminalPrinter.class);
TestSummaryPrinter.print(summary, printer, true, true);
InOrder order = Mockito.inOrder(printer);
order.verify(printer).print(contains("//package:name"));
order.verify(printer).print(find("FAILED.*apple"));
order.verify(printer).print(find("FAILED.*banana"));
order.verify(printer).print(find("FAILED.*cranberry"));
}
}
Aggregations