Merge 3df62357ab54be772d421c2dd0767c56b5b5247c into a0f06a70e3da7afa88da9527c43951bca1f7cef2

This commit is contained in:
Kirtikumar Anandrao Ramchandani 2026-07-29 15:06:03 -04:00 committed by GitHub
commit 1697e1e952
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 3 deletions

View File

@ -6885,9 +6885,12 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {
LoadFlagsFromFile(flagfile_value);
remove_flag = true;
#endif // GTEST_USE_OWN_FLAGFILE_FLAG_ && GTEST_HAS_FILE_SYSTEM
} else if (arg_string == "--help" || HasGoogleTestFlagPrefix(arg)) {
// Both help flag and unrecognized Google Test flags (excluding
// internal ones) trigger help display.
} else if (arg_string == "--help") {
g_help_flag = true;
remove_flag = true;
} else if (HasGoogleTestFlagPrefix(arg)) {
// Unrecognized Google Test flags (excluding internal ones) trigger help
// display, but remain available for other flag parsers.
g_help_flag = true;
}

View File

@ -5993,6 +5993,15 @@ TEST_F(ParseFlagsTest, UnrecognizedFlag) {
GTEST_TEST_PARSING_FLAGS_(argv, argv2, flags, false);
}
// Tests having a --help flag on the command line.
TEST_F(ParseFlagsTest, HelpFlag) {
const char* argv[] = {"foo.exe", "--help", "bar", nullptr};
const char* argv2[] = {"foo.exe", "bar", nullptr};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), true);
}
// Tests having a --gtest_list_tests flag
TEST_F(ParseFlagsTest, ListTestsFlag) {
const char* argv[] = {"foo.exe", "--gtest_list_tests", nullptr};