Make unittest log printouts opt-in with a --logs flag.

TESTED=Using modules_unittests, no logs are printed by default.
Specifying --logs prints logs. gtest flags work correctly.

R=henrike@webrtc.org, kjellander@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/2181004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4686 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andrew@webrtc.org
2013-09-05 21:16:29 +00:00
parent bebf3995ce
commit aa3d1c8169
2 changed files with 9 additions and 2 deletions

View File

@ -47,6 +47,7 @@
'dependencies': [
'<(DEPTH)/testing/gtest.gyp:gtest',
'<(DEPTH)/testing/gmock.gyp:gmock',
'<(DEPTH)/third_party/gflags/gflags.gyp:gflags',
'<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers',
],
'sources': [

View File

@ -10,11 +10,14 @@
#include "webrtc/test/test_suite.h"
#include "gflags/gflags.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/test/testsupport/fileutils.h"
#include "webrtc/test/testsupport/trace_to_stderr.h"
DEFINE_bool(logs, false, "print logs to stderr");
namespace webrtc {
namespace test {
@ -22,6 +25,9 @@ TestSuite::TestSuite(int argc, char** argv)
: trace_to_stderr_(NULL) {
SetExecutablePath(argv[0]);
testing::InitGoogleMock(&argc, argv); // Runs InitGoogleTest() internally.
// ParseCommandLineFlags fails on unrecognized flags. Call it last so that
// any flags inteded for gtest are already filtered out.
google::ParseCommandLineFlags(&argc, &argv, true);
}
TestSuite::~TestSuite() {
@ -35,8 +41,8 @@ int TestSuite::Run() {
}
void TestSuite::Initialize() {
// Create TraceToStderr here so the behavior can be overridden.
trace_to_stderr_.reset(new TraceToStderr);
if (FLAGS_logs)
trace_to_stderr_.reset(new TraceToStderr);
}
void TestSuite::Shutdown() {