summaryrefslogtreecommitdiffstats
path: root/googletest
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2022-03-22 16:07:20 (GMT)
committerCopybara-Service <copybara-worker@google.com>2022-03-22 16:07:51 (GMT)
commit5d6f38c1e2bc5e462e7bbb743903479ee2c54f7e (patch)
tree2ca95233b7f0848fc62ede9786b77daeccf19fa0 /googletest
parent1754febbaa863ae95f34c4aff46162f11186a899 (diff)
downloadgoogletest-5d6f38c1e2bc5e462e7bbb743903479ee2c54f7e.zip
googletest-5d6f38c1e2bc5e462e7bbb743903479ee2c54f7e.tar.gz
googletest-5d6f38c1e2bc5e462e7bbb743903479ee2c54f7e.tar.bz2
Only print disabled test banner if the test matches gtest_filter
Currently, the "[ DISABLED ]" banner is printed for every test in a suite. When iterating on a single test gtest_filter this is very noisy. PiperOrigin-RevId: 436489088 Change-Id: If337087a7a0986b073fabf2b0a55d26485eb5c37
Diffstat (limited to 'googletest')
-rw-r--r--googletest/src/gtest.cc2
-rwxr-xr-xgoogletest/test/googletest-filter-unittest.py31
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."""