Update tests for changed error output

This commit is contained in:
Aaron Gyes 2021-11-03 22:52:17 -07:00
parent 72c04d11ad
commit fefb913857
19 changed files with 107 additions and 102 deletions

View file

@ -8,7 +8,7 @@ function __fish_unexpected_hist_args --no-scope-shadowing
return 0
end
if set -q argv[1]
printf (_ "%ls: %ls: expected %d arguments; got %d") $cmd $hist_cmd 0 (count $argv) >&2
printf (_ "%ls: %ls: expected %d arguments; got %d\n") $cmd $hist_cmd 0 (count $argv) >&2
return 0
end
return 1

View file

@ -113,34 +113,40 @@ echo comment after conjunction
# --help works
builtin and --help >/dev/null
# CHECKERR: fish: Missing man page {{.*}}
# CHECKERR: `help '{{.*}}'` will open the online version.
# CHECKERR: fish: and: missing man page
# CHECKERR: Documentation may not be installed.
# CHECKERR: `help and` will show an online version
echo $status
and --help >/dev/null
# CHECKERR: fish: Missing man page {{.*}}
# CHECKERR: `help '{{.*}}'` will open the online version.
# CHECKERR: fish: and: missing man page
# CHECKERR: Documentation may not be installed.
# CHECKERR: `help and` will show an online version
echo $status
# CHECK: 0
# CHECK: 0
builtin or --help >/dev/null
# CHECKERR: fish: Missing man page {{.*}}
# CHECKERR: `help '{{.*}}'` will open the online version.
# CHECKERR: fish: or: missing man page
# CHECKERR: Documentation may not be installed.
# CHECKERR: `help or` will show an online version
echo $status
or --help >/dev/null
# CHECKERR: fish: Missing man page {{.*}}
# CHECKERR: `help '{{.*}}'` will open the online version.
# CHECKERR: fish: or: missing man page
# CHECKERR: Documentation may not be installed.
# CHECKERR: `help or` will show an online version
echo $status
# CHECK: 0
# CHECK: 0
builtin not --help >/dev/null
# CHECKERR: fish: Missing man page {{.*}}
# CHECKERR: `help '{{.*}}'` will open the online version.
# CHECKERR: fish: not: missing man page
# CHECKERR: Documentation may not be installed.
# CHECKERR: `help not` will show an online version
echo $status
not --help >/dev/null
# CHECKERR: fish: Missing man page {{.*}}
# CHECKERR: `help '{{.*}}'` will open the online version.
# CHECKERR: fish: not: missing man page
# CHECKERR: Documentation may not be installed.
# CHECKERR: `help not` will show an online version
echo $status
# CHECK: 0
# CHECK: 0

View file

@ -66,16 +66,16 @@ argparse h-help=x
# --max-args and --min-args work
begin
argparse --name min-max --min-args 1 h/help --
#CHECKERR: min-max: Expected at least 1 args, got 0
#CHECKERR: min-max: expected >= 1 arguments; got 0
argparse --name min-max --min-args 1 --max-args 3 h/help -- arg1
argparse --name min-max --min-args 1 --max-args 3 h/help -- arg1 arg2
argparse --name min-max --min-args 1 --max-args 3 h/help -- --help arg1 arg2 arg3
argparse --name min-max --min-args 1 --max-args 3 h/help -- arg1 arg2 -h arg3 arg4
#CHECKERR: min-max: Expected at most 3 args, got 4
#CHECKERR: min-max: expected <= 3 arguments; got 4
argparse --name min-max --max-args 1 h/help --
argparse --name min-max --max-args 1 h/help -- arg1
argparse --name min-max --max-args 1 h/help -- arg1 arg2
#CHECKERR: min-max: Expected at most 1 args, got 2
#CHECKERR: min-max: expected <= 1 arguments; got 2
end
# Invalid \"#-val\" spec
@ -91,7 +91,7 @@ end
# Invalid arg in the face of a \"#-val\" spec
begin
argparse '#-val' -- abc -x def
# CHECKERR: argparse: Unknown option '-x'
# CHECKERR: argparse: -x: unknown option
end
# Defining a short flag more than once
@ -305,7 +305,7 @@ function notargparse
argparse a/alpha -- --banana
end
notargparse
# CHECKERR: notargparse: Unknown option '--banana'
# CHECKERR: notargparse: --banana: unknown option
true
@ -400,10 +400,10 @@ end
# #6483 - error messages for missing arguments
argparse -n foo q r/required= -- foo -qr
# CHECKERR: foo: Expected argument for option r
# CHECKERR: foo: -r: option requires an argument
argparse r/required= -- foo --required
# CHECKERR: argparse: Expected argument for option --required
# CHECKERR: argparse: --required: option requires an argument
### The fish_opt wrapper:
# No args is an error
@ -422,17 +422,18 @@ and echo unexpected status $status
# 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
#CHECKERR: fish_opt: o/optional-val r/required-val: options cannot be used together
# XXX FIXME the error should output -r and --optional-val: what the user used
# 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
#CHECKERR: fish_opt: multiple-vals o/optional-val: options cannot be used together
# 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
#CHECKERR: fish_opt: expected <= 0 arguments; got 1
# Now verify that valid combinations of options produces the correct output.

