summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-13 18:22:27 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-13 18:22:27 +0000
commit8929414c3ade6fcbcab194cb719d88413626cb96 (patch)
tree85012cdf7191c522efd0e7a15fb6d4d98f7412b1 /base
parentfc6471f20aa0241a14da6edcd2b706a7a0bc6556 (diff)
downloadchromium_src-8929414c3ade6fcbcab194cb719d88413626cb96.zip
chromium_src-8929414c3ade6fcbcab194cb719d88413626cb96.tar.gz
chromium_src-8929414c3ade6fcbcab194cb719d88413626cb96.tar.bz2
GTTF: Make --help and --gtest_help behave correctly with --brave-new-test-launcher
BUG=236893 R=sky@chromium.org Review URL: https://codereview.chromium.org/23892020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223082 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/test/test_launcher.cc1
-rw-r--r--base/test/test_launcher.h1
-rw-r--r--base/test/unit_test_launcher.cc31
3 files changed, 32 insertions, 1 deletions
diff --git a/base/test/test_launcher.cc b/base/test/test_launcher.cc
index 25482b3..0dc97d1 100644
--- a/base/test/test_launcher.cc
+++ b/base/test/test_launcher.cc
@@ -555,6 +555,7 @@ void RunTestIteration(TestLauncherDelegate* launcher_delegate,
} // namespace
const char kGTestFilterFlag[] = "gtest_filter";
+const char kGTestHelpFlag[] = "gtest_help";
const char kGTestListTestsFlag[] = "gtest_list_tests";
const char kGTestRepeatFlag[] = "gtest_repeat";
const char kGTestRunDisabledTestsFlag[] = "gtest_also_run_disabled_tests";
diff --git a/base/test/test_launcher.h b/base/test/test_launcher.h
index 03fe796..739cbdd 100644
--- a/base/test/test_launcher.h
+++ b/base/test/test_launcher.h
@@ -25,6 +25,7 @@ struct LaunchOptions;
// Constants for GTest command-line flags.
extern const char kGTestFilterFlag[];
+extern const char kGTestHelpFlag[];
extern const char kGTestListTestsFlag[];
extern const char kGTestRepeatFlag[];
extern const char kGTestRunDisabledTestsFlag[];
diff --git a/base/test/unit_test_launcher.cc b/base/test/unit_test_launcher.cc
index 7f6ed5b..cc7f5b9 100644
--- a/base/test/unit_test_launcher.cc
+++ b/base/test/unit_test_launcher.cc
@@ -31,6 +31,8 @@ namespace {
// This constant controls how many tests are run in a single batch by default.
const size_t kDefaultTestBatchLimit = 10;
+const char kHelpFlag[] = "help";
+
// Flag to enable the new launcher logic.
// TODO(phajdan.jr): Remove it, http://crbug.com/236893 .
const char kBraveNewTestLauncherFlag[] = "brave-new-test-launcher";
@@ -38,6 +40,27 @@ const char kBraveNewTestLauncherFlag[] = "brave-new-test-launcher";
// Flag to run all tests in a single process.
const char kSingleProcessTestsFlag[] = "single-process-tests";
+void PrintUsage() {
+ fprintf(stdout,
+ "Runs tests using the gtest framework, each batch of tests being\n"
+ "run in their own process. Supported command-line flags:\n"
+ "\n"
+ " --single-process-tests\n"
+ " Runs the tests and the launcher in the same process. Useful\n"
+ " for debugging a specific test in a debugger.\n"
+ " --test-launcher-jobs=N\n"
+ " Sets the number of parallel test jobs to N.\n"
+ " --test-launcher-batch-limit=N\n"
+ " Sets the limit of test batch to run in a single process to N.\n"
+ " --gtest_filter=...\n"
+ " Runs a subset of tests (see --gtest_help for more info).\n"
+ " --help\n"
+ " Shows this message.\n"
+ " --gtest_help\n"
+ " Shows the gtest help message.\n");
+ fflush(stdout);
+}
+
// Returns command line for child GTest process based on the command line
// of current process. |test_names| is a vector of test full names
// (e.g. "A.B"), |output_file| is path to the GTest XML output file.
@@ -312,11 +335,17 @@ int LaunchUnitTests(int argc,
char** argv,
const RunTestSuiteCallback& run_test_suite) {
CommandLine::Init(argc, argv);
- if (CommandLine::ForCurrentProcess()->HasSwitch(kSingleProcessTestsFlag) ||
+ if (CommandLine::ForCurrentProcess()->HasSwitch(kGTestHelpFlag) ||
+ CommandLine::ForCurrentProcess()->HasSwitch(kSingleProcessTestsFlag) ||
!CommandLine::ForCurrentProcess()->HasSwitch(kBraveNewTestLauncherFlag)) {
return run_test_suite.Run();
}
+ if (CommandLine::ForCurrentProcess()->HasSwitch(kHelpFlag)) {
+ PrintUsage();
+ return 0;
+ }
+
base::TimeTicks start_time(base::TimeTicks::Now());
testing::InitGoogleTest(&argc, argv);