summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-09 20:06:05 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-09 20:06:05 +0000
commit946c0242c685f7c014f1a63fe3c60fa94bc0d966 (patch)
tree4bf03c99930ed864019f38dd3c3a270ce43b8d1a /chrome/test
parenta877d06fc0cba436f6452b74233269ecf4059c75 (diff)
downloadchromium_src-946c0242c685f7c014f1a63fe3c60fa94bc0d966.zip
chromium_src-946c0242c685f7c014f1a63fe3c60fa94bc0d966.tar.gz
chromium_src-946c0242c685f7c014f1a63fe3c60fa94bc0d966.tar.bz2
Make --gtest_repeat flag work correctly for browser_tests.
Before this patch it was being passed to the child process and was causing crashes becuase we can't restart the browser in the same process after shutdown. TEST=browser_tests BUG=none Review URL: http://codereview.chromium.org/3083023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55451 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/test_launcher/out_of_proc_test_runner.cc37
1 files changed, 31 insertions, 6 deletions
diff --git a/chrome/test/test_launcher/out_of_proc_test_runner.cc b/chrome/test/test_launcher/out_of_proc_test_runner.cc
index eb4e172..c614065 100644
--- a/chrome/test/test_launcher/out_of_proc_test_runner.cc
+++ b/chrome/test/test_launcher/out_of_proc_test_runner.cc
@@ -28,9 +28,10 @@ typedef int (*DLL_MAIN)(HINSTANCE, sandbox::SandboxInterfaceInfo*, wchar_t*);
namespace {
+const char kGTestHelpFlag[] = "gtest_help";
const char kGTestListTestsFlag[] = "gtest_list_tests";
const char kGTestOutputFlag[] = "gtest_output";
-const char kGTestHelpFlag[] = "gtest_help";
+const char kGTestRepeatFlag[] = "gtest_repeat";
const char kSingleProcessTestsFlag[] = "single_process";
const char kSingleProcessTestsAndChromeFlag[] = "single-process";
const char kTestTerminateTimeoutFlag[] = "test-terminate-timeout";
@@ -58,13 +59,19 @@ class OutOfProcTestRunner : public tests::TestRunner {
// Returns true if the test succeeded, false if it failed.
bool RunTest(const std::string& test_name) {
const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
- // Construct the new command line. Strip out gtest_output flag if
- // it has been given because otherwise each test outputs the same file
- // over and over overriding the previous one every time.
- // We will generate the final output file later in RunTests().
CommandLine new_cmd_line(cmd_line->GetProgram());
CommandLine::SwitchMap switches = cmd_line->GetSwitches();
+
+ // Strip out gtest_output flag because otherwise we would overwrite results
+ // of the previous test. We will generate the final output file later
+ // in RunTests().
switches.erase(kGTestOutputFlag);
+
+ // Strip out gtest_repeat flag because we can only run one test in the child
+ // process (restarting the browser in the same process is illegal after it
+ // has been shut down and will actually crash).
+ switches.erase(kGTestRepeatFlag);
+
for (CommandLine::SwitchMap::const_iterator iter = switches.begin();
iter != switches.end(); ++iter) {
new_cmd_line.AppendSwitchNative((*iter).first, (*iter).second);
@@ -208,5 +215,23 @@ int main(int argc, char** argv) {
"--single-process (to do the above, and also run Chrome in single-\n"
"process mode).\n");
OutOfProcTestRunnerFactory test_runner_factory;
- return tests::RunTests(test_runner_factory) ? 0 : 1;
+
+ int cycles = 1;
+ if (command_line->HasSwitch(kGTestRepeatFlag)) {
+ base::StringToInt(command_line->GetSwitchValueASCII(kGTestRepeatFlag),
+ &cycles);
+ }
+
+ int exit_code = 0;
+ while (cycles != 0) {
+ if (!tests::RunTests(test_runner_factory)) {
+ exit_code = 1;
+ break;
+ }
+
+ // Special value "-1" means "repeat indefinitely".
+ if (cycles != -1)
+ cycles--;
+ }
+ return exit_code;
}