Use Abseil Flag public API for flag parsing.

This change brings InitGoogleTest semantic in accordance with the official documentation: only GoogleTest flags are removed from argc/argv. The rest of the flags remains in place. We do nothing special for flags with unrecognized gunit_/gtest_ prefix and we do not report them.

PiperOrigin-RevId: 527257221
Change-Id: Ibb29a1bda1a44251a4ee579c0fb5bbdfd9965c21
This commit is contained in:
Abseil Team
2023-04-26 07:13:23 -07:00
committed by Copybara-Service
parent ccdeec888e
commit dea0484e4d
4 changed files with 67 additions and 30 deletions

View File

@@ -54,7 +54,6 @@ PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath('gtest_help_test_')
FLAG_PREFIX = '--gtest_'
DEATH_TEST_STYLE_FLAG = FLAG_PREFIX + 'death_test_style'
STREAM_RESULT_TO_FLAG = FLAG_PREFIX + 'stream_result_to'
UNKNOWN_GTEST_PREFIXED_FLAG = FLAG_PREFIX + 'unknown_flag_for_testing'
LIST_TESTS_FLAG = FLAG_PREFIX + 'list_tests'
INTERNAL_FLAG_FOR_TESTING = FLAG_PREFIX + 'internal_flag_for_testing'
@@ -177,16 +176,6 @@ class GTestHelpTest(gtest_test_utils.TestCase):
def testPrintsHelpWithFullFlag(self):
self.TestHelpFlag('--help')
def testPrintsHelpWithUnrecognizedGoogleTestFlag(self):
# The behavior is slightly different when Abseil flags is
# used. Abseil flags rejects all unknown flags, while the builtin
# GTest flags implementation interprets an unknown flag with a
# '--gtest_' prefix as a request for help.
if HAS_ABSL_FLAGS:
self.TestUnknownFlagWithAbseil(UNKNOWN_GTEST_PREFIXED_FLAG)
else:
self.TestHelpFlag(UNKNOWN_GTEST_PREFIXED_FLAG)
def testRunsTestsWithoutHelpFlag(self):
"""Verifies correct behavior when no help flag is specified.