View file

@ -537,6 +537,7 @@ echo (echo hello\\)
for PWD in foo bar
true
end
# CHECKERR: {{.*}}/basic.fish (line {{\d+}}): You cannot use read-only variable 'PWD' in a for loop
# CHECKERR: {{.*}}/basic.fish (line {{\d+}}): for: PWD: cannot overwrite read-only variable
# CHECKERR: for PWD in foo bar
# CHECKERR: ^
# XXX FIXME carat should point at PWD

View file

@ -5,10 +5,11 @@
# Verify that an invalid bind mode is rejected. >&2
bind -m 'bad bind mode' \cX true
# CHECKERR: bind: mode name 'bad bind mode' is not valid. See `help identifiers`.
# CHECKERR: bind: bad bind mode: invalid mode. See `help identifiers`
# Verify that an invalid bind mode target is rejected. >&2
bind -M bind-mode \cX true
# CHECKERR: bind: mode name 'bind-mode' is not valid. See `help identifiers`.
# CHECKERR: bind: bind-mode: invalid mode. See `help identifiers`
# CHECKERR: bind: No binding found for sequence '\t'
# This should succeed and result in a success, zero, status.

View file

@ -6,8 +6,7 @@ builtin -q; and echo None exists
builtin -q string echo banana; and echo Some of these exist
#CHECK: Some of these exist
builtin -nq string
#CHECKERR: builtin: Invalid combination of options,
#CHECKERR: --query and --names are mutually exclusive
#CHECKERR: builtin: invalid option combination, --query and --names are mutually exclusive
echo $status
#CHECK: 2
exit 0

View file

@ -371,7 +371,7 @@ complete banana
# "-a" ain't
complete banana bar
#CHECKERR: complete: Too many arguments
#CHECKERR: complete: too many arguments
#CHECKERR:
#CHECKERR: {{.*}}checks/complete.fish (line {{\d+}}):
#CHECKERR: complete banana bar

View file

@ -60,7 +60,7 @@ function name1 -a arg1 arg2
end
function -a arg1 arg2 name2
end
#CHECKERR: {{.*}}checks/function.fish (line {{\d+}}): function: Illegal function name '-a'
#CHECKERR: {{.*}}checks/function.fish (line {{\d+}}): function: -a: invalid function name
#CHECKERR: function -a arg1 arg2 name2
#CHECKERR: ^
function name3 --argument-names arg1 arg2
@ -69,12 +69,12 @@ function name3 --argument-names arg1 arg2
end
function --argument-names arg1 arg2 name4
end
#CHECKERR: {{.*}}checks/function.fish (line {{\d+}}): function: Illegal function name '--argument-names'
#CHECKERR: {{.*}}checks/function.fish (line {{\d+}}): function: --argument-names: invalid function name
#CHECKERR: function --argument-names arg1 arg2 name4
#CHECKERR: ^
function name5 abc --argument-names def
end
#CHECKERR: {{.*}}checks/function.fish (line {{\d+}}): function: Unexpected positional argument 'abc'
#CHECKERR: {{.*}}checks/function.fish (line {{\d+}}): function: abc: unexpected positional argument
#CHECKERR: function name5 abc --argument-names def
#CHECKERR: ^
functions -q name1; and echo "Function name1 found"
@ -108,7 +108,7 @@ test "$name3[3..-1]" = "$name3a[3..-1]"; and echo "3 = 3a"
function test
echo banana
end
#CHECKERR: {{.*}}checks/function.fish (line {{\d+}}): function: The name 'test' is reserved, and cannot be used as a function name
#CHECKERR: {{.*}}checks/function.fish (line {{\d+}}): function: test: cannot use reserved keyword as function name
#CHECKERR: function test
#CHECKERR: ^

View file

