Skip the .exe suffix in the helpshort filter on Windows (#629)

On Windows, the `flags_internal::ShortProgramInvocationName()`
function usually returns the program name with '.exe' (if the
extension is present in the command line during the program startup).
This fact breaks the checks in the `ContainsHelpshortFlags` filter:
obviously, module names have no .exe in them. Therefore, no defined flags
are shown when the program runs with the --help flag. The program name
should be used in filter without this extension even though it is present.

The unit test has also been updated.

Signed-off-by: Pavel Samolysov <samolisov@gmail.com>
This commit is contained in:
Pavel Samolysov 2020-03-09 21:37:46 +03:00 committed by GitHub
parent 417ea99cba
commit 238b9a59c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View file

@ -84,7 +84,11 @@ TEST_F(FlagsUsageConfigTest, TestGetSetFlagsUsageConfig) {
// --------------------------------------------------------------------
TEST_F(FlagsUsageConfigTest, TestContainsHelpshortFlags) {
#if defined(_WIN32)
flags::SetProgramInvocationName("usage_config_test.exe");
#else
flags::SetProgramInvocationName("usage_config_test");
#endif
auto config = flags::GetUsageConfig();
EXPECT_TRUE(config.contains_helpshort_flags("adir/cd/usage_config_test.cc"));