summaryrefslogtreecommitdiffstats
path: root/base/test/test_suite.h
diff options
context:
space:
mode:
authorglider@chromium.org <glider@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-11 13:57:36 +0000
committerglider@chromium.org <glider@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-11 13:57:36 +0000
commit0b6391a6d4d7113ae80e4400d5351bf3c377a768 (patch)
tree19dcf58d1a28f9ad56f29d9416b5a6db402fec88 /base/test/test_suite.h
parent456a3c5efd48fbcef8d67347506e0085d7b4fd6c (diff)
downloadchromium_src-0b6391a6d4d7113ae80e4400d5351bf3c377a768.zip
chromium_src-0b6391a6d4d7113ae80e4400d5351bf3c377a768.tar.gz
chromium_src-0b6391a6d4d7113ae80e4400d5351bf3c377a768.tar.bz2
Make gtest report an error if there are tests marked as "MAYBE"
Review URL: http://codereview.chromium.org/2762016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49526 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/test/test_suite.h')
-rw-r--r--base/test/test_suite.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/base/test/test_suite.h b/base/test/test_suite.h
index 609a0e1..c026709 100644
--- a/base/test/test_suite.h
+++ b/base/test/test_suite.h
@@ -82,6 +82,13 @@ class TestSuite {
return strncmp(test.name(), "FAILS_", 6) == 0;
}
+ // Returns true if the test is marked as "MAYBE_".
+ // When using different prefixes depending on platform, we use MAYBE_ and
+ // preprocessor directives to replace MAYBE_ with the target prefix.
+ static bool IsMarkedMaybe(const testing::TestInfo& test) {
+ return strncmp(test.name(), "MAYBE_", 6) == 0;
+ }
+
// Returns true if the test failure should be ignored.
static bool ShouldIgnoreFailure(const testing::TestInfo& test) {
if (CommandLine::ForCurrentProcess()->HasSwitch(kStrictFailureHandling))
@@ -119,6 +126,12 @@ class TestSuite {
listeners.Append(new TestIsolationEnforcer);
}
+ void CatchMaybeTests() {
+ testing::TestEventListeners& listeners =
+ testing::UnitTest::GetInstance()->listeners();
+ listeners.Append(new MaybeTestDisabler);
+ }
+
// Don't add additional code to this method. Instead add it to
// Initialize(). See bug 6436.
int Run() {
@@ -165,6 +178,16 @@ class TestSuite {
}
protected:
+ class MaybeTestDisabler : public testing::EmptyTestEventListener {
+ public:
+ virtual void OnTestStart(const testing::TestInfo& test_info) {
+ ASSERT_FALSE(TestSuite::IsMarkedMaybe(test_info))
+ << "Probably the OS #ifdefs don't include all of the necessary "
+ "platforms.\nPlease ensure that no tests have the MAYBE_ prefix "
+ "after the code is preprocessed.";
+ }
+ };
+
// By default fatal log messages (e.g. from DCHECKs) result in error dialogs
// which gum up buildbots. Use a minimalistic assert handler which just
// terminates the process.
@@ -227,6 +250,8 @@ class TestSuite {
// will be done only on process exit.
base::EnsureNSSInit();
#endif // defined(USE_NSS)
+
+ CatchMaybeTests();
}
virtual void Shutdown() {