| 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/unit_test_launcher.h" | 5 #include "base/test/launcher/unit_test_launcher.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/debug/debugger.h" | 11 #include "base/debug/debugger.h" |
| 12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 13 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
| 14 #include "base/format_macros.h" | 14 #include "base/format_macros.h" |
| 15 #include "base/location.h" |
| 15 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 17 #include "base/single_thread_task_runner.h" |
| 16 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
| 17 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 19 #include "base/sys_info.h" | 21 #include "base/sys_info.h" |
| 20 #include "base/test/gtest_xml_util.h" | 22 #include "base/test/gtest_xml_util.h" |
| 21 #include "base/test/launcher/test_launcher.h" | 23 #include "base/test/launcher/test_launcher.h" |
| 22 #include "base/test/test_switches.h" | 24 #include "base/test/test_switches.h" |
| 23 #include "base/test/test_timeouts.h" | 25 #include "base/test/test_timeouts.h" |
| 24 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 26 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
| 27 #include "base/thread_task_runner_handle.h" |
| 25 #include "base/threading/thread_checker.h" | 28 #include "base/threading/thread_checker.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| 27 | 30 |
| 28 namespace base { | 31 namespace base { |
| 29 | 32 |
| 30 namespace { | 33 namespace { |
| 31 | 34 |
| 32 // This constant controls how many tests are run in a single batch by default. | 35 // This constant controls how many tests are run in a single batch by default. |
| 33 const size_t kDefaultTestBatchLimit = 10; | 36 const size_t kDefaultTestBatchLimit = 10; |
| 34 | 37 |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 // There is only one test, there cannot be other tests to relaunch | 401 // There is only one test, there cannot be other tests to relaunch |
| 399 // due to a crash. | 402 // due to a crash. |
| 400 DCHECK(tests_to_relaunch.empty()); | 403 DCHECK(tests_to_relaunch.empty()); |
| 401 | 404 |
| 402 // There is only one test, we should have called back with its result. | 405 // There is only one test, we should have called back with its result. |
| 403 DCHECK(called_any_callbacks); | 406 DCHECK(called_any_callbacks); |
| 404 | 407 |
| 405 // The temporary file's directory is also temporary. | 408 // The temporary file's directory is also temporary. |
| 406 DeleteFile(callback_state.output_file.DirName(), true); | 409 DeleteFile(callback_state.output_file.DirName(), true); |
| 407 | 410 |
| 408 MessageLoop::current()->PostTask( | 411 ThreadTaskRunnerHandle::Get()->PostTask( |
| 409 FROM_HERE, | 412 FROM_HERE, Bind(&RunUnitTestsSerially, callback_state.test_launcher, |
| 410 Bind(&RunUnitTestsSerially, | 413 callback_state.platform_delegate, test_names, |
| 411 callback_state.test_launcher, | 414 callback_state.launch_flags)); |
| 412 callback_state.platform_delegate, | |
| 413 test_names, | |
| 414 callback_state.launch_flags)); | |
| 415 } | 415 } |
| 416 | 416 |
| 417 } // namespace | 417 } // namespace |
| 418 | 418 |
| 419 int LaunchUnitTests(int argc, | 419 int LaunchUnitTests(int argc, |
| 420 char** argv, | 420 char** argv, |
| 421 const RunTestSuiteCallback& run_test_suite) { | 421 const RunTestSuiteCallback& run_test_suite) { |
| 422 CommandLine::Init(argc, argv); | 422 CommandLine::Init(argc, argv); |
| 423 return LaunchUnitTestsInternal(run_test_suite, SysInfo::NumberOfProcessors(), | 423 return LaunchUnitTestsInternal(run_test_suite, SysInfo::NumberOfProcessors(), |
| 424 true, Bind(&InitGoogleTestChar, &argc, argv)); | 424 true, Bind(&InitGoogleTestChar, &argc, argv)); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 } | 569 } |
| 570 | 570 |
| 571 RunUnitTestsBatch(test_launcher, platform_delegate_, batch, launch_flags); | 571 RunUnitTestsBatch(test_launcher, platform_delegate_, batch, launch_flags); |
| 572 | 572 |
| 573 return test_names.size(); | 573 return test_names.size(); |
| 574 } | 574 } |
| 575 | 575 |
| 576 size_t UnitTestLauncherDelegate::RetryTests( | 576 size_t UnitTestLauncherDelegate::RetryTests( |
| 577 TestLauncher* test_launcher, | 577 TestLauncher* test_launcher, |
| 578 const std::vector<std::string>& test_names) { | 578 const std::vector<std::string>& test_names) { |
| 579 MessageLoop::current()->PostTask( | 579 ThreadTaskRunnerHandle::Get()->PostTask( |
| 580 FROM_HERE, | 580 FROM_HERE, |
| 581 Bind(&RunUnitTestsSerially, | 581 Bind(&RunUnitTestsSerially, test_launcher, platform_delegate_, test_names, |
| 582 test_launcher, | |
| 583 platform_delegate_, | |
| 584 test_names, | |
| 585 use_job_objects_ ? TestLauncher::USE_JOB_OBJECTS : 0)); | 582 use_job_objects_ ? TestLauncher::USE_JOB_OBJECTS : 0)); |
| 586 return test_names.size(); | 583 return test_names.size(); |
| 587 } | 584 } |
| 588 | 585 |
| 589 } // namespace base | 586 } // namespace base |
| OLD | NEW |