Search in sources :

Example 1 with AnsiTerminalPrinter

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

the class TestCommand method exec.

@Override
public ExitCode exec(CommandEnvironment env, OptionsProvider options) {
    TestResultAnalyzer resultAnalyzer = new TestResultAnalyzer(env.getDirectories().getExecRoot(), options.getOptions(TestSummaryOptions.class), options.getOptions(ExecutionOptions.class), env.getEventBus());
    printer = new AnsiTerminalPrinter(env.getReporter().getOutErr().getOutputStream(), options.getOptions(BlazeCommandEventHandler.Options.class).useColor());
    // Initialize test handler.
    AggregatingTestListener testListener = new AggregatingTestListener(resultAnalyzer, env.getEventBus(), env.getReporter());
    env.getEventBus().register(testListener);
    return doTest(env, options, testListener);
}
Also used : TestSummaryOptions(com.google.devtools.build.lib.runtime.TerminalTestResultNotifier.TestSummaryOptions) ExecutionOptions(com.google.devtools.build.lib.exec.ExecutionOptions) ExecutionOptions(com.google.devtools.build.lib.exec.ExecutionOptions) AggregatingTestListener(com.google.devtools.build.lib.runtime.AggregatingTestListener) TestSummaryOptions(com.google.devtools.build.lib.runtime.TerminalTestResultNotifier.TestSummaryOptions) AnsiTerminalPrinter(com.google.devtools.build.lib.util.io.AnsiTerminalPrinter) TestResultAnalyzer(com.google.devtools.build.lib.runtime.TestResultAnalyzer)

Example 2 with AnsiTerminalPrinter

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

the class TestSummaryTest method testIncompleteCached.

@Test
public void testIncompleteCached() throws Exception {
    AnsiTerminalPrinter terminalPrinter = Mockito.mock(AnsiTerminalPrinter.class);
    TestSummary summary = createTestSummary(stubTarget, BlazeTestStatus.INCOMPLETE, CACHED - 1);
    TestSummaryPrinter.print(summary, terminalPrinter, true, false);
    verify(terminalPrinter).print(not(contains("cached")));
}
Also used : AnsiTerminalPrinter(com.google.devtools.build.lib.util.io.AnsiTerminalPrinter) Test(org.junit.Test)

Example 3 with AnsiTerminalPrinter

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

the class TestSummaryTest method testShouldPrintPassedStatus.

@Test
public void testShouldPrintPassedStatus() throws Exception {
    String expectedString = ANY_STRING + "INFO" + ANY_STRING + BlazeTestStatus.PASSED + ANY_STRING;
    AnsiTerminalPrinter terminalPrinter = Mockito.mock(AnsiTerminalPrinter.class);
    TestSummary summary = createTestSummary(stubTarget, BlazeTestStatus.PASSED, NOT_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 4 with AnsiTerminalPrinter

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

the class TestSummaryTest method testShouldProperlyTestLabels.

@Test
public void testShouldProperlyTestLabels() throws Exception {
    ConfiguredTarget target = target("somepath", "MyTarget");
    String expectedString = ANY_STRING + "//somepath:MyTarget" + ANY_STRING;
    AnsiTerminalPrinter terminalPrinter = Mockito.mock(AnsiTerminalPrinter.class);
    TestSummary summaryStatus = createTestSummary(target, BlazeTestStatus.PASSED, CACHED);
    TestSummaryPrinter.print(summaryStatus, terminalPrinter, true, false);
    terminalPrinter.print(find(expectedString));
}
Also used : AnsiTerminalPrinter(com.google.devtools.build.lib.util.io.AnsiTerminalPrinter) ConfiguredTarget(com.google.devtools.build.lib.analysis.ConfiguredTarget) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 5 with AnsiTerminalPrinter

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

the class TestSummaryTest method testFileNamesNotShown.

@Test
public void testFileNamesNotShown() throws Exception {
    List<TestCase> emptyDetails = ImmutableList.of();
    TestSummary summary = basicBuilder.setStatus(BlazeTestStatus.FAILED).addPassedLogs(getPathList("/apple")).addFailedLogs(getPathList("/pear")).addCoverageFiles(getPathList("/maracuja")).addFailedTestCases(emptyDetails, FailedTestCasesStatus.FULL).build();
    // Check that only //package:name is printed.
    AnsiTerminalPrinter printer = Mockito.mock(AnsiTerminalPrinter.class);
    TestSummaryPrinter.print(summary, printer, true, true);
    verify(printer).print(contains("//package:name"));
}
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)

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