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

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

Issue 105203003: GTTF: Enable --brave-new-test-launcher by default. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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/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"
(...skipping 14 matching lines...) Expand all
25 25
26 namespace base { 26 namespace base {
27 27
28 namespace { 28 namespace {
29 29
30 // This constant controls how many tests are run in a single batch by default. 30 // This constant controls how many tests are run in a single batch by default.
31 const size_t kDefaultTestBatchLimit = 10; 31 const size_t kDefaultTestBatchLimit = 10;
32 32
33 const char kHelpFlag[] = "help"; 33 const char kHelpFlag[] = "help";
34 34
35 // Flag to enable the new launcher logic.
36 // TODO(phajdan.jr): Remove it, http://crbug.com/236893 .
37 const char kBraveNewTestLauncherFlag[] = "brave-new-test-launcher";
38
39 // Flag to run all tests in a single process. 35 // Flag to run all tests in a single process.
40 const char kSingleProcessTestsFlag[] = "single-process-tests"; 36 const char kSingleProcessTestsFlag[] = "single-process-tests";
41 37
42 void PrintUsage() { 38 void PrintUsage() {
43 fprintf(stdout, 39 fprintf(stdout,
44 "Runs tests using the gtest framework, each batch of tests being\n" 40 "Runs tests using the gtest framework, each batch of tests being\n"
45 "run in their own process. Supported command-line flags:\n" 41 "run in their own process. Supported command-line flags:\n"
46 "\n" 42 "\n"
47 " --single-process-tests\n" 43 " --single-process-tests\n"
48 " Runs the tests and the launcher in the same process. Useful\n" 44 " Runs the tests and the launcher in the same process. Useful\n"
(...skipping 15 matching lines...) Expand all
64 // of current process. |test_names| is a vector of test full names 60 // of current process. |test_names| is a vector of test full names
65 // (e.g. "A.B"), |output_file| is path to the GTest XML output file. 61 // (e.g. "A.B"), |output_file| is path to the GTest XML output file.
66 CommandLine GetCommandLineForChildGTestProcess( 62 CommandLine GetCommandLineForChildGTestProcess(
67 const std::vector<std::string>& test_names, 63 const std::vector<std::string>& test_names,
68 const base::FilePath& output_file) { 64 const base::FilePath& output_file) {
69 CommandLine new_cmd_line(*CommandLine::ForCurrentProcess()); 65 CommandLine new_cmd_line(*CommandLine::ForCurrentProcess());
70 66
71 new_cmd_line.AppendSwitchPath(switches::kTestLauncherOutput, output_file); 67 new_cmd_line.AppendSwitchPath(switches::kTestLauncherOutput, output_file);
72 new_cmd_line.AppendSwitchASCII(kGTestFilterFlag, JoinString(test_names, ":")); 68 new_cmd_line.AppendSwitchASCII(kGTestFilterFlag, JoinString(test_names, ":"));
73 new_cmd_line.AppendSwitch(kSingleProcessTestsFlag); 69 new_cmd_line.AppendSwitch(kSingleProcessTestsFlag);
74 new_cmd_line.AppendSwitch(kBraveNewTestLauncherFlag);
75 70
76 return new_cmd_line; 71 return new_cmd_line;
77 } 72 }
78 73
79 class UnitTestLauncherDelegate : public TestLauncherDelegate { 74 class UnitTestLauncherDelegate : public TestLauncherDelegate {
80 public: 75 public:
81 explicit UnitTestLauncherDelegate(size_t batch_limit) 76 explicit UnitTestLauncherDelegate(size_t batch_limit)
82 : batch_limit_(batch_limit) { 77 : batch_limit_(batch_limit) {
83 } 78 }
84 79
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 434
440 return true; 435 return true;
441 } 436 }
442 437
443 int LaunchUnitTestsInternal(int argc, 438 int LaunchUnitTestsInternal(int argc,
444 char** argv, 439 char** argv,
445 const RunTestSuiteCallback& run_test_suite, 440 const RunTestSuiteCallback& run_test_suite,
446 int default_jobs) { 441 int default_jobs) {
447 CommandLine::Init(argc, argv); 442 CommandLine::Init(argc, argv);
448 if (CommandLine::ForCurrentProcess()->HasSwitch(kGTestHelpFlag) || 443 if (CommandLine::ForCurrentProcess()->HasSwitch(kGTestHelpFlag) ||
449 CommandLine::ForCurrentProcess()->HasSwitch(kSingleProcessTestsFlag) || 444 CommandLine::ForCurrentProcess()->HasSwitch(kSingleProcessTestsFlag)) {
450 !CommandLine::ForCurrentProcess()->HasSwitch(kBraveNewTestLauncherFlag)) {
451 return run_test_suite.Run(); 445 return run_test_suite.Run();
452 } 446 }
453 447
454 if (CommandLine::ForCurrentProcess()->HasSwitch(kHelpFlag)) { 448 if (CommandLine::ForCurrentProcess()->HasSwitch(kHelpFlag)) {
455 PrintUsage(); 449 PrintUsage();
456 return 0; 450 return 0;
457 } 451 }
458 452
459 base::TimeTicks start_time(base::TimeTicks::Now()); 453 base::TimeTicks start_time(base::TimeTicks::Now());
460 454
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 argc, argv, run_test_suite, SysInfo::NumberOfProcessors()); 489 argc, argv, run_test_suite, SysInfo::NumberOfProcessors());
496 } 490 }
497 491
498 int LaunchUnitTestsSerially(int argc, 492 int LaunchUnitTestsSerially(int argc,
499 char** argv, 493 char** argv,
500 const RunTestSuiteCallback& run_test_suite) { 494 const RunTestSuiteCallback& run_test_suite) {
501 return LaunchUnitTestsInternal(argc, argv, run_test_suite, 1); 495 return LaunchUnitTestsInternal(argc, argv, run_test_suite, 1);
502 } 496 }
503 497
504 } // namespace base 498 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698