Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: base/test/launcher/test_launcher.cc

Issue 1469843005: Calculate broken tests threshold based on number of tests in binary, before applying filter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/test/launcher/test_launcher.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 445
446 TestLauncherDelegate::~TestLauncherDelegate() { 446 TestLauncherDelegate::~TestLauncherDelegate() {
447 } 447 }
448 448
449 TestLauncher::TestLauncher(TestLauncherDelegate* launcher_delegate, 449 TestLauncher::TestLauncher(TestLauncherDelegate* launcher_delegate,
450 size_t parallel_jobs) 450 size_t parallel_jobs)
451 : launcher_delegate_(launcher_delegate), 451 : launcher_delegate_(launcher_delegate),
452 total_shards_(1), 452 total_shards_(1),
453 shard_index_(0), 453 shard_index_(0),
454 cycles_(1), 454 cycles_(1),
455 test_found_count_(0),
455 test_started_count_(0), 456 test_started_count_(0),
456 test_finished_count_(0), 457 test_finished_count_(0),
457 test_success_count_(0), 458 test_success_count_(0),
458 test_broken_count_(0), 459 test_broken_count_(0),
459 retry_count_(0), 460 retry_count_(0),
460 retry_limit_(0), 461 retry_limit_(0),
461 force_run_broken_tests_(false), 462 force_run_broken_tests_(false),
462 run_result_(true), 463 run_result_(true),
463 watchdog_timer_(FROM_HERE, 464 watchdog_timer_(FROM_HERE,
464 TimeDelta::FromSeconds(kOutputTimeoutSeconds), 465 TimeDelta::FromSeconds(kOutputTimeoutSeconds),
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 watchdog_timer_.Reset(); 615 watchdog_timer_.Reset();
615 616
616 // Do not waste time on timeouts. We include tests with unknown results here 617 // Do not waste time on timeouts. We include tests with unknown results here
617 // because sometimes (e.g. hang in between unit tests) that's how a timeout 618 // because sometimes (e.g. hang in between unit tests) that's how a timeout
618 // gets reported. 619 // gets reported.
619 if (result.status == TestResult::TEST_TIMEOUT || 620 if (result.status == TestResult::TEST_TIMEOUT ||
620 result.status == TestResult::TEST_UNKNOWN) { 621 result.status == TestResult::TEST_UNKNOWN) {
621 test_broken_count_++; 622 test_broken_count_++;
622 } 623 }
623 size_t broken_threshold = 624 size_t broken_threshold =
624 std::max(static_cast<size_t>(20), test_started_count_ / 10); 625 std::max(static_cast<size_t>(20), test_found_count_ / 10);
625 if (!force_run_broken_tests_ && test_broken_count_ >= broken_threshold) { 626 if (!force_run_broken_tests_ && test_broken_count_ >= broken_threshold) {
626 fprintf(stdout, "Too many badly broken tests (%" PRIuS "), exiting now.\n", 627 fprintf(stdout, "Too many badly broken tests (%" PRIuS "), exiting now.\n",
627 test_broken_count_); 628 test_broken_count_);
628 fflush(stdout); 629 fflush(stdout);
629 630
630 #if defined(OS_POSIX) 631 #if defined(OS_POSIX)
631 KillSpawnedTestProcesses(); 632 KillSpawnedTestProcesses();
632 #endif // defined(OS_POSIX) 633 #endif // defined(OS_POSIX)
633 634
634 results_tracker_.AddGlobalTag("BROKEN_TEST_EARLY_EXIT"); 635 results_tracker_.AddGlobalTag("BROKEN_TEST_EARLY_EXIT");
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 // Skip disabled tests unless explicitly requested. 921 // Skip disabled tests unless explicitly requested.
921 if (!command_line->HasSwitch(kGTestRunDisabledTestsFlag)) 922 if (!command_line->HasSwitch(kGTestRunDisabledTestsFlag))
922 continue; 923 continue;
923 } 924 }
924 925
925 if (!launcher_delegate_->ShouldRunTest( 926 if (!launcher_delegate_->ShouldRunTest(
926 tests_[i].test_case_name, tests_[i].test_name)) { 927 tests_[i].test_case_name, tests_[i].test_name)) {
927 continue; 928 continue;
928 } 929 }
929 930
931 // Count tests in the binary, before we apply filter and sharding.
932 test_found_count_++;
933
930 // Skip the test that doesn't match the filter (if given). 934 // Skip the test that doesn't match the filter (if given).
931 if (!positive_test_filter_.empty()) { 935 if (!positive_test_filter_.empty()) {
932 bool found = false; 936 bool found = false;
933 for (size_t k = 0; k < positive_test_filter_.size(); ++k) { 937 for (size_t k = 0; k < positive_test_filter_.size(); ++k) {
934 if (MatchPattern(test_name, positive_test_filter_[k])) { 938 if (MatchPattern(test_name, positive_test_filter_[k])) {
935 found = true; 939 found = true;
936 break; 940 break;
937 } 941 }
938 } 942 }
939 943
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 CommandLine::ForCurrentProcess()->HasSwitch(kGTestBreakOnFailure); 977 CommandLine::ForCurrentProcess()->HasSwitch(kGTestBreakOnFailure);
974 if (cycles_ == 0 || 978 if (cycles_ == 0 ||
975 (stop_on_failure && test_success_count_ != test_finished_count_)) { 979 (stop_on_failure && test_success_count_ != test_finished_count_)) {
976 MessageLoop::current()->QuitWhenIdle(); 980 MessageLoop::current()->QuitWhenIdle();
977 return; 981 return;
978 } 982 }
979 983
980 // Special value "-1" means "repeat indefinitely". 984 // Special value "-1" means "repeat indefinitely".
981 cycles_ = (cycles_ == -1) ? cycles_ : cycles_ - 1; 985 cycles_ = (cycles_ == -1) ? cycles_ : cycles_ - 1;
982 986
987 test_found_count_ = 0;
983 test_started_count_ = 0; 988 test_started_count_ = 0;
984 test_finished_count_ = 0; 989 test_finished_count_ = 0;
985 test_success_count_ = 0; 990 test_success_count_ = 0;
986 test_broken_count_ = 0; 991 test_broken_count_ = 0;
987 retry_count_ = 0; 992 retry_count_ = 0;
988 tests_to_retry_.clear(); 993 tests_to_retry_.clear();
989 results_tracker_.OnTestIterationStarting(); 994 results_tracker_.OnTestIterationStarting();
990 995
991 ThreadTaskRunnerHandle::Get()->PostTask( 996 ThreadTaskRunnerHandle::Get()->PostTask(
992 FROM_HERE, Bind(&TestLauncher::RunTests, Unretained(this))); 997 FROM_HERE, Bind(&TestLauncher::RunTests, Unretained(this)));
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 } 1093 }
1089 1094
1090 std::string snippet(full_output.substr(run_pos)); 1095 std::string snippet(full_output.substr(run_pos));
1091 if (end_pos != std::string::npos) 1096 if (end_pos != std::string::npos)
1092 snippet = full_output.substr(run_pos, end_pos - run_pos); 1097 snippet = full_output.substr(run_pos, end_pos - run_pos);
1093 1098
1094 return snippet; 1099 return snippet;
1095 } 1100 }
1096 1101
1097 } // namespace base 1102 } // namespace base
OLDNEW
« no previous file with comments | « base/test/launcher/test_launcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698