| 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 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 CHECK(UnsetEnvironmentVariableIfExists("GTEST_TOTAL_SHARDS")); | 622 CHECK(UnsetEnvironmentVariableIfExists("GTEST_TOTAL_SHARDS")); |
| 623 CHECK(UnsetEnvironmentVariableIfExists("GTEST_SHARD_INDEX")); | 623 CHECK(UnsetEnvironmentVariableIfExists("GTEST_SHARD_INDEX")); |
| 624 | 624 |
| 625 if (command_line->HasSwitch(kGTestRepeatFlag) && | 625 if (command_line->HasSwitch(kGTestRepeatFlag) && |
| 626 !StringToInt(command_line->GetSwitchValueASCII(kGTestRepeatFlag), | 626 !StringToInt(command_line->GetSwitchValueASCII(kGTestRepeatFlag), |
| 627 &cycles_)) { | 627 &cycles_)) { |
| 628 LOG(ERROR) << "Invalid value for " << kGTestRepeatFlag; | 628 LOG(ERROR) << "Invalid value for " << kGTestRepeatFlag; |
| 629 return false; | 629 return false; |
| 630 } | 630 } |
| 631 | 631 |
| 632 if (CommandLine::ForCurrentProcess()->HasSwitch( | 632 if (command_line->HasSwitch(switches::kTestLauncherRetryLimit)) { |
| 633 switches::kTestLauncherRetryLimit)) { | |
| 634 int retry_limit = -1; | 633 int retry_limit = -1; |
| 635 if (!StringToInt(CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 634 if (!StringToInt(command_line->GetSwitchValueASCII( |
| 636 switches::kTestLauncherRetryLimit), &retry_limit) || | 635 switches::kTestLauncherRetryLimit), &retry_limit) || |
| 637 retry_limit < 0) { | 636 retry_limit < 0) { |
| 638 LOG(ERROR) << "Invalid value for " << switches::kTestLauncherRetryLimit; | 637 LOG(ERROR) << "Invalid value for " << switches::kTestLauncherRetryLimit; |
| 639 return false; | 638 return false; |
| 640 } | 639 } |
| 641 | 640 |
| 642 retry_limit_ = retry_limit; | 641 retry_limit_ = retry_limit; |
| 643 } else if (!CommandLine::ForCurrentProcess()->HasSwitch(kGTestFilterFlag)) { | 642 } else if (!command_line->HasSwitch(kGTestFilterFlag) || BotModeEnabled()) { |
| 644 // Retry failures 3 times by default if we are running all of the tests. | 643 // Retry failures 3 times by default if we are running all of the tests or |
| 644 // in bot mode. |
| 645 retry_limit_ = 3; | 645 retry_limit_ = 3; |
| 646 } | 646 } |
| 647 | 647 |
| 648 if (CommandLine::ForCurrentProcess()->HasSwitch( | 648 if (command_line->HasSwitch(switches::kTestLauncherJobs)) { |
| 649 switches::kTestLauncherJobs)) { | |
| 650 int jobs = -1; | 649 int jobs = -1; |
| 651 if (!StringToInt(CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 650 if (!StringToInt(command_line->GetSwitchValueASCII( |
| 652 switches::kTestLauncherJobs), &jobs) || | 651 switches::kTestLauncherJobs), &jobs) || |
| 653 jobs < 0) { | 652 jobs < 0) { |
| 654 LOG(ERROR) << "Invalid value for " << switches::kTestLauncherJobs; | 653 LOG(ERROR) << "Invalid value for " << switches::kTestLauncherJobs; |
| 655 return false; | 654 return false; |
| 656 } | 655 } |
| 657 | 656 |
| 658 parallel_jobs_ = jobs; | 657 parallel_jobs_ = jobs; |
| 659 } else if (CommandLine::ForCurrentProcess()->HasSwitch(kGTestFilterFlag)) { | 658 } else if (command_line->HasSwitch(kGTestFilterFlag) && !BotModeEnabled()) { |
| 660 // Do not run jobs in parallel by default if we are running a subset of | 659 // Do not run jobs in parallel by default if we are running a subset of |
| 661 // the tests. | 660 // the tests and if bot mode is off. |
| 662 parallel_jobs_ = 1; | 661 parallel_jobs_ = 1; |
| 663 } | 662 } |
| 664 | 663 |
| 665 fprintf(stdout, "Using %" PRIuS " parallel jobs.\n", parallel_jobs_); | 664 fprintf(stdout, "Using %" PRIuS " parallel jobs.\n", parallel_jobs_); |
| 666 fflush(stdout); | 665 fflush(stdout); |
| 667 worker_pool_owner_.reset( | 666 worker_pool_owner_.reset( |
| 668 new SequencedWorkerPoolOwner(parallel_jobs_, "test_launcher")); | 667 new SequencedWorkerPoolOwner(parallel_jobs_, "test_launcher")); |
| 669 | 668 |
| 670 if (command_line->HasSwitch(switches::kTestLauncherFilterFile) && | 669 if (command_line->HasSwitch(switches::kTestLauncherFilterFile) && |
| 671 command_line->HasSwitch(kGTestFilterFlag)) { | 670 command_line->HasSwitch(kGTestFilterFlag)) { |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1096 | 1095 |
| 1097 g_live_processes.Get().erase(process_handle); | 1096 g_live_processes.Get().erase(process_handle); |
| 1098 } | 1097 } |
| 1099 | 1098 |
| 1100 base::CloseProcessHandle(process_handle); | 1099 base::CloseProcessHandle(process_handle); |
| 1101 | 1100 |
| 1102 return exit_code; | 1101 return exit_code; |
| 1103 } | 1102 } |
| 1104 | 1103 |
| 1105 } // namespace base | 1104 } // namespace base |
| OLD | NEW |