Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Adapt the version checker to sharg. #38

Merged
merged 6 commits into from
Jan 5, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions test/unit/detail/version_check_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,12 @@ TEST_F(version_check, option_off)
EXPECT_FALSE(std::filesystem::exists(app_timestamp_filename())) << app_timestamp_filename();

EXPECT_TRUE(remove_files_from_path()); // clear files again
}

TEST_F(version_check, option_off_with_help_page)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good split! much nicer!

{
// Version check option always needs to be parsed, even if special formats get selected
const char * argv2[4] = {app_name.c_str(), "-h", OPTION_VERSION_CHECK, OPTION_OFF};
const char * argv[4] = {app_name.c_str(), "-h", OPTION_VERSION_CHECK, OPTION_OFF};

std::string previous_value{};
if (char * env = std::getenv("SHARG_NO_VERSION_CHECK"))
Expand All @@ -353,7 +356,7 @@ TEST_F(version_check, option_off)
unsetenv("SHARG_NO_VERSION_CHECK");
}

sharg::argument_parser parser{app_name, 4, argv2};
sharg::argument_parser parser{app_name, 4, argv};
parser.info.version = "2.3.4";

EXPECT_EXIT(parser.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), "");
Expand Down