diff options
author | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2009-04-24 20:27:29 (GMT) |
---|---|---|
committer | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2009-04-24 20:27:29 (GMT) |
commit | fa2b06c52fa3ffb1909ed8b928e106292609cfcb (patch) | |
tree | 9641a37117afa67d303e37434a6b1810dee190f9 /test | |
parent | f2d0d0e3d56794855d1e9a1f157457b7225e8c88 (diff) | |
download | googletest-fa2b06c52fa3ffb1909ed8b928e106292609cfcb.zip googletest-fa2b06c52fa3ffb1909ed8b928e106292609cfcb.tar.gz googletest-fa2b06c52fa3ffb1909ed8b928e106292609cfcb.tar.bz2 |
Makes --gtest_list_tests honor the test filter (by Jay Campan).
Diffstat (limited to 'test')
-rwxr-xr-x | test/gtest_list_tests_unittest.py | 55 | ||||
-rw-r--r-- | test/gtest_list_tests_unittest_.cc | 4 |
2 files changed, 40 insertions, 19 deletions
diff --git a/test/gtest_list_tests_unittest.py b/test/gtest_list_tests_unittest.py index 147bd73..3d006df 100755 --- a/test/gtest_list_tests_unittest.py +++ b/test/gtest_list_tests_unittest.py @@ -56,12 +56,12 @@ EXE_PATH = gtest_test_utils.GetTestExecutablePath('gtest_list_tests_unittest_') # The expected output when running gtest_list_tests_unittest_ with # --gtest_list_tests -EXPECTED_OUTPUT = """FooDeathTest. +EXPECTED_OUTPUT_NO_FILTER = """FooDeathTest. Test1 Foo. Bar1 Bar2 - Bar3 + DISABLED_Bar3 Abc. Xyz Def @@ -69,17 +69,33 @@ FooBar. Baz FooTest. Test1 - Test2 + DISABLED_Test2 + Test3 +""" + +# The expected output when running gtest_list_tests_unittest_ with +# --gtest_list_tests and --gtest_filter=Foo*. +EXPECTED_OUTPUT_FILTER_FOO = """FooDeathTest. + Test1 +Foo. + Bar1 + Bar2 + DISABLED_Bar3 +FooBar. + Baz +FooTest. + Test1 + DISABLED_Test2 Test3 """ # Utilities. + def Run(command): - """Runs a command and returns the list of tests printed. - """ + """Runs a command and returns the list of tests printed.""" - stdout_file = os.popen(command, "r") + stdout_file = os.popen(command, 'r') output = stdout_file.read() @@ -90,8 +106,7 @@ def Run(command): # The unit test. class GTestListTestsUnitTest(unittest.TestCase): - """Tests using the --gtest_list_tests flag to list all tests. - """ + """Tests using the --gtest_list_tests flag to list all tests.""" def RunAndVerify(self, flag_value, expected_output, other_flag): """Runs gtest_list_tests_unittest_ and verifies that it prints @@ -126,12 +141,12 @@ class GTestListTestsUnitTest(unittest.TestCase): output = Run(command) msg = ('when %s is %s, the output of "%s" is "%s".' % - (LIST_TESTS_FLAG, flag_expression, command, output)) + (LIST_TESTS_FLAG, flag_expression, command, output)) if expected_output is not None: self.assert_(output == expected_output, msg) else: - self.assert_(output != EXPECTED_OUTPUT, msg) + self.assert_(output != EXPECTED_OUTPUT_NO_FILTER, msg) def testDefaultBehavior(self): """Tests the behavior of the default mode.""" @@ -147,18 +162,24 @@ class GTestListTestsUnitTest(unittest.TestCase): expected_output=None, other_flag=None) self.RunAndVerify(flag_value='1', - expected_output=EXPECTED_OUTPUT, + expected_output=EXPECTED_OUTPUT_NO_FILTER, other_flag=None) - def testOverrideOtherFlags(self): - """Tests that --gtest_list_tests overrides all other flags.""" + def testOverrideNonFilterFlags(self): + """Tests that --gtest_list_tests overrides the non-filter flags.""" self.RunAndVerify(flag_value="1", - expected_output=EXPECTED_OUTPUT, - other_flag="--gtest_filter=*") - self.RunAndVerify(flag_value="1", - expected_output=EXPECTED_OUTPUT, + expected_output=EXPECTED_OUTPUT_NO_FILTER, other_flag="--gtest_break_on_failure") + def testWithFilterFlags(self): + """Tests that --gtest_list_tests takes into account the + --gtest_filter flag.""" + + self.RunAndVerify(flag_value="1", + expected_output=EXPECTED_OUTPUT_FILTER_FOO, + other_flag="--gtest_filter=Foo*") + + if __name__ == '__main__': gtest_test_utils.Main() diff --git a/test/gtest_list_tests_unittest_.cc b/test/gtest_list_tests_unittest_.cc index 566694b..b5e07dd 100644 --- a/test/gtest_list_tests_unittest_.cc +++ b/test/gtest_list_tests_unittest_.cc @@ -50,7 +50,7 @@ TEST(Foo, Bar1) { TEST(Foo, Bar2) { } -TEST(Foo, Bar3) { +TEST(Foo, DISABLED_Bar3) { } TEST(Abc, Xyz) { @@ -68,7 +68,7 @@ class FooTest : public testing::Test { TEST_F(FooTest, Test1) { } -TEST_F(FooTest, Test2) { +TEST_F(FooTest, DISABLED_Test2) { } TEST_F(FooTest, Test3) { |