Commit 4564361c authored by jam@chromium.org's avatar jam@chromium.org

Add a "--silent" flag to our test suite to disable gtest output. This clears...

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
parent ed308bf2
...@@ -70,6 +70,7 @@ class TestClientInitializer : public testing::EmptyTestEventListener { ...@@ -70,6 +70,7 @@ class TestClientInitializer : public testing::EmptyTestEventListener {
} // namespace } // namespace
const char TestSuite::kStrictFailureHandling[] = "strict_failure_handling"; const char TestSuite::kStrictFailureHandling[] = "strict_failure_handling";
const char TestSuite::kSilent[] = "silent";
TestSuite::TestSuite(int argc, char** argv) : initialized_command_line_(false) { TestSuite::TestSuite(int argc, char** argv) : initialized_command_line_(false) {
PreInitialize(argc, argv, true); PreInitialize(argc, argv, true);
...@@ -176,6 +177,14 @@ int TestSuite::Run() { ...@@ -176,6 +177,14 @@ int TestSuite::Run() {
std::string client_func = std::string client_func =
CommandLine::ForCurrentProcess()->GetSwitchValueASCII( CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kTestChildProcess); 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. // Check to see if we are being run as a client process.
if (!client_func.empty()) if (!client_func.empty())
return multi_process_function_list::InvokeChildProcessTest(client_func); return multi_process_function_list::InvokeChildProcessTest(client_func);
...@@ -185,6 +194,7 @@ int TestSuite::Run() { ...@@ -185,6 +194,7 @@ int TestSuite::Run() {
if (result != 0 && GetTestCount(&TestSuite::NonIgnoredFailures) == 0) if (result != 0 && GetTestCount(&TestSuite::NonIgnoredFailures) == 0)
result = 0; result = 0;
if (!silent) {
// Display the number of flaky tests. // Display the number of flaky tests.
int flaky_count = GetTestCount(&TestSuite::IsMarkedFlaky); int flaky_count = GetTestCount(&TestSuite::IsMarkedFlaky);
if (flaky_count) { if (flaky_count) {
...@@ -198,6 +208,7 @@ int TestSuite::Run() { ...@@ -198,6 +208,7 @@ int TestSuite::Run() {
printf(" YOU HAVE %d %s with ignored failures (FAILS prefix)\n\n", printf(" YOU HAVE %d %s with ignored failures (FAILS prefix)\n\n",
failing_count, failing_count == 1 ? "test" : "tests"); failing_count, failing_count == 1 ? "test" : "tests");
} }
}
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
// This MUST happen before Shutdown() since Shutdown() tears down // This MUST happen before Shutdown() since Shutdown() tears down
......
...@@ -59,6 +59,9 @@ class TestSuite { ...@@ -59,6 +59,9 @@ class TestSuite {
// process exit code. // process exit code.
static const char kStrictFailureHandling[]; static const char kStrictFailureHandling[];
// A command-line flag that silences all gtest output.
static const char kSilent[];
protected: protected:
// This constructor is only accessible to specialized test suite // This constructor is only accessible to specialized test suite
// implementations which need to control the creation of an AtExitManager // implementations which need to control the creation of an AtExitManager
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/file_util.h" #include "base/file_util.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/process_util.h" #include "base/process_util.h"
#include "base/test/test_suite.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list.h"
#include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_notification_types.h"
...@@ -50,6 +51,7 @@ class ChromeMainTest : public InProcessBrowserTest { ...@@ -50,6 +51,7 @@ class ChromeMainTest : public InProcessBrowserTest {
new_command_line_.AppendSwitchASCII( new_command_line_.AppendSwitchASCII(
test_launcher::kGTestFilterFlag, test_launcher::kEmptyTestName); test_launcher::kGTestFilterFlag, test_launcher::kEmptyTestName);
new_command_line_.AppendSwitch(TestSuite::kSilent);
} }
void Relaunch() { void Relaunch() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment