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

Side by Side Diff: base/test/test_suite.cc

Issue 10199007: Add a "--silent" flag to our test suite to disable gtest output. This clears up the test logs when … (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 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
« no previous file with comments | « base/test/test_suite.h ('k') | chrome/browser/chrome_main_browsertest.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 (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
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";
73 74
74 TestSuite::TestSuite(int argc, char** argv) : initialized_command_line_(false) { 75 TestSuite::TestSuite(int argc, char** argv) : initialized_command_line_(false) {
75 PreInitialize(argc, argv, true); 76 PreInitialize(argc, argv, true);
76 } 77 }
77 78
78 TestSuite::TestSuite(int argc, char** argv, bool create_at_exit_manager) 79 TestSuite::TestSuite(int argc, char** argv, bool create_at_exit_manager)
79 : initialized_command_line_(false) { 80 : initialized_command_line_(false) {
80 PreInitialize(argc, argv, create_at_exit_manager); 81 PreInitialize(argc, argv, create_at_exit_manager);
81 } 82 }
82 83
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 // Initialize(). See bug 6436. 170 // Initialize(). See bug 6436.
170 int TestSuite::Run() { 171 int TestSuite::Run() {
171 #if defined(OS_MACOSX) 172 #if defined(OS_MACOSX)
172 base::mac::ScopedNSAutoreleasePool scoped_pool; 173 base::mac::ScopedNSAutoreleasePool scoped_pool;
173 #endif 174 #endif
174 175
175 Initialize(); 176 Initialize();
176 std::string client_func = 177 std::string client_func =
177 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 178 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
178 switches::kTestChildProcess); 179 switches::kTestChildProcess);
180
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
179 // Check to see if we are being run as a client process. 188 // Check to see if we are being run as a client process.
180 if (!client_func.empty()) 189 if (!client_func.empty())
181 return multi_process_function_list::InvokeChildProcessTest(client_func); 190 return multi_process_function_list::InvokeChildProcessTest(client_func);
182 int result = RUN_ALL_TESTS(); 191 int result = RUN_ALL_TESTS();
183 192
184 // If there are failed tests, see if we should ignore the failures. 193 // If there are failed tests, see if we should ignore the failures.
185 if (result != 0 && GetTestCount(&TestSuite::NonIgnoredFailures) == 0) 194 if (result != 0 && GetTestCount(&TestSuite::NonIgnoredFailures) == 0)
186 result = 0; 195 result = 0;
187 196
188 // Display the number of flaky tests. 197 if (!silent) {
189 int flaky_count = GetTestCount(&TestSuite::IsMarkedFlaky); 198 // Display the number of flaky tests.
190 if (flaky_count) { 199 int flaky_count = GetTestCount(&TestSuite::IsMarkedFlaky);
191 printf(" YOU HAVE %d FLAKY %s\n\n", flaky_count, 200 if (flaky_count) {
192 flaky_count == 1 ? "TEST" : "TESTS"); 201 printf(" YOU HAVE %d FLAKY %s\n\n", flaky_count,
193 } 202 flaky_count == 1 ? "TEST" : "TESTS");
203 }
194 204
195 // Display the number of tests with ignored failures (FAILS). 205 // Display the number of tests with ignored failures (FAILS).
196 int failing_count = GetTestCount(&TestSuite::IsMarkedFailing); 206 int failing_count = GetTestCount(&TestSuite::IsMarkedFailing);
197 if (failing_count) { 207 if (failing_count) {
198 printf(" YOU HAVE %d %s with ignored failures (FAILS prefix)\n\n", 208 printf(" YOU HAVE %d %s with ignored failures (FAILS prefix)\n\n",
199 failing_count, failing_count == 1 ? "test" : "tests"); 209 failing_count, failing_count == 1 ? "test" : "tests");
210 }
200 } 211 }
201 212
202 #if defined(OS_MACOSX) 213 #if defined(OS_MACOSX)
203 // This MUST happen before Shutdown() since Shutdown() tears down 214 // This MUST happen before Shutdown() since Shutdown() tears down
204 // objects (such as NotificationService::current()) that Cocoa 215 // objects (such as NotificationService::current()) that Cocoa
205 // objects use to remove themselves as observers. 216 // objects use to remove themselves as observers.
206 scoped_pool.Recycle(); 217 scoped_pool.Recycle();
207 #endif 218 #endif
208 219
209 Shutdown(); 220 Shutdown();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 #endif 286 #endif
276 287
277 CatchMaybeTests(); 288 CatchMaybeTests();
278 ResetCommandLine(); 289 ResetCommandLine();
279 290
280 TestTimeouts::Initialize(); 291 TestTimeouts::Initialize();
281 } 292 }
282 293
283 void TestSuite::Shutdown() { 294 void TestSuite::Shutdown() {
284 } 295 }
OLDNEW
« no previous file with comments | « base/test/test_suite.h ('k') | chrome/browser/chrome_main_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698