summaryrefslogtreecommitdiffstats
path: root/base/test
diff options
context:
space:
mode:
authorscottbyer@chromium.org <scottbyer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-25 20:36:33 +0000
committerscottbyer@chromium.org <scottbyer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-25 20:36:33 +0000
commitfe992bf04826c6f7a067704a2fa117eda813d0fa (patch)
tree169cc41bb183542dbe526f6814c4d79fce6c7867 /base/test
parentc9236ae784665dc4583e3c98a2b6c0280c21c8bd (diff)
downloadchromium_src-fe992bf04826c6f7a067704a2fa117eda813d0fa.zip
chromium_src-fe992bf04826c6f7a067704a2fa117eda813d0fa.tar.gz
chromium_src-fe992bf04826c6f7a067704a2fa117eda813d0fa.tar.bz2
Revert 144488 - For unit tests, track additions to AtExitManager and warn.
While trying to bullet proof a unit test, I had trouble getting very far when running all tests in shuffle mode. Tracked that back to a few other tests doing stuff that accessed Singleton()s outside of a test-scoped ShadowingAtExitManager. Seemed to me that should be an invariant around any unit test, so created this towards that end, hopefully helping stabilize out unit_tests a bit more. BUG=133403 Review URL: https://chromiumcodereview.appspot.com/10582012 TBR=scottbyer@chromium.org Review URL: https://chromiumcodereview.appspot.com/10834010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148405 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/test')
-rw-r--r--base/test/test_suite.cc56
-rw-r--r--base/test/test_suite.h2
-rw-r--r--base/test/test_switches.cc19
-rw-r--r--base/test/test_switches.h2
4 files changed, 4 insertions, 75 deletions
diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc
index 42edb00..b0c7c22 100644
--- a/base/test/test_suite.cc
+++ b/base/test/test_suite.cc
@@ -17,7 +17,6 @@
#include "base/path_service.h"
#include "base/process_util.h"
#include "base/test/multiprocess_test.h"
-#include "base/test/test_switches.h"
#include "base/test/test_timeouts.h"
#include "base/time.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -78,46 +77,6 @@ class TestClientInitializer : public testing::EmptyTestEventListener {
} // namespace
-namespace base {
-
-class TestWatchAtExitManager : public testing::EmptyTestEventListener {
- public:
- TestWatchAtExitManager() { }
- ~TestWatchAtExitManager() { }
-
- virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE {
- initial_top_manager_ = AtExitManager::current();
- at_exit_stack_size_ = initial_top_manager_->CallbackStackSize();
- }
-
- virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE {
- AtExitManager* new_top_manager = AtExitManager::current();
- size_t new_stack_size = new_top_manager->CallbackStackSize();
-
- if (initial_top_manager_ != new_top_manager) {
- ADD_FAILURE() << "The current AtExitManager has changed across the "
- "test " << test_info.test_case_name() << "." << test_info.name() <<
- " most likely because one was created without being destroyed.";
- } else if (new_stack_size != at_exit_stack_size_) {
- // TODO(scottbyer): clean up all the errors that result from this and
- // turn this into a test failure with
- // ADD_FAILURE(). http://crbug.com/133403
- LOG(WARNING) <<
- "AtExitManager: items were added to the callback list by " <<
- test_info.test_case_name() << "." << test_info.name() <<
- ". Global state should be cleaned up before a test exits.";
- }
- }
-
- private:
- AtExitManager* initial_top_manager_;
- size_t at_exit_stack_size_;
-
- DISALLOW_COPY_AND_ASSIGN(TestWatchAtExitManager);
-};
-
-} // namespace base
-
const char TestSuite::kStrictFailureHandling[] = "strict_failure_handling";
TestSuite::TestSuite(int argc, char** argv) : initialized_command_line_(false) {
@@ -219,12 +178,6 @@ void TestSuite::ResetCommandLine() {
listeners.Append(new TestClientInitializer);
}
-void TestSuite::WatchAtExitManager() {
- testing::TestEventListeners& listeners =
- testing::UnitTest::GetInstance()->listeners();
- listeners.Append(new TestWatchAtExitManager);
-}
-
// Don't add additional code to this method. Instead add it to
// Initialize(). See bug 6436.
int TestSuite::Run() {
@@ -349,15 +302,6 @@ void TestSuite::Initialize() {
CatchMaybeTests();
ResetCommandLine();
- // Don't watch for AtExit items being added if we're running as a child
- // process (e.g., browser_tests or interactive_ui_tests).
- if (!CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kSingleProcessTestsFlag) &&
- !CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kSingleProcessChromeFlag)) {
- WatchAtExitManager();
- }
-
TestTimeouts::Initialize();
}
diff --git a/base/test/test_suite.h b/base/test/test_suite.h
index ff3e0de..1758f86 100644
--- a/base/test/test_suite.h
+++ b/base/test/test_suite.h
@@ -52,8 +52,6 @@ class TestSuite {
void ResetCommandLine();
- void WatchAtExitManager();
-
int Run();
// A command-line flag that makes a test failure always result in a non-zero
diff --git a/base/test/test_switches.cc b/base/test/test_switches.cc
index f5ec293..79fbad1 100644
--- a/base/test/test_switches.cc
+++ b/base/test/test_switches.cc
@@ -4,20 +4,9 @@
#include "base/test/test_switches.h"
-namespace switches {
-
-// Run Chromium in single process mode.
-const char kSingleProcessChromeFlag[] = "single-process";
-
-// Run the tests and the launcher in the same process. Useful for debugging a
-// specific test in a debugger.
-const char kSingleProcessTestsFlag[] = "single_process";
-
// Time (in milliseconds) that the tests should wait before timing out.
// TODO(phajdan.jr): Clean up the switch names.
-const char kTestLargeTimeout[] = "test-large-timeout";
-const char kTestTinyTimeout[] = "test-tiny-timeout";
-const char kUiTestActionTimeout[] = "ui-test-action-timeout";
-const char kUiTestActionMaxTimeout[] = "ui-test-action-max-timeout";
-
-} // namespace switches
+const char switches::kTestLargeTimeout[] = "test-large-timeout";
+const char switches::kTestTinyTimeout[] = "test-tiny-timeout";
+const char switches::kUiTestActionTimeout[] = "ui-test-action-timeout";
+const char switches::kUiTestActionMaxTimeout[] = "ui-test-action-max-timeout";
diff --git a/base/test/test_switches.h b/base/test/test_switches.h
index 999c931..a5665d4 100644
--- a/base/test/test_switches.h
+++ b/base/test/test_switches.h
@@ -9,8 +9,6 @@ namespace switches {
// All switches in alphabetical order. The switches should be documented
// alongside the definition of their values in the .cc file.
-extern const char kSingleProcessChromeFlag[];
-extern const char kSingleProcessTestsFlag[];
extern const char kTestLargeTimeout[];
extern const char kTestTinyTimeout[];
extern const char kUiTestActionTimeout[];