OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/test_suite.h" | 5 #include "base/test/test_suite.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/base_paths.h" | 8 #include "base/base_paths.h" |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 private: | 64 private: |
65 CommandLine old_command_line_; | 65 CommandLine old_command_line_; |
66 | 66 |
67 DISALLOW_COPY_AND_ASSIGN(TestClientInitializer); | 67 DISALLOW_COPY_AND_ASSIGN(TestClientInitializer); |
68 }; | 68 }; |
69 | 69 |
70 } // namespace | 70 } // namespace |
71 | 71 |
72 const char TestSuite::kStrictFailureHandling[] = "strict_failure_handling"; | 72 const char TestSuite::kStrictFailureHandling[] = "strict_failure_handling"; |
73 const char TestSuite::kSilent[] = "silent"; | |
74 | 73 |
75 TestSuite::TestSuite(int argc, char** argv) : initialized_command_line_(false) { | 74 TestSuite::TestSuite(int argc, char** argv) : initialized_command_line_(false) { |
76 PreInitialize(argc, argv, true); | 75 PreInitialize(argc, argv, true); |
77 } | 76 } |
78 | 77 |
79 TestSuite::TestSuite(int argc, char** argv, bool create_at_exit_manager) | 78 TestSuite::TestSuite(int argc, char** argv, bool create_at_exit_manager) |
80 : initialized_command_line_(false) { | 79 : initialized_command_line_(false) { |
81 PreInitialize(argc, argv, create_at_exit_manager); | 80 PreInitialize(argc, argv, create_at_exit_manager); |
82 } | 81 } |
83 | 82 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 int TestSuite::Run() { | 170 int TestSuite::Run() { |
172 #if defined(OS_MACOSX) | 171 #if defined(OS_MACOSX) |
173 base::mac::ScopedNSAutoreleasePool scoped_pool; | 172 base::mac::ScopedNSAutoreleasePool scoped_pool; |
174 #endif | 173 #endif |
175 | 174 |
176 Initialize(); | 175 Initialize(); |
177 std::string client_func = | 176 std::string client_func = |
178 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 177 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
179 switches::kTestChildProcess); | 178 switches::kTestChildProcess); |
180 | 179 |
181 bool silent = CommandLine::ForCurrentProcess()->HasSwitch(kSilent); | |
182 if (silent) { | |
183 testing::TestEventListeners& listeners = | |
184 testing::UnitTest::GetInstance()->listeners(); | |
185 delete listeners.Release(listeners.default_result_printer()); | |
186 } | |
187 | |
188 // Check to see if we are being run as a client process. | 180 // Check to see if we are being run as a client process. |
189 if (!client_func.empty()) | 181 if (!client_func.empty()) |
190 return multi_process_function_list::InvokeChildProcessTest(client_func); | 182 return multi_process_function_list::InvokeChildProcessTest(client_func); |
191 int result = RUN_ALL_TESTS(); | 183 int result = RUN_ALL_TESTS(); |
192 | 184 |
193 // If there are failed tests, see if we should ignore the failures. | 185 // If there are failed tests, see if we should ignore the failures. |
194 if (result != 0 && GetTestCount(&TestSuite::NonIgnoredFailures) == 0) | 186 if (result != 0 && GetTestCount(&TestSuite::NonIgnoredFailures) == 0) |
195 result = 0; | 187 result = 0; |
196 | 188 |
197 if (!silent) { | 189 // Display the number of flaky tests. |
198 // Display the number of flaky tests. | 190 int flaky_count = GetTestCount(&TestSuite::IsMarkedFlaky); |
199 int flaky_count = GetTestCount(&TestSuite::IsMarkedFlaky); | 191 if (flaky_count) { |
200 if (flaky_count) { | 192 printf(" YOU HAVE %d FLAKY %s\n\n", flaky_count, |
201 printf(" YOU HAVE %d FLAKY %s\n\n", flaky_count, | 193 flaky_count == 1 ? "TEST" : "TESTS"); |
202 flaky_count == 1 ? "TEST" : "TESTS"); | 194 } |
203 } | |
204 | 195 |
205 // Display the number of tests with ignored failures (FAILS). | 196 // Display the number of tests with ignored failures (FAILS). |
206 int failing_count = GetTestCount(&TestSuite::IsMarkedFailing); | 197 int failing_count = GetTestCount(&TestSuite::IsMarkedFailing); |
207 if (failing_count) { | 198 if (failing_count) { |
208 printf(" YOU HAVE %d %s with ignored failures (FAILS prefix)\n\n", | 199 printf(" YOU HAVE %d %s with ignored failures (FAILS prefix)\n\n", |
209 failing_count, failing_count == 1 ? "test" : "tests"); | 200 failing_count, failing_count == 1 ? "test" : "tests"); |
210 } | |
211 } | 201 } |
212 | 202 |
213 #if defined(OS_MACOSX) | 203 #if defined(OS_MACOSX) |
214 // This MUST happen before Shutdown() since Shutdown() tears down | 204 // This MUST happen before Shutdown() since Shutdown() tears down |
215 // objects (such as NotificationService::current()) that Cocoa | 205 // objects (such as NotificationService::current()) that Cocoa |
216 // objects use to remove themselves as observers. | 206 // objects use to remove themselves as observers. |
217 scoped_pool.Recycle(); | 207 scoped_pool.Recycle(); |
218 #endif | 208 #endif |
219 | 209 |
220 Shutdown(); | 210 Shutdown(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 #endif | 276 #endif |
287 | 277 |
288 CatchMaybeTests(); | 278 CatchMaybeTests(); |
289 ResetCommandLine(); | 279 ResetCommandLine(); |
290 | 280 |
291 TestTimeouts::Initialize(); | 281 TestTimeouts::Initialize(); |
292 } | 282 } |
293 | 283 |
294 void TestSuite::Shutdown() { | 284 void TestSuite::Shutdown() { |
295 } | 285 } |
OLD | NEW |