diff options
Diffstat (limited to 'googletest')
-rw-r--r-- | googletest/src/gtest.cc | 2 | ||||
-rwxr-xr-x | googletest/test/googletest-filter-unittest.py | 31 |
2 files changed, 32 insertions, 1 deletions
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index e422e92..10cff8e 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -2821,7 +2821,7 @@ void UnitTestImpl::RegisterParameterizedTests() { void TestInfo::Run() { TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater(); if (!should_run_) { - if (is_disabled_) repeater->OnTestDisabled(*this); + if (is_disabled_ && matches_filter_) repeater->OnTestDisabled(*this); return; } diff --git a/googletest/test/googletest-filter-unittest.py b/googletest/test/googletest-filter-unittest.py index bd1d5a5..2c4a1b1 100755 --- a/googletest/test/googletest-filter-unittest.py +++ b/googletest/test/googletest-filter-unittest.py @@ -113,6 +113,9 @@ TEST_CASE_REGEX = re.compile(r'^\[\-+\] \d+ tests? from (\w+(/\w+)?)') # Regex for parsing test names from Google Test's output. TEST_REGEX = re.compile(r'^\[\s*RUN\s*\].*\.(\w+(/\w+)?)') +# Regex for parsing disabled banner from Google Test's output +DISABLED_BANNER_REGEX = re.compile(r'^\[\s*DISABLED\s*\] (.*)') + # The command line flag to tell Google Test to output the list of tests it # will run. LIST_TESTS_FLAG = '--gtest_list_tests' @@ -206,6 +209,17 @@ def RunAndExtractTestList(args = None): return (tests_run, p.exit_code) +def RunAndExtractDisabledBannerList(args=None): + """Runs the test program and returns tests that printed a disabled banner.""" + p = gtest_test_utils.Subprocess([COMMAND] + (args or []), env=environ) + banners_printed = [] + for line in p.output.split('\n'): + match = DISABLED_BANNER_REGEX.match(line) + if match is not None: + banners_printed.append(match.group(1)) + return banners_printed + + def InvokeWithModifiedEnv(extra_env, function, *args, **kwargs): """Runs the given function and arguments in a modified environment.""" try: @@ -613,6 +627,23 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase): self.assert_(os.path.exists(shard_status_file)) os.remove(shard_status_file) + def testDisabledBanner(self): + """Tests that the disabled banner prints only tests that match filter.""" + make_filter = lambda s: ['--%s=%s' % (FILTER_FLAG, s)] + + banners = RunAndExtractDisabledBannerList(make_filter('*')) + self.AssertSetEqual(banners, [ + 'BarTest.DISABLED_TestFour', 'BarTest.DISABLED_TestFive', + 'BazTest.DISABLED_TestC' + ]) + + banners = RunAndExtractDisabledBannerList(make_filter('Bar*')) + self.AssertSetEqual( + banners, ['BarTest.DISABLED_TestFour', 'BarTest.DISABLED_TestFive']) + + banners = RunAndExtractDisabledBannerList(make_filter('*-Bar*')) + self.AssertSetEqual(banners, ['BazTest.DISABLED_TestC']) + if SUPPORTS_DEATH_TESTS: def testShardingWorksWithDeathTests(self): """Tests integration with death tests and sharding.""" |