summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-23 23:11:57 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-23 23:11:57 +0000
commit4564361c750a8a898fa4ad5d8eba1be501bf5ab9 (patch)
tree3a55f12af7901ce3a29e15c9b12ead9563b1ef96
parented308bf28af2b288a38494944e3563a508356161 (diff)
downloadchromium_src-4564361c750a8a898fa4ad5d8eba1be501bf5ab9.zip
chromium_src-4564361c750a8a898fa4ad5d8eba1be501bf5ab9.tar.gz
chromium_src-4564361c750a8a898fa4ad5d8eba1be501bf5ab9.tar.bz2
Add a "--silent" flag to our test suite to disable gtest output. This clears up the test logs when running the ChromeMain browsertests.
BUG=124645 Review URL: https://chromiumcodereview.appspot.com/10199007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133560 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/test/test_suite.cc33
-rw-r--r--base/test/test_suite.h3
-rw-r--r--chrome/browser/chrome_main_browsertest.cc2
3 files changed, 27 insertions, 11 deletions
diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc
index a1af2c5..dba5063 100644
--- a/base/test/test_suite.cc
+++ b/base/test/test_suite.cc
@@ -70,6 +70,7 @@ class TestClientInitializer : public testing::EmptyTestEventListener {
} // namespace
const char TestSuite::kStrictFailureHandling[] = "strict_failure_handling";
+const char TestSuite::kSilent[] = "silent";
TestSuite::TestSuite(int argc, char** argv) : initialized_command_line_(false) {
PreInitialize(argc, argv, true);
@@ -176,6 +177,14 @@ int TestSuite::Run() {
std::string client_func =
CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kTestChildProcess);
+
+ bool silent = CommandLine::ForCurrentProcess()->HasSwitch(kSilent);
+ if (silent) {
+ testing::TestEventListeners& listeners =
+ testing::UnitTest::GetInstance()->listeners();
+ delete listeners.Release(listeners.default_result_printer());
+ }
+
// Check to see if we are being run as a client process.
if (!client_func.empty())
return multi_process_function_list::InvokeChildProcessTest(client_func);
@@ -185,18 +194,20 @@ int TestSuite::Run() {
if (result != 0 && GetTestCount(&TestSuite::NonIgnoredFailures) == 0)
result = 0;
- // Display the number of flaky tests.
- int flaky_count = GetTestCount(&TestSuite::IsMarkedFlaky);
- if (flaky_count) {
- printf(" YOU HAVE %d FLAKY %s\n\n", flaky_count,
- flaky_count == 1 ? "TEST" : "TESTS");
- }
+ if (!silent) {
+ // Display the number of flaky tests.
+ int flaky_count = GetTestCount(&TestSuite::IsMarkedFlaky);
+ if (flaky_count) {
+ printf(" YOU HAVE %d FLAKY %s\n\n", flaky_count,
+ flaky_count == 1 ? "TEST" : "TESTS");
+ }
- // Display the number of tests with ignored failures (FAILS).
- int failing_count = GetTestCount(&TestSuite::IsMarkedFailing);
- if (failing_count) {
- printf(" YOU HAVE %d %s with ignored failures (FAILS prefix)\n\n",
- failing_count, failing_count == 1 ? "test" : "tests");
+ // Display the number of tests with ignored failures (FAILS).
+ int failing_count = GetTestCount(&TestSuite::IsMarkedFailing);
+ if (failing_count) {
+ printf(" YOU HAVE %d %s with ignored failures (FAILS prefix)\n\n",
+ failing_count, failing_count == 1 ? "test" : "tests");
+ }
}
#if defined(OS_MACOSX)
diff --git a/base/test/test_suite.h b/base/test/test_suite.h
index 2b0e9ce..889e55f 100644
--- a/base/test/test_suite.h
+++ b/base/test/test_suite.h
@@ -59,6 +59,9 @@ class TestSuite {
// process exit code.
static const char kStrictFailureHandling[];
+ // A command-line flag that silences all gtest output.
+ static const char kSilent[];
+
protected:
// This constructor is only accessible to specialized test suite
// implementations which need to control the creation of an AtExitManager
diff --git a/chrome/browser/chrome_main_browsertest.cc b/chrome/browser/chrome_main_browsertest.cc
index b34080a..888079c 100644
--- a/chrome/browser/chrome_main_browsertest.cc
+++ b/chrome/browser/chrome_main_browsertest.cc
@@ -8,6 +8,7 @@
#include "base/file_util.h"
#include "base/path_service.h"
#include "base/process_util.h"
+#include "base/test/test_suite.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/chrome_notification_types.h"
@@ -50,6 +51,7 @@ class ChromeMainTest : public InProcessBrowserTest {
new_command_line_.AppendSwitchASCII(
test_launcher::kGTestFilterFlag, test_launcher::kEmptyTestName);
+ new_command_line_.AppendSwitch(TestSuite::kSilent);
}
void Relaunch() {