| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/test/launcher/test_launcher.h" | 5 #include "base/test/launcher/test_launcher.h" |
| 6 | 6 |
| 7 #if defined(OS_POSIX) | 7 #if defined(OS_POSIX) |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 LOG(ERROR) << "Failed to save test launcher output summary."; | 262 LOG(ERROR) << "Failed to save test launcher output summary."; |
| 263 } | 263 } |
| 264 } | 264 } |
| 265 | 265 |
| 266 return run_result_; | 266 return run_result_; |
| 267 } | 267 } |
| 268 | 268 |
| 269 void TestLauncher::OnTestFinished(const TestResult& result) { | 269 void TestLauncher::OnTestFinished(const TestResult& result) { |
| 270 ++test_finished_count_; | 270 ++test_finished_count_; |
| 271 | 271 |
| 272 bool print_snippet = false; |
| 273 std::string print_test_stdio("auto"); |
| 274 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 275 switches::kTestLauncherPrintTestStdio)) { |
| 276 print_test_stdio = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 277 switches::kTestLauncherPrintTestStdio); |
| 278 } |
| 279 if (print_test_stdio == "auto") { |
| 280 print_snippet = (result.status != TestResult::TEST_SUCCESS); |
| 281 } else if (print_test_stdio == "always") { |
| 282 print_snippet = true; |
| 283 } else if (print_test_stdio == "never") { |
| 284 print_snippet = false; |
| 285 } else { |
| 286 LOG(WARNING) << "Invalid value of " << switches::kTestLauncherPrintTestStdio |
| 287 << ": " << print_test_stdio; |
| 288 } |
| 289 if (print_snippet) { |
| 290 fprintf(stdout, "%s", result.output_snippet.c_str()); |
| 291 fflush(stdout); |
| 292 } |
| 293 |
| 272 if (result.status == TestResult::TEST_SUCCESS) { | 294 if (result.status == TestResult::TEST_SUCCESS) { |
| 273 ++test_success_count_; | 295 ++test_success_count_; |
| 274 } else { | 296 } else { |
| 275 tests_to_retry_.insert(result.full_name); | 297 tests_to_retry_.insert(result.full_name); |
| 276 | |
| 277 fprintf(stdout, "%s", result.output_snippet.c_str()); | |
| 278 fflush(stdout); | |
| 279 } | 298 } |
| 280 | 299 |
| 281 results_tracker_.AddTestResult(result); | 300 results_tracker_.AddTestResult(result); |
| 282 | 301 |
| 283 // TODO(phajdan.jr): Align counter (padding). | 302 // TODO(phajdan.jr): Align counter (padding). |
| 284 std::string status_line( | 303 std::string status_line( |
| 285 StringPrintf("[%" PRIuS "/%" PRIuS "] %s ", | 304 StringPrintf("[%" PRIuS "/%" PRIuS "] %s ", |
| 286 test_finished_count_, | 305 test_finished_count_, |
| 287 test_started_count_, | 306 test_started_count_, |
| 288 result.full_name.c_str())); | 307 result.full_name.c_str())); |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 | 668 |
| 650 g_live_process_handles.Get().erase(process_handle); | 669 g_live_process_handles.Get().erase(process_handle); |
| 651 } | 670 } |
| 652 | 671 |
| 653 base::CloseProcessHandle(process_handle); | 672 base::CloseProcessHandle(process_handle); |
| 654 | 673 |
| 655 return exit_code; | 674 return exit_code; |
| 656 } | 675 } |
| 657 | 676 |
| 658 } // namespace base | 677 } // namespace base |
| OLD | NEW |