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 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 #if defined(OS_POSIX) | 497 #if defined(OS_POSIX) |
498 KillSpawnedTestProcesses(); | 498 KillSpawnedTestProcesses(); |
499 #endif // defined(OS_POSIX) | 499 #endif // defined(OS_POSIX) |
500 | 500 |
501 results_tracker_.AddGlobalTag("BROKEN_TEST_EARLY_EXIT"); | 501 results_tracker_.AddGlobalTag("BROKEN_TEST_EARLY_EXIT"); |
502 MaybeSaveSummaryAsJSON(); | 502 MaybeSaveSummaryAsJSON(); |
503 | 503 |
504 exit(1); | 504 exit(1); |
505 } | 505 } |
506 | 506 |
507 if (test_finished_count_ == test_started_count_) { | 507 if (test_finished_count_ != test_started_count_) |
508 if (!tests_to_retry_.empty()) { | 508 return; |
509 if (retry_count_ < retry_limit_ && | |
510 tests_to_retry_.size() < broken_threshold) { | |
511 retry_count_++; | |
512 | 509 |
513 std::vector<std::string> test_names(tests_to_retry_.begin(), | 510 if (tests_to_retry_.empty() || retry_count_ >= retry_limit_) { |
514 tests_to_retry_.end()); | 511 OnTestIterationFinished(); |
| 512 return; |
| 513 } |
515 | 514 |
516 tests_to_retry_.clear(); | 515 if (tests_to_retry_.size() >= broken_threshold) { |
| 516 fprintf(stdout, |
| 517 "Too many failing tests (%" PRIuS "), skipping retries.\n", |
| 518 tests_to_retry_.size()); |
| 519 fflush(stdout); |
517 | 520 |
518 size_t retry_started_count = | 521 results_tracker_.AddGlobalTag("BROKEN_TEST_SKIPPED_RETRIES"); |
519 launcher_delegate_->RetryTests(this, test_names); | |
520 if (retry_started_count == 0) { | |
521 // Signal failure, but continue to run all requested test iterations. | |
522 // With the summary of all iterations at the end this is a good | |
523 // default. | |
524 run_result_ = false; | |
525 | 522 |
526 OnTestIterationFinished(); | 523 OnTestIterationFinished(); |
527 } else { | 524 return; |
528 fprintf(stdout, "Retrying %" PRIuS " test%s (retry #%" PRIuS ")\n", | 525 } |
529 retry_started_count, | |
530 retry_started_count > 1 ? "s" : "", | |
531 retry_count_); | |
532 fflush(stdout); | |
533 | 526 |
534 test_started_count_ += retry_started_count; | 527 retry_count_++; |
535 } | |
536 } else { | |
537 fprintf(stdout, | |
538 "Too many failing tests (%" PRIuS "), skipping retries.\n", | |
539 tests_to_retry_.size()); | |
540 fflush(stdout); | |
541 | 528 |
542 results_tracker_.AddGlobalTag("BROKEN_TEST_SKIPPED_RETRIES"); | 529 std::vector<std::string> test_names(tests_to_retry_.begin(), |
| 530 tests_to_retry_.end()); |
543 | 531 |
544 OnTestIterationFinished(); | 532 tests_to_retry_.clear(); |
545 } | 533 |
546 } else { | 534 size_t retry_started_count = launcher_delegate_->RetryTests(this, test_names); |
547 OnTestIterationFinished(); | 535 if (retry_started_count == 0) { |
548 } | 536 // Signal failure, but continue to run all requested test iterations. |
| 537 // With the summary of all iterations at the end this is a good default. |
| 538 run_result_ = false; |
| 539 |
| 540 OnTestIterationFinished(); |
| 541 return; |
549 } | 542 } |
| 543 |
| 544 fprintf(stdout, "Retrying %" PRIuS " test%s (retry #%" PRIuS ")\n", |
| 545 retry_started_count, |
| 546 retry_started_count > 1 ? "s" : "", |
| 547 retry_count_); |
| 548 fflush(stdout); |
| 549 |
| 550 test_started_count_ += retry_started_count; |
550 } | 551 } |
551 | 552 |
552 bool TestLauncher::Init() { | 553 bool TestLauncher::Init() { |
553 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 554 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
554 | 555 |
555 // Initialize sharding. Command line takes precedence over legacy environment | 556 // Initialize sharding. Command line takes precedence over legacy environment |
556 // variables. | 557 // variables. |
557 if (command_line->HasSwitch(switches::kTestLauncherTotalShards) && | 558 if (command_line->HasSwitch(switches::kTestLauncherTotalShards) && |
558 command_line->HasSwitch(switches::kTestLauncherShardIndex)) { | 559 command_line->HasSwitch(switches::kTestLauncherShardIndex)) { |
559 if (!StringToInt( | 560 if (!StringToInt( |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 | 1005 |
1005 g_live_processes.Get().erase(process_handle); | 1006 g_live_processes.Get().erase(process_handle); |
1006 } | 1007 } |
1007 | 1008 |
1008 base::CloseProcessHandle(process_handle); | 1009 base::CloseProcessHandle(process_handle); |
1009 | 1010 |
1010 return exit_code; | 1011 return exit_code; |
1011 } | 1012 } |
1012 | 1013 |
1013 } // namespace base | 1014 } // namespace base |
OLD | NEW |