google / googletest

GoogleTest - Google Testing and Mocking Framework
https://google.github.io/googletest/
BSD 3-Clause "New" or "Revised" License
33.68k stars 9.98k forks source link

[Bug]: Google Test Executables don't respect additional help flags mentioned in the documentation #4564

Open codeinred opened 1 week ago

codeinred commented 1 week ago

Describe the issue

The documentation: states that the following flags are supported:

To see a list of supported flags and their usage, please run your test program with the --help flag. You can also use -h, -?, or /? for short.

However, executables only check for the --help flag (and not the short-hand variants):

    // ...
    } else if (arg_string == "--help" || HasGoogleTestFlagPrefix(arg)) {
      // Both help flag and unrecognized Google Test flags (excluding
      // internal ones) trigger help display.
      g_help_flag = true;
    }
    // ...

Steps to reproduce the problem

Reproduce as follows:

  1. Build any google test executable
  2. Run it with -h, -?, or /?
  3. Observe that tests execute, and no help text is printed.

What version of GoogleTest are you using?

Latest version of google test, v1.14.0, although this bug applies to much older versions as well.

Output of git rev-parse HEAD: 1d17ea141d2c11b8917d2c7d029f1c4e2b9769b2

What operating system and version are you using?

MacOS, although this bug applies to all platforms.

What compiler and version are you using?

This isn't relevant to the bug, as it applies to all platforms, however the output is:

Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

What build system are you using?

cmake version 3.29.6

CMake suite maintained and supported by Kitware (kitware.com/cmake).

Additional context

I've provided a fix in PR #4563