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 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 watchdog_timer_.Reset(); | 529 watchdog_timer_.Reset(); |
530 | 530 |
531 ThreadTaskRunnerHandle::Get()->PostTask( | 531 ThreadTaskRunnerHandle::Get()->PostTask( |
532 FROM_HERE, Bind(&TestLauncher::RunTestIteration, Unretained(this))); | 532 FROM_HERE, Bind(&TestLauncher::RunTestIteration, Unretained(this))); |
533 | 533 |
534 RunLoop().Run(); | 534 RunLoop().Run(); |
535 | 535 |
536 if (requested_cycles != 1) | 536 if (requested_cycles != 1) |
537 results_tracker_.PrintSummaryOfAllIterations(); | 537 results_tracker_.PrintSummaryOfAllIterations(); |
538 | 538 |
539 MaybeSaveSummaryAsJSON(); | 539 MaybeSaveSummaryAsJSON(std::vector<std::string>()); |
540 | 540 |
541 return run_result_; | 541 return run_result_; |
542 } | 542 } |
543 | 543 |
544 void TestLauncher::LaunchChildGTestProcess( | 544 void TestLauncher::LaunchChildGTestProcess( |
545 const CommandLine& command_line, | 545 const CommandLine& command_line, |
546 const std::string& wrapper, | 546 const std::string& wrapper, |
547 TimeDelta timeout, | 547 TimeDelta timeout, |
548 const LaunchOptions& options, | 548 const LaunchOptions& options, |
549 const GTestProcessCompletedCallback& completed_callback, | 549 const GTestProcessCompletedCallback& completed_callback, |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 std::max(static_cast<size_t>(20), test_found_count_ / 10); | 649 std::max(static_cast<size_t>(20), test_found_count_ / 10); |
650 if (!force_run_broken_tests_ && test_broken_count_ >= broken_threshold) { | 650 if (!force_run_broken_tests_ && test_broken_count_ >= broken_threshold) { |
651 fprintf(stdout, "Too many badly broken tests (%" PRIuS "), exiting now.\n", | 651 fprintf(stdout, "Too many badly broken tests (%" PRIuS "), exiting now.\n", |
652 test_broken_count_); | 652 test_broken_count_); |
653 fflush(stdout); | 653 fflush(stdout); |
654 | 654 |
655 #if defined(OS_POSIX) | 655 #if defined(OS_POSIX) |
656 KillSpawnedTestProcesses(); | 656 KillSpawnedTestProcesses(); |
657 #endif // defined(OS_POSIX) | 657 #endif // defined(OS_POSIX) |
658 | 658 |
659 results_tracker_.AddGlobalTag("BROKEN_TEST_EARLY_EXIT"); | 659 MaybeSaveSummaryAsJSON({"BROKEN_TEST_EARLY_EXIT", kUnreliableResultsTag}); |
660 results_tracker_.AddGlobalTag(kUnreliableResultsTag); | |
661 MaybeSaveSummaryAsJSON(); | |
662 | 660 |
663 exit(1); | 661 exit(1); |
664 } | 662 } |
665 | 663 |
666 if (test_finished_count_ != test_started_count_) | 664 if (test_finished_count_ != test_started_count_) |
667 return; | 665 return; |
668 | 666 |
669 if (tests_to_retry_.empty() || retry_count_ >= retry_limit_) { | 667 if (tests_to_retry_.empty() || retry_count_ >= retry_limit_) { |
670 OnTestIterationFinished(); | 668 OnTestIterationFinished(); |
671 return; | 669 return; |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 } | 980 } |
983 if (excluded) | 981 if (excluded) |
984 continue; | 982 continue; |
985 | 983 |
986 if (Hash(test_name) % total_shards_ != static_cast<uint32_t>(shard_index_)) | 984 if (Hash(test_name) % total_shards_ != static_cast<uint32_t>(shard_index_)) |
987 continue; | 985 continue; |
988 | 986 |
989 test_names.push_back(test_name); | 987 test_names.push_back(test_name); |
990 } | 988 } |
991 | 989 |
| 990 // Save an early test summary in case the launcher crashes or gets killed. |
| 991 MaybeSaveSummaryAsJSON({"EARLY_SUMMARY", kUnreliableResultsTag}); |
| 992 |
992 test_started_count_ = launcher_delegate_->RunTests(this, test_names); | 993 test_started_count_ = launcher_delegate_->RunTests(this, test_names); |
993 | 994 |
994 if (test_started_count_ == 0) { | 995 if (test_started_count_ == 0) { |
995 fprintf(stdout, "0 tests run\n"); | 996 fprintf(stdout, "0 tests run\n"); |
996 fflush(stdout); | 997 fflush(stdout); |
997 | 998 |
998 // No tests have actually been started, so kick off the next iteration. | 999 // No tests have actually been started, so kick off the next iteration. |
999 ThreadTaskRunnerHandle::Get()->PostTask( | 1000 ThreadTaskRunnerHandle::Get()->PostTask( |
1000 FROM_HERE, Bind(&TestLauncher::RunTestIteration, Unretained(this))); | 1001 FROM_HERE, Bind(&TestLauncher::RunTestIteration, Unretained(this))); |
1001 } | 1002 } |
(...skipping 17 matching lines...) Expand all Loading... |
1019 test_success_count_ = 0; | 1020 test_success_count_ = 0; |
1020 test_broken_count_ = 0; | 1021 test_broken_count_ = 0; |
1021 retry_count_ = 0; | 1022 retry_count_ = 0; |
1022 tests_to_retry_.clear(); | 1023 tests_to_retry_.clear(); |
1023 results_tracker_.OnTestIterationStarting(); | 1024 results_tracker_.OnTestIterationStarting(); |
1024 | 1025 |
1025 ThreadTaskRunnerHandle::Get()->PostTask( | 1026 ThreadTaskRunnerHandle::Get()->PostTask( |
1026 FROM_HERE, Bind(&TestLauncher::RunTests, Unretained(this))); | 1027 FROM_HERE, Bind(&TestLauncher::RunTests, Unretained(this))); |
1027 } | 1028 } |
1028 | 1029 |
1029 void TestLauncher::MaybeSaveSummaryAsJSON() { | 1030 void TestLauncher::MaybeSaveSummaryAsJSON( |
| 1031 const std::vector<std::string>& additional_tags) { |
1030 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 1032 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
1031 if (command_line->HasSwitch(switches::kTestLauncherSummaryOutput)) { | 1033 if (command_line->HasSwitch(switches::kTestLauncherSummaryOutput)) { |
1032 FilePath summary_path(command_line->GetSwitchValuePath( | 1034 FilePath summary_path(command_line->GetSwitchValuePath( |
1033 switches::kTestLauncherSummaryOutput)); | 1035 switches::kTestLauncherSummaryOutput)); |
1034 if (!results_tracker_.SaveSummaryAsJSON(summary_path)) { | 1036 if (!results_tracker_.SaveSummaryAsJSON(summary_path, additional_tags)) { |
1035 LOG(ERROR) << "Failed to save test launcher output summary."; | 1037 LOG(ERROR) << "Failed to save test launcher output summary."; |
1036 } | 1038 } |
1037 } | 1039 } |
1038 if (command_line->HasSwitch(switches::kTestLauncherTrace)) { | 1040 if (command_line->HasSwitch(switches::kTestLauncherTrace)) { |
1039 FilePath trace_path( | 1041 FilePath trace_path( |
1040 command_line->GetSwitchValuePath(switches::kTestLauncherTrace)); | 1042 command_line->GetSwitchValuePath(switches::kTestLauncherTrace)); |
1041 if (!g_tracer.Get().Dump(trace_path)) { | 1043 if (!g_tracer.Get().Dump(trace_path)) { |
1042 LOG(ERROR) << "Failed to save test launcher trace."; | 1044 LOG(ERROR) << "Failed to save test launcher trace."; |
1043 } | 1045 } |
1044 } | 1046 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1140 } | 1142 } |
1141 | 1143 |
1142 std::string snippet(full_output.substr(run_pos)); | 1144 std::string snippet(full_output.substr(run_pos)); |
1143 if (end_pos != std::string::npos) | 1145 if (end_pos != std::string::npos) |
1144 snippet = full_output.substr(run_pos, end_pos - run_pos); | 1146 snippet = full_output.substr(run_pos, end_pos - run_pos); |
1145 | 1147 |
1146 return snippet; | 1148 return snippet; |
1147 } | 1149 } |
1148 | 1150 |
1149 } // namespace base | 1151 } // namespace base |
OLD | NEW |