diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2019-11-17 00:14:45 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2019-11-17 00:14:45 +0000 |
commit | 342a333a4ef02a03bd61ff694cb6b29f9e1e83dd (patch) | |
tree | 927be209f8cf1a91057c3fe5090bf5e85b8db899 | |
parent | 60c4219ca4bdb4a3d943db4a877f72fa9692039e (diff) | |
parent | 8e8f1e9c82c946997959642073317784627919a5 (diff) | |
download | gtest_extras-android-platform-11.0.0_r39.tar.gz |
Snap for 6013487 from 8e8f1e9c82c946997959642073317784627919a5 to rvc-releaseandroid-vts-11.0_r9android-vts-11.0_r8android-vts-11.0_r7android-vts-11.0_r6android-vts-11.0_r5android-vts-11.0_r4android-vts-11.0_r3android-vts-11.0_r2android-vts-11.0_r16android-vts-11.0_r15android-vts-11.0_r14android-vts-11.0_r13android-vts-11.0_r12android-vts-11.0_r11android-vts-11.0_r10android-vts-11.0_r1android-security-11.0.0_r76android-security-11.0.0_r75android-security-11.0.0_r74android-security-11.0.0_r73android-security-11.0.0_r72android-security-11.0.0_r71android-security-11.0.0_r70android-security-11.0.0_r69android-security-11.0.0_r68android-security-11.0.0_r67android-security-11.0.0_r66android-security-11.0.0_r65android-security-11.0.0_r64android-security-11.0.0_r63android-security-11.0.0_r62android-security-11.0.0_r61android-security-11.0.0_r60android-security-11.0.0_r59android-security-11.0.0_r58android-security-11.0.0_r57android-security-11.0.0_r56android-security-11.0.0_r55android-security-11.0.0_r54android-security-11.0.0_r53android-security-11.0.0_r52android-security-11.0.0_r51android-security-11.0.0_r50android-security-11.0.0_r49android-security-11.0.0_r1android-platform-11.0.0_r9android-platform-11.0.0_r8android-platform-11.0.0_r7android-platform-11.0.0_r6android-platform-11.0.0_r5android-platform-11.0.0_r40android-platform-11.0.0_r4android-platform-11.0.0_r39android-platform-11.0.0_r38android-platform-11.0.0_r37android-platform-11.0.0_r36android-platform-11.0.0_r35android-platform-11.0.0_r34android-platform-11.0.0_r33android-platform-11.0.0_r32android-platform-11.0.0_r31android-platform-11.0.0_r30android-platform-11.0.0_r3android-platform-11.0.0_r29android-platform-11.0.0_r28android-platform-11.0.0_r27android-platform-11.0.0_r26android-platform-11.0.0_r25android-platform-11.0.0_r24android-platform-11.0.0_r23android-platform-11.0.0_r22android-platform-11.0.0_r21android-platform-11.0.0_r20android-platform-11.0.0_r2android-platform-11.0.0_r19android-platform-11.0.0_r18android-platform-11.0.0_r17android-platform-11.0.0_r16android-platform-11.0.0_r15android-platform-11.0.0_r14android-platform-11.0.0_r13android-platform-11.0.0_r12android-platform-11.0.0_r11android-platform-11.0.0_r10android-platform-11.0.0_r1android-cts-11.0_r9android-cts-11.0_r8android-cts-11.0_r7android-cts-11.0_r6android-cts-11.0_r5android-cts-11.0_r4android-cts-11.0_r3android-cts-11.0_r2android-cts-11.0_r16android-cts-11.0_r15android-cts-11.0_r14android-cts-11.0_r13android-cts-11.0_r12android-cts-11.0_r11android-cts-11.0_r10android-cts-11.0_r1android-11.0.0_r6android-11.0.0_r5android-11.0.0_r4android-11.0.0_r3android-11.0.0_r25android-11.0.0_r2android-11.0.0_r17android-11.0.0_r1android11-tests-releaseandroid11-security-releaseandroid11-s1-releaseandroid11-releaseandroid11-platform-releaseandroid11-gsi
Change-Id: I557bed205e4a3d17a7e7d33ba530ffcffea77688
-rw-r--r-- | Isolate.cpp | 10 | ||||
-rw-r--r-- | Test.cpp | 40 | ||||
-rw-r--r-- | Test.h | 3 | ||||
-rw-r--r-- | tests/SystemTests.cpp | 11 |
4 files changed, 28 insertions, 36 deletions
diff --git a/Isolate.cpp b/Isolate.cpp index 756f194..889b183 100644 --- a/Isolate.cpp +++ b/Isolate.cpp @@ -617,9 +617,13 @@ void TestResultPrinter::OnTestPartResult(const ::testing::TestPartResult& result return; } - // Print failure message from the assertion (e.g. expected this and got that). - printf("%s:(%d) Failure in test %s.%s\n%s\n", result.file_name(), result.line_number(), - pinfo_->test_suite_name(), pinfo_->name(), result.message()); + if (result.type() == ::testing::TestPartResult::kSkip) { + printf("%s:(%d) Skipped%s\n", result.file_name(), result.line_number(), result.message()); + } else { + // Print failure message from the assertion (e.g. expected this and got that). + printf("%s:(%d) Failure in test %s.%s\n%s\n", result.file_name(), result.line_number(), + pinfo_->test_suite_name(), pinfo_->name(), result.message()); + } fflush(stdout); } @@ -18,6 +18,7 @@ #include <stdio.h> #include <unistd.h> +#include <regex> #include <string> #include <tuple> #include <vector> @@ -32,6 +33,8 @@ namespace android { namespace gtest_extras { +std::regex Test::skipped_regex_("(^|\\n)[^\\n]+:\\(\\d+\\) Skipped\\n"); + Test::Test(std::tuple<std::string, std::string>& test, size_t index, size_t run_index, int fd) : suite_name_(std::get<0>(test)), test_name_(std::get<1>(test)), @@ -114,42 +117,13 @@ void Test::SetResultFromOutput() { // Need to parse the output to determine if this test was skipped. // Format of a skipped test: - // <filename>:(<line_number>) Failure in test <testname> - // Skipped + // <filename>:(<line_number>) Skipped // <Skip Message> - // There can be multiple skip messages, so remove all of them. - size_t start_index = 0; - while (true) { - size_t skipped_index = output_.find("\nSkipped\n", start_index); - if (skipped_index == std::string::npos) { - return; - } - if (skipped_index == 0) { - // The output starts with Skipped, so skip over it and keep looking. - start_index = skipped_index + 9; - continue; - } - // Look backwards for start of line before "Skipped" message. - size_t failure_line_start = output_.rfind('\n', skipped_index - 1); - if (failure_line_start == std::string::npos) { - failure_line_start = 0; - } - skipped_index += 9; - size_t failure_index = output_.find(" Failure in test ", failure_line_start); - if (failure_index == std::string::npos || failure_index > skipped_index) { - // Could still be another skipped message matching the pattern after - // this one. - start_index = skipped_index - 1; - continue; - } - start_index = 0; + // If there are multiple skip messages, it doesn't matter, seeing + // even one indicates this is a skipped test. + if (std::regex_search(output_, skipped_regex_)) { result_ = TEST_SKIPPED; - if (failure_line_start != 0) { - output_ = output_.substr(0, failure_line_start + 1) + output_.substr(skipped_index); - } else { - output_ = output_.substr(skipped_index); - } } } @@ -16,6 +16,7 @@ #pragma once +#include <regex> #include <string> #include <tuple> @@ -94,6 +95,8 @@ class Test { TestResult result_ = TEST_NONE; std::string output_; + + static std::regex skipped_regex_; }; } // namespace gtest_extras diff --git a/tests/SystemTests.cpp b/tests/SystemTests.cpp index ee7b176..821c055 100644 --- a/tests/SystemTests.cpp +++ b/tests/SystemTests.cpp @@ -309,6 +309,7 @@ TEST_F(SystemTests, verify_skip) { "Note: Google Test filter = *.DISABLED_skip_no_message\n" "[==========] Running 1 test from 1 test suite (20 jobs).\n" "[ RUN ] SystemTests.DISABLED_skip_no_message\n" + "file:(XX) Skipped\n" "[ SKIPPED ] SystemTests.DISABLED_skip_no_message (XX ms)\n" "[==========] 1 test from 1 test suite ran. (XX ms total)\n" "[ PASSED ] 0 tests.\n" @@ -322,6 +323,7 @@ TEST_F(SystemTests, verify_skip_with_message) { "Note: Google Test filter = *.DISABLED_skip_with_message\n" "[==========] Running 1 test from 1 test suite (20 jobs).\n" "[ RUN ] SystemTests.DISABLED_skip_with_message\n" + "file:(XX) Skipped\n" "This is a skip message\n" "[ SKIPPED ] SystemTests.DISABLED_skip_with_message (XX ms)\n" "[==========] 1 test from 1 test suite ran. (XX ms total)\n" @@ -337,6 +339,7 @@ TEST_F(SystemTests, verify_skip_with_output_before_message) { "[==========] Running 1 test from 1 test suite (20 jobs).\n" "[ RUN ] SystemTests.DISABLED_skip_with_output_before\n" "This is the message before the skip message\n" + "file:(XX) Skipped\n" "This is the skip message\n" "[ SKIPPED ] SystemTests.DISABLED_skip_with_output_before (XX ms)\n" "[==========] 1 test from 1 test suite ran. (XX ms total)\n" @@ -351,6 +354,7 @@ TEST_F(SystemTests, verify_skip_with_output_after_message) { "Note: Google Test filter = *.DISABLED_skip_with_output_after\n" "[==========] Running 1 test from 1 test suite (20 jobs).\n" "[ RUN ] SystemTests.DISABLED_skip_with_output_after\n" + "file:(XX) Skipped\n" "This is the skip message\n" "This is the message after the skip message\n" "[ SKIPPED ] SystemTests.DISABLED_skip_with_output_after (XX ms)\n" @@ -368,8 +372,10 @@ TEST_F(SystemTests, verify_skip_with_skipped_line) { "[ RUN ] SystemTests.DISABLED_skip_with_skipped_line\n" "\n" "Skipped\n" + "file:(XX) Skipped\n" "This is the skip message 1\n" "Skipped\n" + "file:(XX) Skipped\n" "This is the skip message 2\n" "Skipped\n" "[ SKIPPED ] SystemTests.DISABLED_skip_with_skipped_line (XX ms)\n" @@ -386,9 +392,12 @@ TEST_F(SystemTests, verify_skip_multiple) { "[==========] Running 1 test from 1 test suite (20 jobs).\n" "[ RUN ] SystemTests.DISABLED_skip_multiple\n" "This is not a skip message 1\n" + "file:(XX) Skipped\n" "This is the skip message 1\n" "This is not a skip message 2\n" + "file:(XX) Skipped\n" "This is the skip message 2\n" + "file:(XX) Skipped\n" "This is the skip message 3\n" "This is not a skip message 4\n" "[ SKIPPED ] SystemTests.DISABLED_skip_multiple (XX ms)\n" @@ -404,6 +413,7 @@ TEST_F(SystemTests, verify_skip_no_print_time) { "Note: Google Test filter = *.DISABLED_skip_no_message\n" "[==========] Running 1 test from 1 test suite (20 jobs).\n" "[ RUN ] SystemTests.DISABLED_skip_no_message\n" + "file:(XX) Skipped\n" "[ SKIPPED ] SystemTests.DISABLED_skip_no_message\n" "[==========] 1 test from 1 test suite ran. (XX ms total)\n" "[ PASSED ] 0 tests.\n" @@ -418,6 +428,7 @@ TEST_F(SystemTests, verify_skip_color) { "\x1B[0;33mNote: Google Test filter = *.DISABLED_skip_no_message\x1B[m\n" "\x1B[0;32m[==========]\x1B[m Running 1 test from 1 test suite (20 jobs).\n" "\x1B[0;32m[ RUN ]\x1B[m SystemTests.DISABLED_skip_no_message\n" + "file:(XX) Skipped\n" "\x1B[0;32m[ SKIPPED ]\x1B[m SystemTests.DISABLED_skip_no_message (XX ms)\n" "\x1B[0;32m[==========]\x1B[m 1 test from 1 test suite ran. (XX ms total)\n" "\x1B[0;32m[ PASSED ]\x1B[m 0 tests.\n" |