Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_TEST_TEST_SUITE_H_ | 5 #ifndef BASE_TEST_TEST_SUITE_H_ |
| 6 #define BASE_TEST_TEST_SUITE_H_ | 6 #define BASE_TEST_TEST_SUITE_H_ |
| 7 | 7 |
| 8 // Defines a basic test suite framework for running gtest based tests. You can | 8 // Defines a basic test suite framework for running gtest based tests. You can |
| 9 // instantiate this class in your main function and call its Run method to run | 9 // instantiate this class in your main function and call its Run method to run |
| 10 // any gtest based tests that are linked into your executable. | 10 // any gtest based tests that are linked into your executable. |
| 11 | 11 |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/at_exit.h" | 14 #include "base/at_exit.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 | 16 |
| 17 namespace testing { | 17 namespace testing { |
| 18 class TestInfo; | 18 class TestInfo; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace base { | 21 namespace base { |
| 22 | 22 |
| 23 class TestSuite { | 23 class TestSuite { |
| 24 public: | 24 public: |
| 25 // Match function used by the GetTestCount method. | 25 // Match function used by the GetTestCount method. |
| 26 typedef bool (*TestMatch)(const testing::TestInfo&); | 26 typedef bool (*TestMatch)(const testing::TestInfo&); |
|
jam
2012/12/21 23:12:22
this isn't used anymore, remove
| |
| 27 | 27 |
| 28 TestSuite(int argc, char** argv); | 28 TestSuite(int argc, char** argv); |
| 29 virtual ~TestSuite(); | 29 virtual ~TestSuite(); |
| 30 | 30 |
| 31 // Returns true if the test is marked as flaky. | |
| 32 static bool IsMarkedFlaky(const testing::TestInfo& test); | |
| 33 | |
| 34 // Returns true if the test is marked as failing. | |
| 35 static bool IsMarkedFailing(const testing::TestInfo& test); | |
| 36 | |
| 37 // Returns true if the test is marked as "MAYBE_". | 31 // Returns true if the test is marked as "MAYBE_". |
| 38 // When using different prefixes depending on platform, we use MAYBE_ and | 32 // When using different prefixes depending on platform, we use MAYBE_ and |
| 39 // preprocessor directives to replace MAYBE_ with the target prefix. | 33 // preprocessor directives to replace MAYBE_ with the target prefix. |
| 40 static bool IsMarkedMaybe(const testing::TestInfo& test); | 34 static bool IsMarkedMaybe(const testing::TestInfo& test); |
| 41 | 35 |
| 42 // Returns true if the test failure should be ignored. | |
| 43 static bool ShouldIgnoreFailure(const testing::TestInfo& test); | |
| 44 | |
| 45 // Returns true if the test failed and the failure shouldn't be ignored. | |
| 46 static bool NonIgnoredFailures(const testing::TestInfo& test); | |
| 47 | |
| 48 // Returns the number of tests where the match function returns true. | |
| 49 int GetTestCount(TestMatch test_match); | |
| 50 | |
| 51 void CatchMaybeTests(); | 36 void CatchMaybeTests(); |
| 52 | 37 |
| 53 void ResetCommandLine(); | 38 void ResetCommandLine(); |
| 54 | 39 |
| 55 int Run(); | 40 int Run(); |
| 56 | 41 |
| 57 // A command-line flag that makes a test failure always result in a non-zero | |
| 58 // process exit code. | |
| 59 static const char kStrictFailureHandling[]; | |
| 60 | |
| 61 protected: | 42 protected: |
| 62 // This constructor is only accessible to specialized test suite | 43 // This constructor is only accessible to specialized test suite |
| 63 // implementations which need to control the creation of an AtExitManager | 44 // implementations which need to control the creation of an AtExitManager |
| 64 // instance for the duration of the test. | 45 // instance for the duration of the test. |
| 65 TestSuite(int argc, char** argv, bool create_at_exit_manager); | 46 TestSuite(int argc, char** argv, bool create_at_exit_manager); |
| 66 | 47 |
| 67 // By default fatal log messages (e.g. from DCHECKs) result in error dialogs | 48 // By default fatal log messages (e.g. from DCHECKs) result in error dialogs |
| 68 // which gum up buildbots. Use a minimalistic assert handler which just | 49 // which gum up buildbots. Use a minimalistic assert handler which just |
| 69 // terminates the process. | 50 // terminates the process. |
| 70 static void UnitTestAssertHandler(const std::string& str); | 51 static void UnitTestAssertHandler(const std::string& str); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 91 DISALLOW_COPY_AND_ASSIGN(TestSuite); | 72 DISALLOW_COPY_AND_ASSIGN(TestSuite); |
| 92 }; | 73 }; |
| 93 | 74 |
| 94 } // namespace base | 75 } // namespace base |
| 95 | 76 |
| 96 // TODO(brettw) remove this. This is a temporary hack to allow WebKit to compile | 77 // TODO(brettw) remove this. This is a temporary hack to allow WebKit to compile |
| 97 // until we can update it to use "base::" (preventing a two-sided patch). | 78 // until we can update it to use "base::" (preventing a two-sided patch). |
| 98 using base::TestSuite; | 79 using base::TestSuite; |
| 99 | 80 |
| 100 #endif // BASE_TEST_TEST_SUITE_H_ | 81 #endif // BASE_TEST_TEST_SUITE_H_ |
| OLD | NEW |