Commit 1b077df6 authored by Ilia Samsonov's avatar Ilia Samsonov Committed by Commit Bot

Return new TestResult set when "missing results".

ProcessGTestOutput might return TestResults in |results|,
even if the method returns false.

Instead of re-using the vector set by ProcessGTestOutput, return
new vector from ProcessMissingTestResults.

Bug: 978566
Change-Id: I036b79e0a578c87d4dc692b042302e4c2db4ede8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1677689Reviewed-by: default avatarErik Chen <erikchen@chromium.org>
Commit-Queue: Ilia Samsonov <isamsonov@google.com>
Cr-Commit-Position: refs/heads/master@{#673407}
parent e57f4e87
...@@ -211,11 +211,12 @@ void InitGoogleTestWChar(int* argc, wchar_t** argv) { ...@@ -211,11 +211,12 @@ void InitGoogleTestWChar(int* argc, wchar_t** argv) {
// Called if there are no test results, populates results with UNKNOWN results. // Called if there are no test results, populates results with UNKNOWN results.
// If There is only one test, will try to determine status by exit_code and // If There is only one test, will try to determine status by exit_code and
// was_timeout. // was_timeout.
void ProcessMissingTestResults(const std::vector<std::string>& test_names, std::vector<TestResult> ProcessMissingTestResults(
const std::string& output, const std::vector<std::string>& test_names,
bool was_timeout, const std::string& output,
bool exit_code, bool was_timeout,
std::vector<TestResult>* results) { bool exit_code) {
std::vector<TestResult> results;
// We do not have reliable details about test results (parsing test // We do not have reliable details about test results (parsing test
// stdout is known to be unreliable). // stdout is known to be unreliable).
fprintf(stdout, fprintf(stdout,
...@@ -241,15 +242,16 @@ void ProcessMissingTestResults(const std::vector<std::string>& test_names, ...@@ -241,15 +242,16 @@ void ProcessMissingTestResults(const std::vector<std::string>& test_names,
test_result.status = TestResult::TEST_UNKNOWN; test_result.status = TestResult::TEST_UNKNOWN;
} }
results->push_back(test_result); results.push_back(test_result);
return; return results;
} }
for (auto& test_name : test_names) { for (auto& test_name : test_names) {
TestResult test_result; TestResult test_result;
test_result.full_name = test_name; test_result.full_name = test_name;
test_result.status = TestResult::TEST_SKIPPED; test_result.status = TestResult::TEST_SKIPPED;
results->push_back(test_result); results.push_back(test_result);
} }
return results;
} }
// Interprets test results and reports to the test launcher. // Interprets test results and reports to the test launcher.
...@@ -265,8 +267,8 @@ void ProcessTestResults(TestLauncher* test_launcher, ...@@ -265,8 +267,8 @@ void ProcessTestResults(TestLauncher* test_launcher,
ProcessGTestOutput(output_file, &test_results, &crashed); ProcessGTestOutput(output_file, &test_results, &crashed);
if (!have_test_results) { if (!have_test_results) {
ProcessMissingTestResults(test_names, output, was_timeout, exit_code, test_results =
&test_results); ProcessMissingTestResults(test_names, output, was_timeout, exit_code);
for (auto& test_result : test_results) for (auto& test_result : test_results)
test_launcher->OnTestFinished(test_result); test_launcher->OnTestFinished(test_result);
return; return;
......
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