Commit 41febc33 authored by Ilia Samsonov's avatar Ilia Samsonov Committed by Commit Bot

Reduce excessive log.

The purpose of this cl is to reduce the output snippet.
This is most prevalent when tests fails on exit,
and executed in large batches.

Bug: 1086276
Change-Id: I73072f072e12597cdb5dfe53f6153ffaf9cf09d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2226089Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Ilia Samsonov <isamsonov@google.com>
Cr-Commit-Position: refs/heads/master@{#774224}
parent 113bfa01
......@@ -1858,11 +1858,17 @@ std::string GetTestOutputSnippet(const TestResult& result,
run_pos);
// Only clip the snippet to the "OK" message if the test really
// succeeded. It still might have e.g. crashed after printing it.
if (end_pos == std::string::npos &&
result.status == TestResult::TEST_SUCCESS) {
end_pos = full_output.find(std::string("[ OK ] ") +
result.full_name,
run_pos);
if (end_pos == std::string::npos) {
if (result.status == TestResult::TEST_SUCCESS) {
end_pos = full_output.find(std::string("[ OK ] ") +
result.full_name,
run_pos);
} else {
// If test is not successful, include all output until subsequent test.
end_pos = full_output.find(std::string("[ RUN ]"), run_pos + 1);
if (end_pos != std::string::npos)
end_pos--;
}
}
if (end_pos != std::string::npos) {
size_t newline_pos = full_output.find("\n", end_pos);
......
......@@ -764,6 +764,40 @@ TEST_F(UnitTestLauncherDelegateTester, RunMockTests) {
iteration_val, "MockUnitTests.NoRunTest", "NOTRUN", 0u));
}
// Validate GetTestOutputSnippetTest assigns correct output snippet.
TEST(TestLauncherTools, GetTestOutputSnippetTest) {
const std::string output =
"[ RUN ] TestCase.FirstTest\n"
"[ OK ] TestCase.FirstTest (0 ms)\n"
"Post first test output\n"
"[ RUN ] TestCase.SecondTest\n"
"[ FAILED ] TestCase.SecondTest (0 ms)\n"
"Post second test output";
TestResult result;
// test snippet of a successful test
result.full_name = "TestCase.FirstTest";
result.status = TestResult::TEST_SUCCESS;
EXPECT_EQ(GetTestOutputSnippet(result, output),
"[ RUN ] TestCase.FirstTest\n"
"[ OK ] TestCase.FirstTest (0 ms)\n");
// test snippet of a failure on exit tests should include output
// after test concluded, but not subsequent tests output.
result.status = TestResult::TEST_FAILURE_ON_EXIT;
EXPECT_EQ(GetTestOutputSnippet(result, output),
"[ RUN ] TestCase.FirstTest\n"
"[ OK ] TestCase.FirstTest (0 ms)\n"
"Post first test output\n");
// test snippet of a failed test
result.full_name = "TestCase.SecondTest";
result.status = TestResult::TEST_FAILURE;
EXPECT_EQ(GetTestOutputSnippet(result, output),
"[ RUN ] TestCase.SecondTest\n"
"[ FAILED ] TestCase.SecondTest (0 ms)\n");
}
} // namespace
} // namespace base
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment