diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-28 21:54:54 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-28 21:54:54 +0000 |
commit | 0f79893bfd2a3c5bcc20bd32ad9b509f0e157115 (patch) | |
tree | 5f1beae95511cadcc73e61cb2905e272b5f772dd | |
parent | a30d4f91f32506e82e9edd45133632a5340f9920 (diff) | |
download | chromium_src-0f79893bfd2a3c5bcc20bd32ad9b509f0e157115.zip chromium_src-0f79893bfd2a3c5bcc20bd32ad9b509f0e157115.tar.gz chromium_src-0f79893bfd2a3c5bcc20bd32ad9b509f0e157115.tar.bz2 |
Revert "Revert 231359 "GTTF: make sharding_supervisor.py use --brave-new...""
This reverts commit 94094b6f47c929e5ebaa54eb2627c93e7367399f.
Looks like interactive_ui_tests passed on the next build that didn't have the revert yet.
TBR=maruel
BUG=236893
Review URL: https://codereview.chromium.org/49843003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231418 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/base_unittests.isolate | 4 | ||||
-rw-r--r-- | base/test/launcher/test_launcher.cc | 3 | ||||
-rw-r--r-- | base/test/launcher/test_launcher.h | 10 | ||||
-rw-r--r-- | base/test/launcher/unit_test_launcher.cc | 6 | ||||
-rw-r--r-- | chrome/browser_tests.isolate | 4 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 34 | ||||
-rw-r--r-- | chrome/interactive_ui_tests.isolate | 4 | ||||
-rw-r--r-- | chrome/sync_integration_tests.isolate | 2 | ||||
-rw-r--r-- | chrome/test/base/browser_tests_main.cc | 11 | ||||
-rw-r--r-- | chrome/test/base/chrome_test_launcher.cc | 28 | ||||
-rw-r--r-- | chrome/test/base/chrome_test_launcher.h | 13 | ||||
-rw-r--r-- | chrome/test/base/interactive_ui_tests_main.cc | 41 | ||||
-rw-r--r-- | chrome/unit_tests.isolate | 4 | ||||
-rw-r--r-- | content/content_browsertests.isolate | 2 | ||||
-rw-r--r-- | content/content_unittests.isolate | 6 | ||||
-rw-r--r-- | content/public/test/test_launcher.cc | 106 | ||||
-rw-r--r-- | content/public/test/test_launcher.h | 4 | ||||
-rw-r--r-- | content/test/content_test_launcher.cc | 4 | ||||
-rw-r--r-- | net/net_unittests.isolate | 2 | ||||
-rwxr-xr-x | tools/sharding_supervisor/sharding_supervisor.py | 71 |
20 files changed, 204 insertions, 155 deletions
diff --git a/base/base_unittests.isolate b/base/base_unittests.isolate index 0b140dd..dd9e6b8 100644 --- a/base/base_unittests.isolate +++ b/base/base_unittests.isolate @@ -16,8 +16,8 @@ 'command': [ '../testing/xvfb.py', '<(PRODUCT_DIR)', - '../tools/swarm_client/googletest/run_test_cases.py', '<(PRODUCT_DIR)/base_unittests<(EXECUTABLE_SUFFIX)', + '--brave-new-test-launcher', ], 'isolate_dependency_tracked': [ '../testing/xvfb.py', @@ -40,8 +40,8 @@ 'variables': { 'command': [ '../testing/test_env.py', - '../tools/swarm_client/googletest/run_test_cases.py', '<(PRODUCT_DIR)/base_unittests<(EXECUTABLE_SUFFIX)', + '--brave-new-test-launcher', ], }, }], diff --git a/base/test/launcher/test_launcher.cc b/base/test/launcher/test_launcher.cc index f2766a7..9c06a1a 100644 --- a/base/test/launcher/test_launcher.cc +++ b/base/test/launcher/test_launcher.cc @@ -461,8 +461,7 @@ void TestLauncher::RunTests() { } } - test_started_count_ = test_names.size(); - launcher_delegate_->RunTests(this, test_names); + test_started_count_ = launcher_delegate_->RunTests(this, test_names); if (test_started_count_ == 0) { fprintf(stdout, "0 tests run\n"); diff --git a/base/test/launcher/test_launcher.h b/base/test/launcher/test_launcher.h index 10bb266..eee9851 100644 --- a/base/test/launcher/test_launcher.h +++ b/base/test/launcher/test_launcher.h @@ -58,10 +58,12 @@ class TestLauncherDelegate { const testing::TestInfo* test_info) = 0; // Called to make the delegate run the specified tests. The delegate must - // call |test_launcher|'s OnTestFinished method once per every test in - // |test_names|, regardless of its success. - virtual void RunTests(TestLauncher* test_launcher, - const std::vector<std::string>& test_names) = 0; + // return the number of actual tests it's going to run (can be smaller, + // equal to, or larger than size of |test_names|). It must also call + // |test_launcher|'s OnTestFinished method once per every run test, + // regardless of its success. + virtual size_t RunTests(TestLauncher* test_launcher, + const std::vector<std::string>& test_names) = 0; // Called to make the delegate retry the specified tests. The delegate must // return the number of actual tests it's going to retry (can be smaller, diff --git a/base/test/launcher/unit_test_launcher.cc b/base/test/launcher/unit_test_launcher.cc index 7db94bf..63c64c9 100644 --- a/base/test/launcher/unit_test_launcher.cc +++ b/base/test/launcher/unit_test_launcher.cc @@ -115,8 +115,8 @@ class UnitTestLauncherDelegate : public TestLauncherDelegate { return true; } - virtual void RunTests(TestLauncher* test_launcher, - const std::vector<std::string>& test_names) OVERRIDE { + virtual size_t RunTests(TestLauncher* test_launcher, + const std::vector<std::string>& test_names) OVERRIDE { DCHECK(thread_checker_.CalledOnValidThread()); std::vector<std::string> batch; @@ -130,6 +130,8 @@ class UnitTestLauncherDelegate : public TestLauncherDelegate { } RunBatch(test_launcher, batch); + + return test_names.size(); } virtual size_t RetryTests( diff --git a/chrome/browser_tests.isolate b/chrome/browser_tests.isolate index f6978b4..150f018 100644 --- a/chrome/browser_tests.isolate +++ b/chrome/browser_tests.isolate @@ -8,8 +8,6 @@ 'command': [ '../testing/xvfb.py', '<(PRODUCT_DIR)', - '../tools/swarm_client/googletest/run_test_cases.py', - '--use-less-jobs', '<(PRODUCT_DIR)/browser_tests<(EXECUTABLE_SUFFIX)', ], 'isolate_dependency_tracked': [ @@ -129,8 +127,6 @@ 'variables': { 'command': [ '../testing/test_env.py', - '../tools/swarm_client/googletest/run_test_cases.py', - '--use-less-jobs', '<(PRODUCT_DIR)/browser_tests<(EXECUTABLE_SUFFIX)', ], }, diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 0497476..6936edd 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -74,6 +74,24 @@ ], 'targets': [ { + 'target_name': 'test_support_chrome', + 'type': 'static_library', + 'dependencies': [ + 'test_support_common', + '../testing/gtest.gyp:gtest', + ], + 'export_dependent_settings': [ + 'test_support_common', + ], + 'include_dirs': [ + '..', + ], + 'sources': [ + 'test/base/chrome_test_launcher.cc', + 'test/base/chrome_test_launcher.h', + ], + }, + { 'target_name': 'test_support_ui_runner', 'type': 'static_library', 'dependencies': [ @@ -151,6 +169,7 @@ 'common/extensions/api/api.gyp:api', 'debugger', 'renderer', + 'test_support_chrome', 'test_support_common', # NOTE: don't add test_support_ui, no more UITests. See # http://crbug.com/137365 @@ -178,7 +197,6 @@ ], 'defines': [ 'HAS_OUT_OF_PROC_TEST_RUNNER', - 'INTERACTIVE_TESTS', ], 'variables': { 'win_use_external_manifest': 1, @@ -266,7 +284,6 @@ 'browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc', 'browser/ui/views/tabs/tab_drag_controller_interactive_uitest.h', 'browser/ui/views/tabs/tab_drag_controller_interactive_uitest_win.cc', - 'test/base/chrome_test_launcher.cc', 'test/base/interactive_test_utils.cc', 'test/base/interactive_test_utils.h', 'test/base/interactive_test_utils_aura.cc', @@ -275,6 +292,7 @@ 'test/base/interactive_test_utils_mac.mm', 'test/base/interactive_test_utils_views.cc', 'test/base/interactive_test_utils_win.cc', + 'test/base/interactive_ui_tests_main.cc', 'test/base/view_event_test_base.cc', 'test/base/view_event_test_base.h', 'test/ppapi/ppapi_interactive_browsertest.cc', @@ -922,6 +940,7 @@ 'common/extensions/api/api.gyp:api', 'renderer', 'test/perf/perf_test.gyp:*', + 'test_support_chrome', 'test_support_common', 'test_support_unit', '../base/base.gyp:base', @@ -1541,9 +1560,9 @@ 'renderer/safe_browsing/phishing_dom_feature_extractor_browsertest.cc', 'renderer/translate/translate_helper_browsertest.cc', 'renderer/translate/translate_script_browsertest.cc', + 'test/base/browser_tests_main.cc', 'test/base/chrome_render_view_test.cc', 'test/base/chrome_render_view_test.h', - 'test/base/chrome_test_launcher.cc', 'test/base/web_ui_browsertest.cc', 'test/base/web_ui_browsertest.h', 'test/base/in_process_browser_test_browsertest.cc', @@ -2000,6 +2019,7 @@ 'chrome_resources.gyp:packed_resources', 'renderer', 'test/perf/perf_test.gyp:*', + 'test_support_chrome', 'test_support_common', '../base/base.gyp:base', '../base/base.gyp:base_i18n', @@ -2036,9 +2056,9 @@ 'browser/extensions/extension_apitest.cc', 'browser/extensions/extension_browsertest.cc', 'browser/extensions/extension_test_notification_observer.cc', + 'test/base/browser_tests_main.cc', 'test/base/chrome_render_view_test.cc', 'test/base/chrome_render_view_test.h', - 'test/base/chrome_test_launcher.cc', 'test/perf/browser_perf_test.cc', 'test/perf/browser_perf_test.h', 'test/perf/rendering/throughput_tests.cc', @@ -2267,6 +2287,7 @@ 'common', 'common/extensions/api/api.gyp:api', 'renderer', + 'test_support_chrome', 'test_support_common', '../net/net.gyp:net', '../printing/printing.gyp:printing', @@ -2295,7 +2316,7 @@ 'app/chrome_dll.rc', 'app/chrome_dll_resource.h', 'app/chrome_version.rc.version', - 'test/base/chrome_test_launcher.cc', + 'test/base/browser_tests_main.cc', 'test/data/resource.rc', 'browser/sync/test/integration/apps_helper.cc', 'browser/sync/test/integration/apps_helper.h', @@ -2447,6 +2468,7 @@ 'chrome', 'common/extensions/api/api.gyp:api', 'test/perf/perf_test.gyp:*', + 'test_support_chrome', 'test_support_common', '../skia/skia.gyp:skia', '../sync/sync.gyp:sync', @@ -2498,7 +2520,7 @@ 'browser/sync/test/integration/sync_test.h', 'browser/sync/test/integration/typed_urls_helper.cc', 'browser/sync/test/integration/typed_urls_helper.h', - 'test/base/chrome_test_launcher.cc', + 'test/base/browser_tests_main.cc', 'test/data/resource.rc', ], 'conditions': [ diff --git a/chrome/interactive_ui_tests.isolate b/chrome/interactive_ui_tests.isolate index 057e0b9..7f9fc0e 100644 --- a/chrome/interactive_ui_tests.isolate +++ b/chrome/interactive_ui_tests.isolate @@ -8,8 +8,6 @@ 'command': [ '../testing/xvfb.py', '<(PRODUCT_DIR)', - '../tools/swarm_client/googletest/run_test_cases.py', - '-j1', '<(PRODUCT_DIR)/interactive_ui_tests<(EXECUTABLE_SUFFIX)', ], 'isolate_dependency_tracked': [ @@ -67,8 +65,6 @@ 'variables': { 'command': [ '../testing/test_env.py', - '../tools/swarm_client/googletest/run_test_cases.py', - '-j1', '<(PRODUCT_DIR)/interactive_ui_tests<(EXECUTABLE_SUFFIX)', ], }, diff --git a/chrome/sync_integration_tests.isolate b/chrome/sync_integration_tests.isolate index 5aa2463..3861306 100644 --- a/chrome/sync_integration_tests.isolate +++ b/chrome/sync_integration_tests.isolate @@ -8,7 +8,6 @@ 'command': [ '../testing/xvfb.py', '<(PRODUCT_DIR)', - '../tools/swarm_client/googletest/run_test_cases.py', '<(PRODUCT_DIR)/sync_integration_tests<(EXECUTABLE_SUFFIX)', ], 'isolate_dependency_tracked': [ @@ -52,7 +51,6 @@ ['OS=="mac"', { 'variables': { 'command': [ - '../tools/swarm_client/googletest/run_test_cases.py', '<(PRODUCT_DIR)/sync_integration_tests<(EXECUTABLE_SUFFIX)', ], 'isolate_dependency_tracked': [ diff --git a/chrome/test/base/browser_tests_main.cc b/chrome/test/base/browser_tests_main.cc new file mode 100644 index 0000000..cb2acce --- /dev/null +++ b/chrome/test/base/browser_tests_main.cc @@ -0,0 +1,11 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/sys_info.h" +#include "chrome/test/base/chrome_test_launcher.h" + +int main(int argc, char** argv) { + int default_jobs = std::max(1, base::SysInfo::NumberOfProcessors() / 2); + return LaunchChromeTests(default_jobs, argc, argv); +} diff --git a/chrome/test/base/chrome_test_launcher.cc b/chrome/test/base/chrome_test_launcher.cc index 345f504..f14ace3 100644 --- a/chrome/test/base/chrome_test_launcher.cc +++ b/chrome/test/base/chrome_test_launcher.cc @@ -55,6 +55,8 @@ #include "chrome/app/chrome_breakpad_client.h" #endif +namespace { + class ChromeTestLauncherDelegate : public content::TestLauncherDelegate { public: ChromeTestLauncherDelegate() {} @@ -126,31 +128,13 @@ class ChromeTestLauncherDelegate : public content::TestLauncherDelegate { DISALLOW_COPY_AND_ASSIGN(ChromeTestLauncherDelegate); }; -int main(int argc, char** argv) { +} // namespace + +int LaunchChromeTests(int default_jobs, int argc, char** argv) { #if defined(OS_MACOSX) chrome_browser_application_mac::RegisterBrowserCrApp(); #endif -// Only allow ui_controls to be used in interactive_ui_tests, since they depend -// on focus and can't be sharded. -#if defined(INTERACTIVE_TESTS) - ui_controls::EnableUIControls(); - -#if defined(OS_CHROMEOS) - ui_controls::InstallUIControlsAura(ash::test::CreateAshUIControls()); -#elif defined(USE_AURA) - -#if defined(OS_LINUX) - ui_controls::InstallUIControlsAura( - views::test::CreateUIControlsDesktopAura()); -#else - // TODO(win_ash): when running interactive_ui_tests for Win Ash, use above. - ui_controls::InstallUIControlsAura(aura::test::CreateUIControlsAura(NULL)); -#endif -#endif - -#endif - #if defined(OS_LINUX) || defined(OS_ANDROID) // We leak this pointer intentionally. The breakpad client needs to outlive // all other code. @@ -161,5 +145,5 @@ int main(int argc, char** argv) { #endif ChromeTestLauncherDelegate launcher_delegate; - return content::LaunchTests(&launcher_delegate, argc, argv); + return content::LaunchTests(&launcher_delegate, default_jobs, argc, argv); } diff --git a/chrome/test/base/chrome_test_launcher.h b/chrome/test/base/chrome_test_launcher.h new file mode 100644 index 0000000..b9254d3 --- /dev/null +++ b/chrome/test/base/chrome_test_launcher.h @@ -0,0 +1,13 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_TEST_BASE_CHROME_TEST_LAUNCHER_H_ +#define CHROME_TEST_BASE_CHROME_TEST_LAUNCHER_H_ + +// Launches Chrome tests using |launcher_delegate|. |default_jobs| is number +// of test jobs to be run in parallel, unless overridden from the command line. +// Returns exit code. +int LaunchChromeTests(int default_jobs, int argc, char** argv); + +#endif // CHROME_TEST_BASE_CHROME_TEST_LAUNCHER_H_ diff --git a/chrome/test/base/interactive_ui_tests_main.cc b/chrome/test/base/interactive_ui_tests_main.cc new file mode 100644 index 0000000..8de925a --- /dev/null +++ b/chrome/test/base/interactive_ui_tests_main.cc @@ -0,0 +1,41 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/test/base/chrome_test_launcher.h" + +#include "ui/base/test/ui_controls.h" + +#if defined(USE_AURA) +#include "ui/aura/test/ui_controls_factory_aura.h" +#include "ui/base/test/ui_controls_aura.h" +#if defined(OS_LINUX) && !defined(OS_CHROMEOS) +#include "ui/views/test/ui_controls_factory_desktop_aurax11.h" +#endif +#endif + +#if defined(OS_CHROMEOS) +#include "ash/test/ui_controls_factory_ash.h" +#endif + +int main(int argc, char** argv) { + // Only allow ui_controls to be used in interactive_ui_tests, since they + // depend on focus and can't be sharded. + ui_controls::EnableUIControls(); + +#if defined(OS_CHROMEOS) + ui_controls::InstallUIControlsAura(ash::test::CreateAshUIControls()); +#elif defined(USE_AURA) + +#if defined(OS_LINUX) + ui_controls::InstallUIControlsAura( + views::test::CreateUIControlsDesktopAura()); +#else + // TODO(win_ash): when running interactive_ui_tests for Win Ash, use above. + ui_controls::InstallUIControlsAura(aura::test::CreateUIControlsAura(NULL)); +#endif +#endif + + // Run interactive_ui_tests serially, they do not support running in parallel. + return LaunchChromeTests(1, argc, argv); +} diff --git a/chrome/unit_tests.isolate b/chrome/unit_tests.isolate index 71bab21..3f077d6 100644 --- a/chrome/unit_tests.isolate +++ b/chrome/unit_tests.isolate @@ -41,8 +41,8 @@ 'command': [ '../testing/xvfb.py', '<(PRODUCT_DIR)', - '../tools/swarm_client/googletest/run_test_cases.py', '<(PRODUCT_DIR)/unit_tests<(EXECUTABLE_SUFFIX)', + '--brave-new-test-launcher', ], 'isolate_dependency_tracked': [ '../testing/xvfb.py', @@ -86,8 +86,8 @@ 'variables': { 'command': [ '../testing/test_env.py', - '../tools/swarm_client/googletest/run_test_cases.py', '<(PRODUCT_DIR)/unit_tests<(EXECUTABLE_SUFFIX)', + '--brave-new-test-launcher', ], 'isolate_dependency_untracked': [ '<(PRODUCT_DIR)/test_data/chrome/browser/resources/google_now/', diff --git a/content/content_browsertests.isolate b/content/content_browsertests.isolate index 7312750..975c39e 100644 --- a/content/content_browsertests.isolate +++ b/content/content_browsertests.isolate @@ -26,7 +26,6 @@ 'command': [ '../testing/xvfb.py', '<(PRODUCT_DIR)', - '../tools/swarm_client/googletest/run_test_cases.py', '<(PRODUCT_DIR)/content_browsertests<(EXECUTABLE_SUFFIX)', ], 'isolate_dependency_tracked': [ @@ -76,7 +75,6 @@ 'variables': { 'command': [ '../testing/test_env.py', - '../tools/swarm_client/googletest/run_test_cases.py', '<(PRODUCT_DIR)/content_browsertests<(EXECUTABLE_SUFFIX)', ], }, diff --git a/content/content_unittests.isolate b/content/content_unittests.isolate index 780aefb..92a448b 100644 --- a/content/content_unittests.isolate +++ b/content/content_unittests.isolate @@ -35,8 +35,8 @@ 'command': [ '../testing/xvfb.py', '<(PRODUCT_DIR)', - '../tools/swarm_client/googletest/run_test_cases.py', '<(PRODUCT_DIR)/content_unittests<(EXECUTABLE_SUFFIX)', + '--brave-new-test-launcher', ], 'isolate_dependency_tracked': [ '../testing/xvfb.py', @@ -49,8 +49,8 @@ 'variables': { 'command': [ '../testing/test_env.py', - '../tools/swarm_client/googletest/run_test_cases.py', '<(PRODUCT_DIR)/content_unittests<(EXECUTABLE_SUFFIX)', + '--brave-new-test-launcher', ], 'isolate_dependency_tracked': [ '<(PRODUCT_DIR)/ffmpegsumo.so', @@ -61,8 +61,8 @@ 'variables': { 'command': [ '../testing/test_env.py', - '../tools/swarm_client/googletest/run_test_cases.py', '<(PRODUCT_DIR)/content_unittests<(EXECUTABLE_SUFFIX)', + '--brave-new-test-launcher', ], 'isolate_dependency_tracked': [ '<(PRODUCT_DIR)/aura_test_support_resources.pak', diff --git a/content/public/test/test_launcher.cc b/content/public/test/test_launcher.cc index 31dbef2..6e643ec 100644 --- a/content/public/test/test_launcher.cc +++ b/content/public/test/test_launcher.cc @@ -103,8 +103,8 @@ class WrapperTestLauncherDelegate : public base::TestLauncherDelegate { const testing::TestInfo* test_info) OVERRIDE; virtual bool ShouldRunTest(const testing::TestCase* test_case, const testing::TestInfo* test_info) OVERRIDE; - virtual void RunTests(base::TestLauncher* test_launcher, - const std::vector<std::string>& test_names) OVERRIDE; + virtual size_t RunTests(base::TestLauncher* test_launcher, + const std::vector<std::string>& test_names) OVERRIDE; virtual size_t RetryTests( base::TestLauncher* test_launcher, const std::vector<std::string>& test_names) OVERRIDE; @@ -153,6 +153,9 @@ class WrapperTestLauncherDelegate : public base::TestLauncherDelegate { typedef std::map<std::string, base::FilePath> UserDataDirMap; UserDataDirMap user_data_dir_map_; + // Store names of all seen tests to properly handle PRE_ tests. + std::set<std::string> all_test_names_; + // Temporary directory for user data directories. base::ScopedTempDir temp_dir_; @@ -174,11 +177,20 @@ std::string WrapperTestLauncherDelegate::GetTestNameForFiltering( bool WrapperTestLauncherDelegate::ShouldRunTest( const testing::TestCase* test_case, const testing::TestInfo* test_info) { + all_test_names_.insert( + std::string(test_case->name()) + "." + test_info->name()); + if (StartsWithASCII(test_info->name(), kManualTestPrefix, true) && !CommandLine::ForCurrentProcess()->HasSwitch(kRunManualTestsFlag)) { return false; } + if (StartsWithASCII(test_info->name(), kPreTestPrefix, true)) { + // We will actually run PRE_ tests, but to ensure they run on the same shard + // as dependent tests, handle all these details internally. + return false; + } + // Stop test execution after too many timeouts. if (timeout_count_ > 5) { if (!printed_timeout_message_) { @@ -191,46 +203,60 @@ bool WrapperTestLauncherDelegate::ShouldRunTest( return true; } -void WrapperTestLauncherDelegate::RunTests( +std::string GetPreTestName(const std::string& full_name) { + size_t dot_pos = full_name.find('.'); + CHECK_NE(dot_pos, std::string::npos); + std::string test_case_name = full_name.substr(0, dot_pos); + std::string test_name = full_name.substr(dot_pos + 1); + return test_case_name + "." + kPreTestPrefix + test_name; +} + +size_t WrapperTestLauncherDelegate::RunTests( base::TestLauncher* test_launcher, const std::vector<std::string>& test_names) { - // List of tests we can kick off right now, depending on no other tests. - std::vector<std::string> tests_to_run_now; - - std::set<std::string> test_names_set(test_names.begin(), test_names.end()); + // Number of additional tests to run because of dependencies. + size_t additional_tests_to_run_count = 0; + // Compute dependencies of tests to be run. for (size_t i = 0; i < test_names.size(); i++) { std::string full_name(test_names[i]); + std::string pre_test_name(GetPreTestName(full_name)); - // Make sure PRE_ tests and tests that depend on them share the same - // data directory - based it on the test name without prefixes. - std::string test_name_no_pre(RemoveAnyPrePrefixes(full_name)); - if (!ContainsKey(user_data_dir_map_, test_name_no_pre)) { - base::FilePath temp_dir; - CHECK(file_util::CreateTemporaryDirInDir( - temp_dir_.path(), FILE_PATH_LITERAL("d"), &temp_dir)); - user_data_dir_map_[test_name_no_pre] = temp_dir; - } + while (ContainsKey(all_test_names_, pre_test_name)) { + additional_tests_to_run_count++; - size_t dot_pos = full_name.find('.'); - CHECK_NE(dot_pos, std::string::npos); - std::string test_case_name = full_name.substr(0, dot_pos); - std::string test_name = full_name.substr(dot_pos + 1); - std::string pre_test_name( - test_case_name + "." + kPreTestPrefix + test_name); - if (ContainsKey(test_names_set, pre_test_name)) { DCHECK(!ContainsKey(dependent_test_map_, pre_test_name)); dependent_test_map_[pre_test_name] = full_name; DCHECK(!ContainsKey(reverse_dependent_test_map_, full_name)); reverse_dependent_test_map_[full_name] = pre_test_name; - } else { - tests_to_run_now.push_back(full_name); + + full_name = pre_test_name; + pre_test_name = GetPreTestName(pre_test_name); } } - for (size_t i = 0; i < tests_to_run_now.size(); i++) - DoRunTest(test_launcher, tests_to_run_now[i]); + for (size_t i = 0; i < test_names.size(); i++) { + std::string full_name(test_names[i]); + + // Make sure no PRE_ tests were requested explicitly. + DCHECK_EQ(full_name, RemoveAnyPrePrefixes(full_name)); + + if (!ContainsKey(user_data_dir_map_, full_name)) { + base::FilePath temp_dir; + CHECK(file_util::CreateTemporaryDirInDir( + temp_dir_.path(), FILE_PATH_LITERAL("d"), &temp_dir)); + user_data_dir_map_[full_name] = temp_dir; + } + + // If the test has any dependencies, get to the root and start with that. + while (ContainsKey(reverse_dependent_test_map_, full_name)) + full_name = GetPreTestName(full_name); + + DoRunTest(test_launcher, full_name); + } + + return test_names.size() + additional_tests_to_run_count; } size_t WrapperTestLauncherDelegate::RetryTests( @@ -367,10 +393,7 @@ void WrapperTestLauncherDelegate::GTestCallback( result.elapsed_time = elapsed_time; - // TODO(phajdan.jr): Use base::PrintTestOutputSnippetOnFailure after migrating - // away from run_test_cases.py (http://crbug.com/236893). - fprintf(stdout, "%s", output.c_str()); - fflush(stdout); + result.output_snippet = GetTestOutputSnippet(result, output); if (ContainsKey(dependent_test_map_, test_name)) RunDependentTest(test_launcher, dependent_test_map_[test_name], result); @@ -439,6 +462,7 @@ int RunContentMain(int argc, char** argv, } int LaunchTests(TestLauncherDelegate* launcher_delegate, + int default_jobs, int argc, char** argv) { DCHECK(!g_launcher_delegate); @@ -470,23 +494,23 @@ int LaunchTests(TestLauncherDelegate* launcher_delegate, if (ShouldRunContentMain()) return RunContentMain(argc, argv, launcher_delegate); - fprintf(stdout, - "Starting tests...\n" - "IMPORTANT DEBUGGING NOTE: each test is run inside its own process.\n" - "For debugging a test inside a debugger, use the\n" - "--gtest_filter=<your_test_name> flag along with either\n" - "--single_process (to run the test in one launcher/browser process) or\n" - "--single-process (to do the above, and also run Chrome in single-" - "process mode).\n"); - base::AtExitManager at_exit; testing::InitGoogleTest(&argc, argv); TestTimeouts::Initialize(); - int jobs = 1; // TODO(phajdan.jr): Default to half the number of CPU cores. + int jobs = default_jobs; if (!GetSwitchValueAsInt(switches::kTestLauncherJobs, &jobs)) return 1; + fprintf(stdout, + "Starting tests (using %d parallel jobs)...\n" + "IMPORTANT DEBUGGING NOTE: each test is run inside its own process.\n" + "For debugging a test inside a debugger, use the\n" + "--gtest_filter=<your_test_name> flag along with either\n" + "--single_process (to run the test in one launcher/browser process) or\n" + "--single-process (to do the above, and also run Chrome in single-" + "process mode).\n", jobs); + base::MessageLoopForIO message_loop; WrapperTestLauncherDelegate delegate(launcher_delegate, jobs); diff --git a/content/public/test/test_launcher.h b/content/public/test/test_launcher.h index df3f56c..268eab5 100644 --- a/content/public/test/test_launcher.h +++ b/content/public/test/test_launcher.h @@ -43,7 +43,11 @@ class TestLauncherDelegate { virtual ~TestLauncherDelegate(); }; +// Launches tests using |launcher_delegate|. |default_jobs| is number +// of test jobs to be run in parallel, unless overridden from the command line. +// Returns exit code. int LaunchTests(TestLauncherDelegate* launcher_delegate, + int default_jobs, int argc, char** argv) WARN_UNUSED_RESULT; diff --git a/content/test/content_test_launcher.cc b/content/test/content_test_launcher.cc index 9a229a9..fae46c8 100644 --- a/content/test/content_test_launcher.cc +++ b/content/test/content_test_launcher.cc @@ -8,6 +8,7 @@ #include "base/command_line.h" #include "base/logging.h" #include "base/path_service.h" +#include "base/sys_info.h" #include "base/test/test_suite.h" #include "content/public/common/content_switches.h" #include "content/public/test/content_test_suite_base.h" @@ -127,6 +128,7 @@ class ContentTestLauncherDelegate : public TestLauncherDelegate { } // namespace content int main(int argc, char** argv) { + int default_jobs = std::max(1, base::SysInfo::NumberOfProcessors() / 2); content::ContentTestLauncherDelegate launcher_delegate; - return LaunchTests(&launcher_delegate, argc, argv); + return LaunchTests(&launcher_delegate, default_jobs, argc, argv); } diff --git a/net/net_unittests.isolate b/net/net_unittests.isolate index 61b8c47..2d120bf 100644 --- a/net/net_unittests.isolate +++ b/net/net_unittests.isolate @@ -20,8 +20,8 @@ 'variables': { 'command': [ '../testing/test_env.py', - '../tools/swarm_client/googletest/run_test_cases.py', '<(PRODUCT_DIR)/net_unittests<(EXECUTABLE_SUFFIX)', + '--brave-new-test-launcher', ], 'isolate_dependency_tracked': [ '../testing/test_env.py', diff --git a/tools/sharding_supervisor/sharding_supervisor.py b/tools/sharding_supervisor/sharding_supervisor.py index 9967071..20d7db7 100755 --- a/tools/sharding_supervisor/sharding_supervisor.py +++ b/tools/sharding_supervisor/sharding_supervisor.py @@ -3,49 +3,13 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -"""Defer to run_test_cases.py.""" +"""Defer to --brave-new-test-launcher.""" import os import optparse +import subprocess import sys -ROOT_DIR = os.path.dirname( - os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - - -def pop_known_arguments(args): - """Extracts known arguments from the args if present.""" - rest = [] - run_test_cases_extra_args = [] - for arg in args: - if arg.startswith(('--gtest_filter=', '--gtest_output=', '--clusters=')): - run_test_cases_extra_args.append(arg) - elif arg in ('--run-manual', '--verbose'): - run_test_cases_extra_args.append(arg) - elif arg == '--gtest_print_time': - # Ignore. - pass - elif 'interactive_ui_tests' in arg: - # Run this test in a single thread. It is useful to run it under - # run_test_cases so automatic flaky test workaround is still used. - run_test_cases_extra_args.append('-j1') - rest.append(arg) - elif 'browser_tests' in arg: - # Test cases in this executable fire up *a lot* of child processes, - # causing huge memory bottleneck. So use less than N-cpus jobs. - run_test_cases_extra_args.append('--use-less-jobs') - rest.append(arg) - else: - rest.append(arg) - - # Use --jobs arg if exist. - for arg in args: - if arg.startswith('--jobs='): - run_test_cases_extra_args.append(arg) - break - - return run_test_cases_extra_args, rest - def main(): parser = optparse.OptionParser() @@ -68,34 +32,27 @@ def main(): group.add_option( '--retries', type='int', help='Kept as --retries') group.add_option( + '-j', '--jobs', type='int', help='Number of parallel jobs') + group.add_option( + '--clusters', type='int', help='Maximum number of tests in a batch') + group.add_option( '--verbose', action='count', default=0, help='Kept as --verbose') parser.add_option_group(group) parser.disable_interspersed_args() options, args = parser.parse_args() - swarm_client_dir = os.path.join( - ROOT_DIR, 'tools', 'swarm_client', 'googletest') - sys.path.insert(0, swarm_client_dir) - - cmd = [ - '--shards', str(options.total_slaves), - '--index', str(options.slave_index), - '--no-dump', - '--no-cr', - ] - if options.timeout is not None: - cmd.extend(['--timeout', str(options.timeout)]) - if options.retries is not None: - cmd.extend(['--retries', str(options.retries)]) - if options.verbose is not None: - cmd.extend(['--verbose'] * options.verbose) + env = os.environ + env['GTEST_TOTAL_SHARDS'] = str(options.total_slaves) + env['GTEST_SHARD_INDEX'] = str(options.slave_index) - run_test_cases_extra_args, rest = pop_known_arguments(args) + if options.jobs: + args.append('--test-launcher-jobs=%d' % options.jobs) - import run_test_cases # pylint: disable=F0401 + if options.clusters: + args.append('--test-launcher-batch-limit=%d' % options.clusters) - return run_test_cases.main(cmd + run_test_cases_extra_args + ['--'] + rest) + return subprocess.Popen(args + ['--brave-new-test-launcher'], env=env).wait() if __name__ == '__main__': |