Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: base/test/launcher/unit_test_launcher.cc

Issue 2384273002: Use FileDescriptorWatcher in base::TestLauncher. (Closed)
Patch Set: fix win_clang Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/test/launcher/test_launcher_nacl_nonsfi.cc ('k') | content/public/test/test_launcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 13 matching lines...) Expand all
24 #include "base/test/gtest_xml_util.h" 24 #include "base/test/gtest_xml_util.h"
25 #include "base/test/launcher/test_launcher.h" 25 #include "base/test/launcher/test_launcher.h"
26 #include "base/test/test_switches.h" 26 #include "base/test/test_switches.h"
27 #include "base/test/test_timeouts.h" 27 #include "base/test/test_timeouts.h"
28 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 28 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
29 #include "base/threading/thread_checker.h" 29 #include "base/threading/thread_checker.h"
30 #include "base/threading/thread_task_runner_handle.h" 30 #include "base/threading/thread_task_runner_handle.h"
31 #include "build/build_config.h" 31 #include "build/build_config.h"
32 #include "testing/gtest/include/gtest/gtest.h" 32 #include "testing/gtest/include/gtest/gtest.h"
33 33
34 #if defined(OS_POSIX)
35 #include "base/files/file_descriptor_watcher_posix.h"
36 #endif
37
34 namespace base { 38 namespace base {
35 39
36 namespace { 40 namespace {
37 41
38 // This constant controls how many tests are run in a single batch by default. 42 // This constant controls how many tests are run in a single batch by default.
39 const size_t kDefaultTestBatchLimit = 10; 43 const size_t kDefaultTestBatchLimit = 10;
40 44
41 const char kHelpFlag[] = "help"; 45 const char kHelpFlag[] = "help";
42 46
43 // Flag to run all tests in a single process. 47 // Flag to run all tests in a single process.
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 return 1; 226 return 1;
223 227
224 fprintf(stdout, 228 fprintf(stdout,
225 "IMPORTANT DEBUGGING NOTE: batches of tests are run inside their\n" 229 "IMPORTANT DEBUGGING NOTE: batches of tests are run inside their\n"
226 "own process. For debugging a test inside a debugger, use the\n" 230 "own process. For debugging a test inside a debugger, use the\n"
227 "--gtest_filter=<your_test_name> flag along with\n" 231 "--gtest_filter=<your_test_name> flag along with\n"
228 "--single-process-tests.\n"); 232 "--single-process-tests.\n");
229 fflush(stdout); 233 fflush(stdout);
230 234
231 MessageLoopForIO message_loop; 235 MessageLoopForIO message_loop;
236 #if defined(OS_POSIX)
237 FileDescriptorWatcher file_descriptor_watcher(&message_loop);
238 #endif
232 239
233 DefaultUnitTestPlatformDelegate platform_delegate; 240 DefaultUnitTestPlatformDelegate platform_delegate;
234 UnitTestLauncherDelegate delegate( 241 UnitTestLauncherDelegate delegate(
235 &platform_delegate, batch_limit, use_job_objects); 242 &platform_delegate, batch_limit, use_job_objects);
236 base::TestLauncher launcher(&delegate, default_jobs); 243 base::TestLauncher launcher(&delegate, default_jobs);
237 bool success = launcher.Run(); 244 bool success = launcher.Run();
238 245
239 fprintf(stdout, "Tests took %" PRId64 " seconds.\n", 246 fprintf(stdout, "Tests took %" PRId64 " seconds.\n",
240 (base::TimeTicks::Now() - start_time).InSeconds()); 247 (base::TimeTicks::Now() - start_time).InSeconds());
241 fflush(stdout); 248 fflush(stdout);
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 TestLauncher* test_launcher, 634 TestLauncher* test_launcher,
628 const std::vector<std::string>& test_names) { 635 const std::vector<std::string>& test_names) {
629 ThreadTaskRunnerHandle::Get()->PostTask( 636 ThreadTaskRunnerHandle::Get()->PostTask(
630 FROM_HERE, 637 FROM_HERE,
631 Bind(&RunUnitTestsSerially, test_launcher, platform_delegate_, test_names, 638 Bind(&RunUnitTestsSerially, test_launcher, platform_delegate_, test_names,
632 use_job_objects_ ? TestLauncher::USE_JOB_OBJECTS : 0)); 639 use_job_objects_ ? TestLauncher::USE_JOB_OBJECTS : 0));
633 return test_names.size(); 640 return test_names.size();
634 } 641 }
635 642
636 } // namespace base 643 } // namespace base
OLDNEW
« no previous file with comments | « base/test/launcher/test_launcher_nacl_nonsfi.cc ('k') | content/public/test/test_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698