diff --git a/tests/checks/argparse.fish b/tests/checks/argparse.fish index 5c9ca8ec6..7d0a5f3dd 100644 --- a/tests/checks/argparse.fish +++ b/tests/checks/argparse.fish @@ -310,3 +310,81 @@ argparse -n foo q r/required= -- foo -qr argparse r/required= -- foo --required # CHECKERR: argparse: Expected argument for option --required + +### The fish_opt wrapper: +# No args is an error +fish_opt +and echo unexpected status $status +#CHECKERR: fish_opt: The --short flag is required and must be a single character + +# No short flag or an invalid short flag is an error +fish_opt -l help +and echo unexpected status $status +#CHECKERR: fish_opt: The --short flag is required and must be a single character +fish_opt -s help +and echo unexpected status $status +#CHECKERR: fish_opt: The --short flag is required and must be a single character + +# A required and optional arg makes no sense +fish_opt -s h -l help -r --optional-val +and echo unexpected status $status +#CHECKERR: fish_opt: Mutually exclusive flags 'o/optional-val' and `r/required-val` seen + +# A repeated and optional arg makes no sense +fish_opt -s h -l help --multiple-vals --optional-val +and echo unexpected status $status +#CHECKERR: fish_opt: Mutually exclusive flags 'multiple-vals' and `o/optional-val` seen + +# An unexpected arg not associated with a flag is an error +fish_opt -s h -l help hello +and echo unexpected status $status +#CHECKERR: fish_opt: Expected at most 0 args, got 1 + +# Now verify that valid combinations of options produces the correct output. + +# Bool, short only +fish_opt -s h +or echo unexpected status $status +#CHECK: h + +# Bool, short and long +fish_opt --short h --long help +or echo unexpected status $status +#CHECK: h/help + +# Bool, short and long but the short var cannot be used +fish_opt --short h --long help --long-only +#CHECK: h-help + +# Required val, short and long but the short var cannot be used +fish_opt --short h --long help -r --long-only +or echo unexpected status $status +#CHECK: h-help= + +# Optional val, short and long valid +fish_opt --short h -l help --optional-val +or echo unexpected status $status +#CHECK: h/help=? + +# Optional val, short and long but the short var cannot be used +fish_opt --short h -l help --optional-val --long-only +or echo unexpected status $status +#CHECK: h-help=? + +# Repeated val, short and long valid +fish_opt --short h -l help --multiple-vals +or echo unexpected status $status +#CHECK: h/help=+ + +# Repeated val, short and long but short not valid +fish_opt --short h -l help --multiple-vals --long-only +or echo unexpected status $status +#CHECK: h-help=+ + +# Repeated val, short only +fish_opt -s h --multiple-vals +or echo unexpected status $status +fish_opt -s h --multiple-vals --long-only +or echo unexpected status $status +#CHECK: h=+ +#CHECK: h=+ diff --git a/tests/fish_opt.err b/tests/fish_opt.err deleted file mode 100644 index 3d14b2fe6..000000000 --- a/tests/fish_opt.err +++ /dev/null @@ -1,48 +0,0 @@ - -#################### -# No args is an error -fish_opt: The --short flag is required and must be a single character - -#################### -# No short flag or an invalid short flag is an error -fish_opt: The --short flag is required and must be a single character -fish_opt: The --short flag is required and must be a single character - -#################### -# A required and optional arg makes no sense -fish_opt: Mutually exclusive flags 'o/optional-val' and `r/required-val` seen - -#################### -# A repeated and optional arg makes no sense -fish_opt: Mutually exclusive flags 'multiple-vals' and `o/optional-val` seen - -#################### -# An unexpected arg not associated with a flag is an error -fish_opt: Expected at most 0 args, got 1 - -#################### -# Bool, short only - -#################### -# Bool, short and long - -#################### -# Bool, short and long but the short var cannot be used - -#################### -# Required val, short and long but the short var cannot be used - -#################### -# Optional val, short and long valid - -#################### -# Optional val, short and long but the short var cannot be used - -#################### -# Repeated val, short and long valid - -#################### -# Repeated val, short and long but short not valid - -#################### -# Repeated val, short only diff --git a/tests/fish_opt.in b/tests/fish_opt.in deleted file mode 100644 index b9dfb992f..000000000 --- a/tests/fish_opt.in +++ /dev/null @@ -1,62 +0,0 @@ -# Start by testing a bunch of error conditions. - -logmsg No args is an error -fish_opt -and echo unexpected status $status - -logmsg No short flag or an invalid short flag is an error -fish_opt -l help -and echo unexpected status $status -fish_opt -s help -and echo unexpected status $status - -logmsg A required and optional arg makes no sense -fish_opt -s h -l help -r --optional-val -and echo unexpected status $status - -logmsg A repeated and optional arg makes no sense -fish_opt -s h -l help --multiple-vals --optional-val -and echo unexpected status $status - -logmsg An unexpected arg not associated with a flag is an error -fish_opt -s h -l help hello -and echo unexpected status $status - -# Now verify that valid combinations of options produces the correct output. - -logmsg Bool, short only -fish_opt -s h -or echo unexpected status $status - -logmsg Bool, short and long -fish_opt --short h --long help -or echo unexpected status $status - -logmsg Bool, short and long but the short var cannot be used -fish_opt --short h --long help --long-only - -logmsg Required val, short and long but the short var cannot be used -fish_opt --short h --long help -r --long-only -or echo unexpected status $status - -logmsg Optional val, short and long valid -fish_opt --short h -l help --optional-val -or echo unexpected status $status - -logmsg Optional val, short and long but the short var cannot be used -fish_opt --short h -l help --optional-val --long-only -or echo unexpected status $status - -logmsg Repeated val, short and long valid -fish_opt --short h -l help --multiple-vals -or echo unexpected status $status - -logmsg Repeated val, short and long but short not valid -fish_opt --short h -l help --multiple-vals --long-only -or echo unexpected status $status - -logmsg Repeated val, short only -fish_opt -s h --multiple-vals -or echo unexpected status $status -fish_opt -s h --multiple-vals --long-only -or echo unexpected status $status diff --git a/tests/fish_opt.out b/tests/fish_opt.out deleted file mode 100644 index 25442fd86..000000000 --- a/tests/fish_opt.out +++ /dev/null @@ -1,52 +0,0 @@ - -#################### -# No args is an error - -#################### -# No short flag or an invalid short flag is an error - -#################### -# A required and optional arg makes no sense - -#################### -# A repeated and optional arg makes no sense - -#################### -# An unexpected arg not associated with a flag is an error - -#################### -# Bool, short only -h - -#################### -# Bool, short and long -h/help - -#################### -# Bool, short and long but the short var cannot be used -h-help - -#################### -# Required val, short and long but the short var cannot be used -h-help= - -#################### -# Optional val, short and long valid -h/help=? - -#################### -# Optional val, short and long but the short var cannot be used -h-help=? - -#################### -# Repeated val, short and long valid -h/help=+ - -#################### -# Repeated val, short and long but short not valid -h-help=+ - -#################### -# Repeated val, short only -h=+ -h=+