Index: base/test/test_suite.cc |
diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc |
index 0cca8fa25ba9093f87e6af7ebfdb66cc583acdcd..c1d110c546a98172217498f0ecb3159070119ed3 100644 |
--- a/base/test/test_suite.cc |
+++ b/base/test/test_suite.cc |
@@ -82,10 +82,19 @@ class TestWatchAtExitManager : public testing::EmptyTestEventListener { |
virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE { |
initial_top_manager_ = AtExitManager::current(); |
at_exit_stack_size_ = initial_top_manager_->CallbackStackSize(); |
+ per_test_manager_.reset(new base::AtExitManager); |
} |
virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE { |
AtExitManager* new_top_manager = AtExitManager::current(); |
+ if (per_test_manager_.get() != 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."; |
Ryan Sleevi
2012/07/11 22:30:41
style nit: The << should be on the beginning of ea
|
+ } |
+ per_test_manager_.reset(); |
+ |
+ new_top_manager = AtExitManager::current(); |
size_t new_stack_size = new_top_manager->CallbackStackSize(); |
if (initial_top_manager_ != new_top_manager) { |
@@ -93,10 +102,7 @@ class TestWatchAtExitManager : public testing::EmptyTestEventListener { |
"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) << |
+ ADD_FAILURE() << |
"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."; |
@@ -105,6 +111,7 @@ class TestWatchAtExitManager : public testing::EmptyTestEventListener { |
private: |
AtExitManager* initial_top_manager_; |
+ scoped_ptr<base::AtExitManager> per_test_manager_; |
size_t at_exit_stack_size_; |
DISALLOW_COPY_AND_ASSIGN(TestWatchAtExitManager); |