@ -6,10 +6,8 @@ end
# ==========
# Verify that `functions --details` works as expected when given too many args.
set x (functions --details f1 f2 2>&1)
if test "$x" != "functions --details: Expected 1 args, got 2"
echo "Unexpected output for 'functions --details f1 f2': $x" >&2
end
functions --details f1 f2
#CHECKERR: functions: --details: expected 1 arguments; got 2
# ==========
# Verify that `functions --details` works as expected when given the name of a
@ -20,10 +18,8 @@ functions --details f1
# ==========
# Verify that `functions --details` works as expected when given the name of an
# unknown function.
set x (functions -D f2)
if test "$x" != n/a
echo "Unexpected output for 'functions --details f2': $x" >&2
end
functions -D f2
#CHECK: n/a
# ==========
# Verify that `functions --details` works as expected when given the name of a
@ -111,9 +107,10 @@ functions --no-details t
# CHECK: end
functions --no-details --details t
# CHECKERR: functions: Invalid combination of options
# CHECKERR: functions: invalid option combination
# CHECKERR:
# CHECKERR: checks/functions.fish (line {{\d+}}):
# CHECKERR: functions --no-details --details t
# CHECKERR: ^
# CHECKERR: (Type 'help functions' for related documentation)
# XXX FIXME ^ caret should point at --no-details --details

View file

@ -6,63 +6,62 @@
# First with the history function.
history --search --merge
#CHECKERR: history: Mutually exclusive flags 'merge' and `search` seen
#CHECKERR: history: merge search: options cannot be used together
history --clear --contains
#CHECKERR: history: you cannot use any options with the clear command
#CHECKERR: history: clear: subcommand takes no options
history --merge -t
#CHECKERR: history: you cannot use any options with the merge command
#CHECKERR: history: merge: subcommand takes no options
history --save xyz
#CHECKERR: history: save expected 0 args, got 1
#CHECKERR: history: save: expected 0 arguments; got 1
# Now with the history builtin.
builtin history --save --prefix
#CHECKERR: history: you cannot use any options with the save command
#CHECKERR: history: save: subcommand takes no options
builtin history --clear --show-time
#CHECKERR: history: you cannot use any options with the clear command
#CHECKERR: history: clear: subcommand takes no options
builtin history --merge xyz
#CHECKERR: history merge: Expected 0 args, got 1
#CHECKERR: history: merge: expected 0 arguments; got 1
builtin history --clear abc def
#CHECKERR: history clear: Expected 0 args, got 2
#CHECKERR: history: clear: expected 0 arguments; got 2
# Now using the preferred subcommand form. Note that we support flags before
# or after the subcommand name so test both variants.
# First with the history function.
history clear --contains
#CHECKERR: history: you cannot use any options with the clear command
#CHECKERR: history: clear: subcommand takes no options
history clear-session --contains
#CHECKERR: history: you cannot use any options with the clear-session command
#CHECKERR: history: clear-session: subcommand takes no options
history merge -t
#CHECKERR: history: you cannot use any options with the merge command
#CHECKERR: history: merge: subcommand takes no options
history save xyz
#CHECKERR: history: save expected 0 args, got 1
#CHECKERR: history: save: expected 0 arguments; got 1
history --prefix clear
#CHECKERR: history: you cannot use any options with the clear command
#CHECKERR: history: clear: subcommand takes no options
history --prefix clear-session
#CHECKERR: history: you cannot use any options with the clear-session command
#CHECKERR: history: clear-session: subcommand takes no options
history --show-time merge
#CHECKERR: history: you cannot use any options with the merge command
#CHECKERR: history: merge: subcommand takes no options
# Now with the history builtin.
builtin history --search --merge
#CHECKERR: history: Invalid combination of options,
#CHECKERR: you cannot do both 'search' and 'merge' in the same invocation
#CHECKERR: history: search merge: options cannot be used together
builtin history save --prefix
#CHECKERR: history: you cannot use any options with the save command
#CHECKERR: history: save: subcommand takes no options
builtin history clear --show-time
#CHECKERR: history: you cannot use any options with the clear command
#CHECKERR: history: clear: subcommand takes no options
builtin history clear-session --show-time
#CHECKERR: history: you cannot use any options with the clear-session command
#CHECKERR: history: clear-session: subcommand takes no options
builtin history merge xyz
#CHECKERR: history merge: Expected 0 args, got 1
#CHECKERR: history: merge: expected 0 arguments; got 1
builtin history clear abc def
#CHECKERR: history clear: Expected 0 args, got 2
#CHECKERR: history: clear: expected 0 arguments; got 2
builtin history clear-session abc def
#CHECKERR: history clear-session: Expected 0 args, got 2
#CHECKERR: history: clear-session: expected 0 arguments; got 2
builtin history --contains save
#CHECKERR: history: you cannot use any options with the save command
#CHECKERR: history: save: subcommand takes no options
builtin history -t merge
#CHECKERR: history: you cannot use any options with the merge command
#CHECKERR: history: merge: subcommand takes no options
# Now do a history command that should succeed so we exit with a zero,
# success, status.

