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

Side by Side Diff: chrome/test/test_launcher/out_of_proc_test_runner.cc

Issue 197045: Implement a way to run each interactive UI test isolated (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <string> 5 #include <string>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/process_util.h" 9 #include "base/process_util.h"
10 10
11 #include "chrome/test/browser/browser_test_runner.h" 11 #include "chrome/test/test_launcher/test_runner.h"
12 #include "chrome/test/unit/chrome_test_suite.h" 12 #include "chrome/test/unit/chrome_test_suite.h"
13 13
14 // This version of the browser test launcher forks a new process for each test 14 // This version of the test launcher forks a new process for each test it runs.
15 // it runs.
16 15
17 namespace { 16 namespace {
18 17
19 const wchar_t* const kGTestListTestsFlag = L"gtest_list_tests"; 18 const wchar_t* const kGTestListTestsFlag = L"gtest_list_tests";
20 const wchar_t* const kChildProcessFlag = L"child"; 19 const wchar_t* const kChildProcessFlag = L"child";
21 20
22 class OutOfProcBrowserTestRunner : public browser_tests::BrowserTestRunner { 21 class OutOfProcTestRunner : public tests::TestRunner {
23 public: 22 public:
24 OutOfProcBrowserTestRunner() { 23 OutOfProcTestRunner() {
25 } 24 }
26 25
27 virtual ~OutOfProcBrowserTestRunner() { 26 virtual ~OutOfProcTestRunner() {
28 } 27 }
29 28
30 bool Init() { 29 bool Init() {
31 return true; 30 return true;
32 } 31 }
33 32
34 // Returns true if the test succeeded, false if it failed. 33 // Returns true if the test succeeded, false if it failed.
35 bool RunTest(const std::string& test_name) { 34 bool RunTest(const std::string& test_name) {
36 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); 35 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
37 CommandLine new_cmd_line(cmd_line->argv()); 36 CommandLine new_cmd_line(cmd_line->argv());
(...skipping 10 matching lines...) Expand all
48 47
49 int exit_code = 0; 48 int exit_code = 0;
50 r = base::WaitForExitCode(process_handle, &exit_code); 49 r = base::WaitForExitCode(process_handle, &exit_code);
51 if (!r) 50 if (!r)
52 return false; 51 return false;
53 52
54 return exit_code == 0; 53 return exit_code == 0;
55 } 54 }
56 55
57 private: 56 private:
58 DISALLOW_COPY_AND_ASSIGN(OutOfProcBrowserTestRunner); 57 DISALLOW_COPY_AND_ASSIGN(OutOfProcTestRunner);
59 }; 58 };
60 59
61 class OutOfProcBrowserTestRunnerFactory 60 class OutOfProcTestRunnerFactory : public tests::TestRunnerFactory {
62 : public browser_tests::BrowserTestRunnerFactory {
63 public: 61 public:
64 OutOfProcBrowserTestRunnerFactory() { } 62 OutOfProcTestRunnerFactory() { }
65 63
66 virtual browser_tests::BrowserTestRunner* CreateBrowserTestRunner() const { 64 virtual tests::TestRunner* CreateTestRunner() const {
67 return new OutOfProcBrowserTestRunner(); 65 return new OutOfProcTestRunner();
68 } 66 }
69 67
70 private: 68 private:
71 DISALLOW_COPY_AND_ASSIGN(OutOfProcBrowserTestRunnerFactory); 69 DISALLOW_COPY_AND_ASSIGN(OutOfProcTestRunnerFactory);
72 }; 70 };
73 71
74 } // namespace 72 } // namespace
75 73
76 int main(int argc, char** argv) { 74 int main(int argc, char** argv) {
77 CommandLine::Init(argc, argv); 75 CommandLine::Init(argc, argv);
78 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 76 const CommandLine* command_line = CommandLine::ForCurrentProcess();
79 77
80 if (command_line->HasSwitch(kChildProcessFlag)) 78 if (command_line->HasSwitch(kChildProcessFlag))
81 return ChromeTestSuite(argc, argv).Run(); 79 return ChromeTestSuite(argc, argv).Run();
82 80
83 if (command_line->HasSwitch(kGTestListTestsFlag)) 81 if (command_line->HasSwitch(kGTestListTestsFlag))
84 return ChromeTestSuite(argc, argv).Run(); 82 return ChromeTestSuite(argc, argv).Run();
85 83
86 OutOfProcBrowserTestRunnerFactory test_runner_factory; 84 OutOfProcTestRunnerFactory test_runner_factory;
87 return browser_tests::RunTests(test_runner_factory) ? 0 : 1; 85 return tests::RunTests(test_runner_factory) ? 0 : 1;
88 } 86 }
OLDNEW
« no previous file with comments | « chrome/test/test_launcher/in_proc_test_runner.cc ('k') | chrome/test/test_launcher/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698