Chromium Code Reviews| 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() || |
|
sky
2014/01/06 19:27:39
nit: fit on one line.
Paweł Hajdan Jr.
2014/01/07 09:19:35
Done.
| |
| 514 tests_to_retry_.end()); | 511 retry_count_ >= retry_limit_) { |
| 512 OnTestIterationFinished(); | |
| 513 return; | |
| 514 } | |
| 515 | 515 |
| 516 tests_to_retry_.clear(); | 516 if (tests_to_retry_.size() >= broken_threshold) { |
| 517 fprintf(stdout, | |
| 518 "Too many failing tests (%" PRIuS "), skipping retries.\n", | |
| 519 tests_to_retry_.size()); | |
| 520 fflush(stdout); | |
| 517 | 521 |
| 518 size_t retry_started_count = | 522 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 | 523 |
| 526 OnTestIterationFinished(); | 524 OnTestIterationFinished(); |
| 527 } else { | 525 return; |
| 528 fprintf(stdout, "Retrying %" PRIuS " test%s (retry #%" PRIuS ")\n", | 526 } |
| 529 retry_started_count, | |
| 530 retry_started_count > 1 ? "s" : "", | |
| 531 retry_count_); | |
| 532 fflush(stdout); | |
| 533 | 527 |
| 534 test_started_count_ += retry_started_count; | 528 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 | 529 |
| 542 results_tracker_.AddGlobalTag("BROKEN_TEST_SKIPPED_RETRIES"); | 530 std::vector<std::string> test_names(tests_to_retry_.begin(), |
| 531 tests_to_retry_.end()); | |
| 543 | 532 |
| 544 OnTestIterationFinished(); | 533 tests_to_retry_.clear(); |
| 545 } | 534 |
| 546 } else { | 535 size_t retry_started_count = launcher_delegate_->RetryTests(this, test_names); |
| 547 OnTestIterationFinished(); | 536 if (retry_started_count == 0) { |
| 548 } | 537 // Signal failure, but continue to run all requested test iterations. |
| 538 // With the summary of all iterations at the end this is a good default. | |
| 539 run_result_ = false; | |
| 540 | |
| 541 OnTestIterationFinished(); | |
| 542 return; | |
| 549 } | 543 } |
| 544 | |
| 545 fprintf(stdout, "Retrying %" PRIuS " test%s (retry #%" PRIuS ")\n", | |
| 546 retry_started_count, | |
| 547 retry_started_count > 1 ? "s" : "", | |
| 548 retry_count_); | |
| 549 fflush(stdout); | |
| 550 | |
| 551 test_started_count_ += retry_started_count; | |
| 550 } | 552 } |
| 551 | 553 |
| 552 bool TestLauncher::Init() { | 554 bool TestLauncher::Init() { |
| 553 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 555 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 554 | 556 |
| 555 // Initialize sharding. Command line takes precedence over legacy environment | 557 // Initialize sharding. Command line takes precedence over legacy environment |
| 556 // variables. | 558 // variables. |
| 557 if (command_line->HasSwitch(switches::kTestLauncherTotalShards) && | 559 if (command_line->HasSwitch(switches::kTestLauncherTotalShards) && |
| 558 command_line->HasSwitch(switches::kTestLauncherShardIndex)) { | 560 command_line->HasSwitch(switches::kTestLauncherShardIndex)) { |
| 559 if (!StringToInt( | 561 if (!StringToInt( |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1004 | 1006 |
| 1005 g_live_processes.Get().erase(process_handle); | 1007 g_live_processes.Get().erase(process_handle); |
| 1006 } | 1008 } |
| 1007 | 1009 |
| 1008 base::CloseProcessHandle(process_handle); | 1010 base::CloseProcessHandle(process_handle); |
| 1009 | 1011 |
| 1010 return exit_code; | 1012 return exit_code; |
| 1011 } | 1013 } |
| 1012 | 1014 |
| 1013 } // namespace base | 1015 } // namespace base |
| OLD | NEW |