From abc9be0250c154549f85b127a41a819eb5da869f Mon Sep 17 00:00:00 2001 From: Kurtis Rader Date: Fri, 4 Aug 2017 12:01:16 -0700 Subject: [PATCH] use new `logmsg` and `set --show` in tests --- tests/fish_opt.err | 47 +++++++++++++++++++++++++++++++++++++----- tests/fish_opt.in | 28 ++++++++++++------------- tests/fish_opt.out | 51 ++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 98 insertions(+), 28 deletions(-) diff --git a/tests/fish_opt.err b/tests/fish_opt.err index e034573c1..3d14b2fe6 100644 --- a/tests/fish_opt.err +++ b/tests/fish_opt.err @@ -1,11 +1,48 @@ -# no args is an error + +#################### +# 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 + +#################### +# 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 + +#################### +# 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 + +#################### +# 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 + +#################### +# 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 index 8ab6a7061..b9dfb992f 100644 --- a/tests/fish_opt.in +++ b/tests/fish_opt.in @@ -1,61 +1,61 @@ # Start by testing a bunch of error conditions. -echo '# no args is an error' >&2 +logmsg No args is an error fish_opt and echo unexpected status $status -echo '# no short flag or an invalid short flag is an error' >&2 +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 -echo '# a required and optional arg makes no sense' >&2 +logmsg A required and optional arg makes no sense fish_opt -s h -l help -r --optional-val and echo unexpected status $status -echo '# a repeated and optional arg makes no sense' >&2 +logmsg A repeated and optional arg makes no sense fish_opt -s h -l help --multiple-vals --optional-val and echo unexpected status $status -echo '# an unexpected arg not associated with a flag is an error' >&2 +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. -echo '# bool, short only' +logmsg Bool, short only fish_opt -s h or echo unexpected status $status -echo '# bool, short and long' +logmsg Bool, short and long fish_opt --short h --long help or echo unexpected status $status -echo '# bool, short and long but the short var cannot be used' +logmsg Bool, short and long but the short var cannot be used fish_opt --short h --long help --long-only -echo '# required val, short and long but the short var cannot be used' +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 -echo '# optional val, short and long valid' +logmsg Optional val, short and long valid fish_opt --short h -l help --optional-val or echo unexpected status $status -echo '# optional val, short and long but the short var cannot be used' +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 -echo '# repeated val, short and long valid' +logmsg Repeated val, short and long valid fish_opt --short h -l help --multiple-vals or echo unexpected status $status -echo '# repeated val, short and long but short not valid' +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 -echo '# repeated val, short only' +logmsg Repeated val, short only fish_opt -s h --multiple-vals or echo unexpected status $status fish_opt -s h --multiple-vals --long-only diff --git a/tests/fish_opt.out b/tests/fish_opt.out index 086e04064..25442fd86 100644 --- a/tests/fish_opt.out +++ b/tests/fish_opt.out @@ -1,19 +1,52 @@ -# bool, short only + +#################### +# 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 + +#################### +# Bool, short and long h/help -# bool, short and long but the short var cannot be used + +#################### +# 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 + +#################### +# Required val, short and long but the short var cannot be used h-help= -# optional val, short and long valid + +#################### +# Optional val, short and long valid h/help=? -# optional val, short and long but the short var cannot be used + +#################### +# Optional val, short and long but the short var cannot be used h-help=? -# repeated val, short and long valid + +#################### +# Repeated val, short and long valid h/help=+ -# repeated val, short and long but short not valid + +#################### +# Repeated val, short and long but short not valid h-help=+ -# repeated val, short only + +#################### +# Repeated val, short only h=+ h=+