View file

@ -14,7 +14,7 @@ emit linenumber
# CHECK: 8
type --nonexistent-option-so-we-get-a-backtrace
# CHECKERR: type: Unknown option '--nonexistent-option-so-we-get-a-backtrace'
# CHECKERR: type: --nonexistent-option-so-we-get-a-backtrace: unknown option
function line-number
status line-number

View file

@ -107,17 +107,19 @@ echo "while true; end" | $fish --no-execute
for status in a b c
echo $status
end
#CHECKERR: {{.*}}loops.fish (line {{\d+}}): You cannot use read-only variable 'status' in a for loop
#CHECKERR: {{.*}}loops.fish (line {{\d+}}): for: status: cannot overwrite read-only variable
#CHECKERR: for status in a b c
#CHECKERR: ^
# XXX FIXME this should point at `status`
# "That goes for non-electric ones as well (#5548)"
for hostname in a b c
echo $hostname
end
#CHECKERR: {{.*}}loops.fish (line {{\d+}}): You cannot use read-only variable 'hostname' in a for loop
#CHECKERR: {{.*}}loops.fish (line {{\d+}}): for: hostname: cannot overwrite read-only variable
#CHECKERR: for hostname in a b c
#CHECKERR: ^
# XXX FIXME this should point at `for`
# For loop control vars available outside the for block
begin

View file

@ -130,9 +130,10 @@ not math '2 + 2 4'
# CHECKERR: '2 + 2 4'
# CHECKERR: ^
not math
# CHECKERR: math: Expected at least 1 args, got 0
# CHECKERR: math: expected >= 1 arguments; got 0
not math -s 12
# CHECKERR: math: Expected at least 1 args, got 0
# CHECKERR: math: expected >= 1 arguments; got 0
# XXX FIXME these two should be just "missing argument" errors, the count is not helpful
not math 2^999999
# CHECKERR: math: Error: Result is infinite
# CHECKERR: '2^999999'
@ -190,7 +191,7 @@ math --base hex 12 + 0x50
math --base octal --scale=0 55
# CHECK: 067
math --base notabase
# CHECKERR: math: 'notabase' is not a valid base value
# CHECKERR: math: notabase: invalid base value
echo $status
# CHECK: 2

View file

@ -7,27 +7,27 @@ set -l diff_max 18446744073709551614
# check failure cases
random a
#CHECKERR: random: Argument 'a' is not a valid integer
#CHECKERR: random: a: invalid integer
random $diff_max
#CHECKERR: random: Argument '18446744073709551614' is not a valid integer
#CHECKERR: random: 18446744073709551614: invalid integer
random -- 1 2 3 4
#CHECKERR: random: Too many arguments
#CHECKERR: random: too many arguments
random -- 10 -10
#CHECKERR: random: END must be greater than START
random -- 10 $diff_max
#CHECKERR: random: Argument '18446744073709551614' is not a valid integer
#CHECKERR: random: 18446744073709551614: invalid integer
random -- 1 1d
random -- 1 1c 10
#CHECKERR: random: Argument '1d' is not a valid integer
#CHECKERR: random: Argument '1c' is not a valid integer
#CHECKERR: random: 1d: invalid integer
#CHECKERR: random: 1c: invalid integer
random -- 10 10
#CHECKERR: random: END must be greater than START
random -- 1 - 10
#CHECKERR: random: Argument '-' is not a valid integer
#CHECKERR: random: -: invalid integer
random -- 1 -1 10
#CHECKERR: random: Argument '-1' is not a valid integer
#CHECKERR: random: -1: invalid integer
random -- 1 $min 10
#CHECKERR: random: Argument '-9223372036854775807' is not a valid integer
#CHECKERR: random: -9223372036854775807: invalid integer
random -- 1 0 10
#CHECKERR: random: STEP must be a positive integer
random -- 1 11 10
@ -37,7 +37,7 @@ random -- 0 $diff_max $max
random choice
#CHECKERR: random: nothing to choose from
random choic a b c
#CHECKERR: random: Too many arguments
#CHECKERR: random: too many arguments
function check_boundaries
if not test $argv[1] -ge $argv[2] -a $argv[1] -le $argv[3]

View file

@ -6,9 +6,9 @@ read
# Read with -a and anything other than exactly on var name is an error
read -a
#CHECKERR: read: Expected 1 args, got 0
#CHECKERR: read: expected 1 arguments; got 0
read --array v1 v2
#CHECKERR: read: Expected 1 args, got 2
#CHECKERR: read: expected 1 arguments; got 2
read --list v1
# Verify correct behavior of subcommands and splitting of input.

