Do not print skipped test's messages in brief mode

This commit is contained in:
Harry Saunders 2025-07-03 18:52:17 +01:00
parent 3983f67e32
commit 8d24b1552b
No known key found for this signature in database
2 changed files with 15 additions and 2 deletions

View File

@ -2463,7 +2463,7 @@ void TestResult::Clear() {
elapsed_time_ = 0;
}
// Returns true off the test part was skipped.
// Returns true if the test part was skipped.
static bool TestPartSkipped(const TestPartResult& result) {
return result.skipped();
}
@ -3755,6 +3755,8 @@ void BriefUnitTestResultPrinter::OnTestPartResult(
// If the test part succeeded, we don't need to do anything.
case TestPartResult::kSuccess:
return;
case TestPartResult::kSkip:
return;
default:
// Print failure message from the assertion
// (e.g. expected this and got that).

View File

@ -37,7 +37,7 @@ import re
from googletest.test import gtest_test_utils
# Path to the gtest_skip_in_environment_setup_test binary
# Path to the gtest_skip_test binary
EXE_PATH = gtest_test_utils.GetTestExecutablePath('gtest_skip_test')
OUTPUT = gtest_test_utils.Subprocess([EXE_PATH]).output
@ -55,6 +55,17 @@ class SkipEntireEnvironmentTest(gtest_test_utils.TestCase):
)
self.assertNotIn('FAILED', OUTPUT)
def testSkipTestWithBriefFlag(self):
brief_output = gtest_test_utils.Subprocess([EXE_PATH, "--gtest_brief=1"]).output
self.assertNotIn('Skipped\nskipping single test\n', brief_output)
skip_fixture = 'Skipped\nskipping all tests for this fixture\n'
self.assertIsNone(
re.search(skip_fixture + '.*' + skip_fixture, brief_output, flags=re.DOTALL),
repr(brief_output),
)
self.assertIn('SKIPPED', brief_output)
self.assertNotIn('FAILED', brief_output)
if __name__ == '__main__':
gtest_test_utils.Main()