Skip to content

Commit

Permalink
Update ci
Browse files Browse the repository at this point in the history
  • Loading branch information
gen740 committed Dec 7, 2023
1 parent f9902c8 commit f4b9703
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 49 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
brew update
brew unlink node@18 || echo "nod@18 no such keg"
brew unlink [email protected] || echo "[email protected] no such keg"
brew install node@18 --force
brew install [email protected] --force
brew upgrade
- name: Install llvm
Expand Down
7 changes: 6 additions & 1 deletion Argo/ArgoParserImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,12 @@ auto Parser<ID, Args, PArgs, HArg, SubParsers>::formatHelp(bool no_color) const

assert(this->info_); // this->info_ cannot be nullptr

auto help_info = HelpGenerator<tuple_append_t<Args, HArg>>::generate();
std::vector<ArgInfo> help_info;
if constexpr (std::is_same_v<HArg, void>) {
help_info = HelpGenerator<Args>::generate();
} else {
help_info = HelpGenerator<tuple_append_t<Args, HArg>>::generate();
}
auto sub_commands = SubParserInfo(subParsers);

if (this->info_->help) {
Expand Down
80 changes: 32 additions & 48 deletions tests/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,9 @@ TEST(ArgoTest, EqualAssign) {
TEST(ArgoTest, FlagArgument) {
auto [argc, argv] = createArgcArgv( //
"./main", //
"--arg1",
"--arg2=true",
"--arg1", "--arg2=true",
"--arg3=1", //
"--arg4",
"true",
"--arg5",
"--arg4", "true", "--arg5",
"1" //
);

Expand Down Expand Up @@ -86,8 +83,7 @@ TEST(ArgoTest, ShortArgument) {

TEST(ArgoTest, CombiningFlags) {
auto [argc, argv] = createArgcArgv( //
"./main",
"-abd",
"./main", "-abd",
"-e" //
);

Expand All @@ -109,8 +105,7 @@ TEST(ArgoTest, CombiningFlags) {

TEST(ArgoTest, CombiningFlagsWithOptionalArg) {
auto [argc, argv] = createArgcArgv( //
"./main",
"-abdc",
"./main", "-abdc",
"Hello,World" //
);

Expand All @@ -131,8 +126,7 @@ TEST(ArgoTest, CombiningFlagsWithOptionalArg) {
TEST(ArgoTest, Validation) {
{
auto [argc, argv] = createArgcArgv( //
"./main",
"--arg",
"./main", "--arg",
"42" //
);

Expand All @@ -146,8 +140,7 @@ TEST(ArgoTest, Validation) {
}
{
auto [argc, argv] = createArgcArgv( //
"./main",
"--arg",
"./main", "--arg",
"121" //
);

Expand Down Expand Up @@ -191,20 +184,12 @@ TEST(ArgoTest, Narg) {
{
auto [argc, argv] = createArgcArgv( //
"./main", //
"--arg1",
"1",
"2",
"--arg1", "1", "2",
"3", //
"--arg2", //
"--arg3",
"6.0",
"7.2",
"8.4",
"--arg3", "6.0", "7.2", "8.4",
"9.6", //
"--arg4",
"11",
"12",
"8",
"--arg4", "11", "12", "8",
"9" //
);

Expand Down Expand Up @@ -269,31 +254,33 @@ TEST(ArgoTest, NargException) {
}
}

// TEST(ArgoTest, Help) { // TODO(gen740): more help
// {
// auto argo = Argo::Parser<"Help 1">("program");
// auto parser = argo //
// .addArg<"arg0,k", int>()
// .addArg<"arg1,a", int, Argo::nargs('+')>()
// .addArg<"arg2", int,
// Argo::nargs('+')>(Argo::description("This is arg2"));
//
// auto expect_help = R"(Options:
// -k, --arg0
// -a, --arg1
// --arg2 This is arg2)";
//
// EXPECT_EQ(parser.formatHelp(false), expect_help);
// }
// }
TEST(ArgoTest, Help) { // TODO(gen740): more help
{
auto argo = Argo::Parser<"Help 1">("program");
auto parser = argo //
.addArg<"arg0,k", int>()
.addArg<"arg1,a", int, Argo::nargs('+')>()
.addArg<"arg2", int, Argo::nargs('+')>(
Argo::description("This is arg2"));

const auto* expect_help = R"(
USAGE:
program [options...]
Options:
-k, --arg0 [<NUMBER>]
-a, --arg1 <NUMBER,...>
--arg2 <NUMBER,...> This is arg2)";

EXPECT_EQ(parser.formatHelp(true), expect_help);
}
}

TEST(ArgoTest, Required) {
{
auto [argc, argv] = createArgcArgv( //
"./main", //
"--arg1",
"1",
"--arg2",
"--arg1", "1", "--arg2",
"2" //
);

Expand All @@ -309,14 +296,11 @@ TEST(ArgoTest, Required) {
}
}


TEST(ArgoTest, IsAssigned) {
{
auto [argc, argv] = createArgcArgv( //
"./main", //
"--arg1",
"42",
"--arg2",
"--arg1", "42", "--arg2",
"--arg4" //
);

Expand Down

0 comments on commit f4b9703

Please sign in to comment.