View file

@ -241,8 +241,9 @@ echo 7 $status # no passthrough
#CHECK: 7 4
false
set -h >/dev/null
# CHECKERR: fish: Missing man page {{.*}}
# CHECKERR: `help '{{.*}}'` will open the online version.
# CHECKERR: fish: set: missing man page
# CHECKERR: Documentation may not be installed.
# CHECKERR: `help set` will show an online version
echo 8 $status # no passthrough
#CHECK: 8 0

View file

@ -451,12 +451,10 @@ env | grep __fish_empty_uvar
for a,b in y 1 z 3
echo $a,$b
end
# CHECKERR: {{.*}} for: Variable name 'a,b' is not valid. See `help identifiers`.
# CHECKERR:
# CHECKERR: {{.*}} for: a,b: invalid variable. See `help identifiers`
# CHECKERR: for a,b in y 1 z 3
# CHECKERR: ^
# Global vs Universal Unspecified Scopes
set -U __fish_test_global_vs_universal universal
echo "global-vs-universal 1: $__fish_test_global_vs_universal"
@ -512,7 +510,7 @@ sh -c "EDITOR='vim -g' $FISH -c "'\'set -S EDITOR\'' | string match -r -e 'globa
# Verify behavior of `set --show` given an invalid var name
set --show 'argle bargle'
#CHECKERR: set: Variable name 'argle bargle' is not valid. See `help identifiers`.
#CHECKERR: set: argle bargle: invalid variable. See `help identifiers`
#CHECKERR: {{.*}}set.fish (line {{\d+}}):
#CHECKERR: set --show 'argle bargle'
#CHECKERR: ^
@ -711,14 +709,14 @@ echo $status
true
set "" foo
#CHECKERR: set: Variable name '' is not valid. See `help identifiers`.
#CHECKERR: set: : invalid variable. See `help identifiers`
#CHECKERR: {{.*}}set.fish (line {{\d+}}):
#CHECKERR: set "" foo
#CHECKERR: ^
#CHECKERR: (Type 'help set' for related documentation)
set --show ""
#CHECKERR: set: Variable name '' is not valid. See `help identifiers`.
#CHECKERR: set: : invalid variable. See `help identifiers`
#CHECKERR: {{.*}}set.fish (line {{\d+}}):
#CHECKERR: set --show ""
#CHECKERR: ^

View file

@ -21,14 +21,13 @@ and echo '"status is-interactive" unexpectedly returned true for a non-interacti
# We should get an error message about an invalid combination of flags.
status --is-interactive --is-login
#CHECKERR: status: Invalid combination of options,
#CHECKERR: you cannot do both 'is-interactive' and 'is-login' in the same invocation
#CHECKERR: status: is-interactive is-login: options cannot be used together
# We should get an error message about an unexpected arg for `status
# is-block`.
status -b is-interactive
#CHECKERR: status: Invalid combination of options,
#CHECKERR: you cannot do both 'is-block' and 'is-interactive' in the same invocation
#CHECKERR: status: is-block is-interactive: options cannot be used together
# XXX this would be better if it referred to -b rather than what it is
# Try to set the job control to an invalid mode.
status job-control full1

View file

@ -481,16 +481,16 @@ string repeat -m-1 foo; and echo "exit 0"
# CHECKERR: string repeat: Invalid max value '-1'
string repeat -n notanumber foo; and echo "exit 0"
# CHECKERR: string repeat: Argument 'notanumber' is not a valid integer
# CHECKERR: string repeat: notanumber: invalid integer
string repeat -m notanumber foo; and echo "exit 0"
# CHECKERR: string repeat: Argument 'notanumber' is not a valid integer
# CHECKERR: string repeat: notanumber: invalid integer
echo stdin | string repeat -n1 "and arg"; and echo "exit 0"
# CHECKERR: string repeat: Too many arguments
# CHECKERR: string repeat: too many arguments
string repeat -n; and echo "exit 0"
# CHECKERR: string repeat: Expected argument for option n
# CHECKERR: string repeat: -n: option requires an argument
# FIXME: Also triggers usage
# string repeat -l fakearg
@ -761,7 +761,7 @@ echo $status
function string
builtin string $argv
end
# CHECKERR: checks/string.fish (line {{\d+}}): function: The name 'string' is reserved, and cannot be used as a function name
# CHECKERR: checks/string.fish (line {{\d+}}): function: string: cannot use reserved keyword as function name
# CHECKERR: function string
# CHECKERR: ^