Commit 26df7c8b authored by Corentin Wallez's avatar Corentin Wallez Committed by Commit Bot

test_launcher: correctly parse the output of skipped tests.

Bug: chromium:1130483
Change-Id: Ie339143e1830e70e0da98a3cfc803cc6934f6e65
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2421509
Commit-Queue: Ilia Samsonov <isamsonov@google.com>
Reviewed-by: default avatarAustin Eng <enga@chromium.org>
Reviewed-by: default avatarIlia Samsonov <isamsonov@google.com>
Cr-Commit-Position: refs/heads/master@{#808919}
parent 49e4d09f
......@@ -1952,12 +1952,19 @@ std::string GetTestOutputSnippet(const TestResult& result,
result.full_name,
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.
// succeeded or was skipped. It still might have e.g. crashed
// after printing it.
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);
// Also handle SKIPPED next to SUCCESS because the GTest XML output
// doesn't make a difference between SKIPPED and SUCCESS
if (end_pos == std::string::npos)
end_pos = full_output.find(
std::string("[ SKIPPED ] ") + 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);
......
......@@ -854,6 +854,8 @@ TEST(TestLauncherTools, GetTestOutputSnippetTest) {
"Post first test output\n"
"[ RUN ] TestCase.SecondTest\n"
"[ FAILED ] TestCase.SecondTest (0 ms)\n"
"[ RUN ] TestCase.ThirdTest\n"
"[ SKIPPED ] TestCase.ThirdTest (0 ms)\n"
"Post second test output";
TestResult result;
......@@ -878,6 +880,14 @@ TEST(TestLauncherTools, GetTestOutputSnippetTest) {
EXPECT_EQ(GetTestOutputSnippet(result, output),
"[ RUN ] TestCase.SecondTest\n"
"[ FAILED ] TestCase.SecondTest (0 ms)\n");
// test snippet of a skipped test. Note that the status is SUCCESS because
// the gtest XML format doesn't make a difference between SUCCESS and SKIPPED
result.full_name = "TestCase.ThirdTest";
result.status = TestResult::TEST_SUCCESS;
EXPECT_EQ(GetTestOutputSnippet(result, output),
"[ RUN ] TestCase.ThirdTest\n"
"[ SKIPPED ] TestCase.ThirdTest (0 ms)\n");
}
} // namespace
......
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