Index: base/test/test_suite.cc |
diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc |
index c257b141819851ddfa0987e3ce84bc26bf04478b..e67be8d1d6f40a202d0d44511aafac047b8b97a0 100644 |
--- a/base/test/test_suite.cc |
+++ b/base/test/test_suite.cc |
@@ -47,6 +47,26 @@ class MaybeTestDisabler : public testing::EmptyTestEventListener { |
} |
}; |
+class TestClientInitializer : public testing::EmptyTestEventListener { |
+ public: |
+ TestClientInitializer() |
+ : old_command_line_(CommandLine::NO_PROGRAM) { |
+ } |
+ |
+ virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE { |
+ old_command_line_ = *CommandLine::ForCurrentProcess(); |
+ } |
+ |
+ virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE { |
+ *CommandLine::ForCurrentProcess() = old_command_line_; |
+ } |
+ |
+ private: |
+ CommandLine old_command_line_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(TestClientInitializer); |
+}; |
+ |
} // namespace |
const char TestSuite::kStrictFailureHandling[] = "strict_failure_handling"; |
@@ -119,6 +139,12 @@ void TestSuite::CatchMaybeTests() { |
listeners.Append(new MaybeTestDisabler); |
} |
+void TestSuite::ResetCommandLine() { |
+ testing::TestEventListeners& listeners = |
+ testing::UnitTest::GetInstance()->listeners(); |
+ listeners.Append(new TestClientInitializer); |
+} |
+ |
// Don't add additional code to this method. Instead add it to |
// Initialize(). See bug 6436. |
int TestSuite::Run() { |
@@ -229,6 +255,7 @@ void TestSuite::Initialize() { |
#endif |
CatchMaybeTests(); |
+ ResetCommandLine(); |
TestTimeouts::Initialize(); |
} |