Skip to content

Fix: InitGoogleTest now consumes and removes the --help flag#4959

Open
Root-Aamir wants to merge 1 commit into
google:mainfrom
Root-Aamir:fix-help-flag-consumption
Open

Fix: InitGoogleTest now consumes and removes the --help flag#4959
Root-Aamir wants to merge 1 commit into
google:mainfrom
Root-Aamir:fix-help-flag-consumption

Conversation

@Root-Aamir
Copy link
Copy Markdown

Description

Currently, when --help is passed to a GoogleTest binary, InitGoogleTest sets the internal help flag but does not remove the flag from argv. This prevents downstream argument parsers from knowing that the flag has already been handled.

Changes

  • Updated ParseGoogleTestFlagsOnlyImpl in gtest.cc to set remove_flag = true when --help or other unrecognized GTest flags are encountered.
  • This ensures argc is decremented and the help flag is removed from the arguments list after initialization.

Verification

Reproduced the issue with a manual test runner.

  • Before fix: argc remained 2 after InitGoogleTest when passing --help.
  • After fix: argc correctly becomes 1.

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 18, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@Root-Aamir Root-Aamir force-pushed the fix-help-flag-consumption branch from 1348897 to 1abf935 Compare April 18, 2026 01:26
@Root-Aamir
Copy link
Copy Markdown
Author

I have signed the CLA.

@Root-Aamir
Copy link
Copy Markdown
Author

@googlebot I signed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant