> --
> Chromium Developers mailing list: chromi...@chromium.org
> View archives, change email options, or unsubscribe:
> http://groups.google.com/a/chromium.org/group/chromium-dev
>
I coulda sworn I fiddled with some test-running code that did this
already, but I can't find it right now.
I recently got to know that in unit tests singletons created by one test are not released at the end of that test. This causes state to be shared with subsequent tests and in some cases test failures.Some tests such as src/base/debug/trace_event_win_unittest.cc use a ShadowingAtExitManager to release all singletons created by those set of tests. Have we considered adding this to the base testing::Test or other relevant base class so that singletons don't persist across tests?
Note that this is not just a question about tests, but also about how the code is designed. To run AtExit callbacks between tests, we have to change several assumptions in the non-test code, for example how LazyInstance works.
Furthermore, there are LeakySingletonTraits, that would mean Singletons surviving between tests.
Using a ShadowingAtExitManager seems to only release Singletons and LazyInstances created while running that test, and I was thinking that should be sufficient. Do you think otherwise?
I agree that running tests in their own processes would take care of it all. Is that something you were looking to implement as part of that bug?