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

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

Issue 895853003: Update from https://crrev.com/314320 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 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_ios.cc ('k') | base/test/launcher/unit_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 #ifndef BASE_TEST_LAUNCHER_UNIT_TEST_LAUNCHER_H_ 5 #ifndef BASE_TEST_LAUNCHER_UNIT_TEST_LAUNCHER_H_
6 #define BASE_TEST_LAUNCHER_UNIT_TEST_LAUNCHER_H_ 6 #define BASE_TEST_LAUNCHER_UNIT_TEST_LAUNCHER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/test/launcher/test_launcher.h" 10 #include "base/test/launcher/test_launcher.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // of current process. |test_names| is a vector of test full names 48 // of current process. |test_names| is a vector of test full names
49 // (e.g. "A.B"), |output_file| is path to the GTest XML output file. 49 // (e.g. "A.B"), |output_file| is path to the GTest XML output file.
50 virtual CommandLine GetCommandLineForChildGTestProcess( 50 virtual CommandLine GetCommandLineForChildGTestProcess(
51 const std::vector<std::string>& test_names, 51 const std::vector<std::string>& test_names,
52 const base::FilePath& output_file) = 0; 52 const base::FilePath& output_file) = 0;
53 53
54 // Returns wrapper to use for child GTest process. Empty string means 54 // Returns wrapper to use for child GTest process. Empty string means
55 // no wrapper. 55 // no wrapper.
56 virtual std::string GetWrapperForChildGTestProcess() = 0; 56 virtual std::string GetWrapperForChildGTestProcess() = 0;
57 57
58 // Relaunch tests, e.g. after a crash.
59 virtual void RelaunchTests(TestLauncher* test_launcher,
60 const std::vector<std::string>& test_names,
61 int launch_flags) = 0;
62
58 protected: 63 protected:
59 ~UnitTestPlatformDelegate() {} 64 ~UnitTestPlatformDelegate() {}
60 }; 65 };
61 66
67 // Runs tests serially, each in its own process.
68 void RunUnitTestsSerially(TestLauncher* test_launcher,
69 UnitTestPlatformDelegate* platform_delegate,
70 const std::vector<std::string>& test_names,
71 int launch_flags);
72
73 // Runs tests in batches (each batch in its own process).
74 void RunUnitTestsBatch(TestLauncher* test_launcher,
75 UnitTestPlatformDelegate* platform_delegate,
76 const std::vector<std::string>& test_names,
77 int launch_flags);
78
62 // Test launcher delegate for unit tests (mostly to support batching). 79 // Test launcher delegate for unit tests (mostly to support batching).
63 class UnitTestLauncherDelegate : public TestLauncherDelegate { 80 class UnitTestLauncherDelegate : public TestLauncherDelegate {
64 public: 81 public:
65 UnitTestLauncherDelegate(UnitTestPlatformDelegate* delegate, 82 UnitTestLauncherDelegate(UnitTestPlatformDelegate* delegate,
66 size_t batch_limit, 83 size_t batch_limit,
67 bool use_job_objects); 84 bool use_job_objects);
68 ~UnitTestLauncherDelegate() override; 85 ~UnitTestLauncherDelegate() override;
69 86
70 private: 87 private:
71 struct GTestCallbackState {
72 GTestCallbackState();
73 ~GTestCallbackState();
74
75 TestLauncher* test_launcher;
76 std::vector<std::string> test_names;
77 FilePath output_file;
78 };
79
80 // TestLauncherDelegate: 88 // TestLauncherDelegate:
81 bool GetTests(std::vector<SplitTestName>* output) override; 89 bool GetTests(std::vector<SplitTestName>* output) override;
82 bool ShouldRunTest(const std::string& test_case_name, 90 bool ShouldRunTest(const std::string& test_case_name,
83 const std::string& test_name) override; 91 const std::string& test_name) override;
84 size_t RunTests(TestLauncher* test_launcher, 92 size_t RunTests(TestLauncher* test_launcher,
85 const std::vector<std::string>& test_names) override; 93 const std::vector<std::string>& test_names) override;
86 size_t RetryTests(TestLauncher* test_launcher, 94 size_t RetryTests(TestLauncher* test_launcher,
87 const std::vector<std::string>& test_names) override; 95 const std::vector<std::string>& test_names) override;
88 96
89 // Runs tests serially, each in its own process.
90 void RunSerially(TestLauncher* test_launcher,
91 const std::vector<std::string>& test_names);
92
93 // Runs tests in batches (each batch in its own process).
94 void RunBatch(TestLauncher* test_launcher,
95 const std::vector<std::string>& test_names);
96
97 // Callback for batched tests.
98 void GTestCallback(const GTestCallbackState& callback_state,
99 int exit_code,
100 const TimeDelta& elapsed_time,
101 bool was_timeout,
102 const std::string& output);
103
104 // Callback for serialized tests.
105 void SerialGTestCallback(const GTestCallbackState& callback_state,
106 const std::vector<std::string>& test_names,
107 int exit_code,
108 const TimeDelta& elapsed_time,
109 bool was_timeout,
110 const std::string& output);
111
112 // Interprets test results and reports to the test launcher. Returns true
113 // on success.
114 static bool ProcessTestResults(TestLauncher* test_launcher,
115 const std::vector<std::string>& test_names,
116 const base::FilePath& output_file,
117 const std::string& output,
118 int exit_code,
119 bool was_timeout,
120 std::vector<std::string>* tests_to_relaunch);
121
122 ThreadChecker thread_checker_; 97 ThreadChecker thread_checker_;
123 98
124 UnitTestPlatformDelegate* platform_delegate_; 99 UnitTestPlatformDelegate* platform_delegate_;
125 100
126 // Maximum number of tests to run in a single batch. 101 // Maximum number of tests to run in a single batch.
127 size_t batch_limit_; 102 size_t batch_limit_;
128 103
129 // Determines whether we use job objects on Windows. 104 // Determines whether we use job objects on Windows.
130 bool use_job_objects_; 105 bool use_job_objects_;
131 106
132 DISALLOW_COPY_AND_ASSIGN(UnitTestLauncherDelegate); 107 DISALLOW_COPY_AND_ASSIGN(UnitTestLauncherDelegate);
133 }; 108 };
134 109
135 } // namespace base 110 } // namespace base
136 111
137 #endif // BASE_TEST_LAUNCHER_UNIT_TEST_LAUNCHER_H_ 112 #endif // BASE_TEST_LAUNCHER_UNIT_TEST_LAUNCHER_H_
OLDNEW
« no previous file with comments | « base/test/launcher/test_launcher_ios.cc ('k') | base/test/launcher/unit_test_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698