diff --git a/tests/checks/abbr.fish b/tests/checks/abbr.fish index 3275022b4..7829e031a 100644 --- a/tests/checks/abbr.fish +++ b/tests/checks/abbr.fish @@ -141,7 +141,7 @@ echo $status abbr --query banana --function echo $status # CHECKERR: abbr: --function: option requires an argument -# CHECKERR: checks/abbr.fish (line 141): +# CHECKERR: {{.*}}checks/abbr.fish (line 141): # CHECKERR: abbr --query banana --function # CHECKERR: ^ # CHECKERR: (Type 'help abbr' for related documentation) diff --git a/tests/checks/argparse.fish b/tests/checks/argparse.fish index 7b5745792..218619957 100644 --- a/tests/checks/argparse.fish +++ b/tests/checks/argparse.fish @@ -11,7 +11,7 @@ # No args (not even --) is an error argparse #CHECKERR: argparse: Missing -- separator -#CHECKERR: checks/argparse.fish (line {{\d+}}): +#CHECKERR: {{.*}}checks/argparse.fish (line {{\d+}}): #CHECKERR: argparse #CHECKERR: ^ #CHECKERR: (Type 'help argparse' for related documentation) @@ -19,7 +19,7 @@ argparse # Missing -- is an error argparse h/help #CHECKERR: argparse: Missing -- separator -#CHECKERR: checks/argparse.fish (line {{\d+}}): +#CHECKERR: {{.*}}checks/argparse.fish (line {{\d+}}): #CHECKERR: argparse h/help #CHECKERR: ^ #CHECKERR: (Type 'help argparse' for related documentation) @@ -40,27 +40,27 @@ argparse h/help: argparse h-help:: argparse h-help=x #CHECKERR: argparse: Invalid option spec 'h-' at char '-' -#CHECKERR: checks/argparse.fish (line {{\d+}}): +#CHECKERR: {{.*}}checks/argparse.fish (line {{\d+}}): #CHECKERR: argparse h- #CHECKERR: ^ #CHECKERR: (Type 'help argparse' for related documentation) #CHECKERR: argparse: Short flag '+' invalid, must be alphanum or '#' -#CHECKERR: checks/argparse.fish (line {{\d+}}): +#CHECKERR: {{.*}}checks/argparse.fish (line {{\d+}}): #CHECKERR: argparse +help #CHECKERR: ^ #CHECKERR: (Type 'help argparse' for related documentation) #CHECKERR: argparse: Invalid option spec 'h/help:' at char ':' -#CHECKERR: checks/argparse.fish (line {{\d+}}): +#CHECKERR: {{.*}}checks/argparse.fish (line {{\d+}}): #CHECKERR: argparse h/help: #CHECKERR: ^ #CHECKERR: (Type 'help argparse' for related documentation) #CHECKERR: argparse: Invalid option spec 'h-help::' at char ':' -#CHECKERR: checks/argparse.fish (line {{\d+}}): +#CHECKERR: {{.*}}checks/argparse.fish (line {{\d+}}): #CHECKERR: argparse h-help:: #CHECKERR: ^ #CHECKERR: (Type 'help argparse' for related documentation) #CHECKERR: argparse: Invalid option spec 'h-help=x' at char 'x' -#CHECKERR: checks/argparse.fish (line {{\d+}}): +#CHECKERR: {{.*}}checks/argparse.fish (line {{\d+}}): #CHECKERR: argparse h-help=x #CHECKERR: ^ #CHECKERR: (Type 'help argparse' for related documentation) @@ -89,7 +89,7 @@ end begin argparse '#-val=' -- abc -x def # CHECKERR: argparse: Implicit int short flag '#' does not allow modifiers like '=' - #CHECKERR: checks/argparse.fish (line {{\d+}}): + #CHECKERR: {{.*}}checks/argparse.fish (line {{\d+}}): #CHECKERR: argparse '#-val=' -- abc -x def #CHECKERR: ^ #CHECKERR: (Type 'help argparse' for related documentation) @@ -105,7 +105,7 @@ end begin argparse s/short x/xray s/long -- -s -x --long # CHECKERR: argparse: Short flag 's' already defined - #CHECKERR: checks/argparse.fish (line {{\d+}}): + #CHECKERR: {{.*}}checks/argparse.fish (line {{\d+}}): #CHECKERR: argparse s/short x/xray s/long -- -s -x --long #CHECKERR: ^ #CHECKERR: (Type 'help argparse' for related documentation) @@ -115,7 +115,7 @@ end begin argparse s/short x/xray l/short -- -s -x --long # CHECKERR: argparse: Long flag 'short' already defined - #CHECKERR: checks/argparse.fish (line {{\d+}}): + #CHECKERR: {{.*}}checks/argparse.fish (line {{\d+}}): #CHECKERR: argparse s/short x/xray l/short -- -s -x --long #CHECKERR: ^ #CHECKERR: (Type 'help argparse' for related documentation) @@ -125,7 +125,7 @@ end begin argparse '#-val' x/xray 'v#val' -- -s -x --long # CHECKERR: argparse: Implicit int flag '#' already defined - #CHECKERR: checks/argparse.fish (line {{\d+}}): + #CHECKERR: {{.*}}checks/argparse.fish (line {{\d+}}): #CHECKERR: argparse '#-val' x/xray 'v#val' -- -s -x --long #CHECKERR: ^ #CHECKERR: (Type 'help argparse' for related documentation) @@ -135,7 +135,7 @@ end begin argparse 'v#val=' -- # CHECKERR: argparse: Implicit int short flag 'v' does not allow modifiers like '=' - #CHECKERR: checks/argparse.fish (line {{\d+}}): + #CHECKERR: {{.*}}checks/argparse.fish (line {{\d+}}): #CHECKERR: argparse 'v#val=' -- #CHECKERR: ^ #CHECKERR: (Type 'help argparse' for related documentation) @@ -500,7 +500,7 @@ end begin argparse '' #CHECKERR: argparse: An option spec must have at least a short or a long flag - #CHECKERR: checks/argparse.fish (line {{\d+}}): + #CHECKERR: {{.*}}checks/argparse.fish (line {{\d+}}): #CHECKERR: argparse '' #CHECKERR: ^ #CHECKERR: (Type 'help argparse' for related documentation) diff --git a/tests/checks/broken-config.fish b/tests/checks/broken-config.fish index 28c471d56..7899a8169 100644 --- a/tests/checks/broken-config.fish +++ b/tests/checks/broken-config.fish @@ -1,6 +1,6 @@ #RUN: %fish -C 'set -g fish %fish' %s begin - set -l dir $PWD/(dirname (status -f)) + set -l dir (dirname (status -f)) set -gx XDG_CONFIG_HOME $dir/broken-config/ set -gx HOME $dir/broken-config/ $fish -l -c 'echo but still going' diff --git a/tests/checks/command-not-found.fish b/tests/checks/command-not-found.fish index cf6ce48cb..a4c26e70a 100644 --- a/tests/checks/command-not-found.fish +++ b/tests/checks/command-not-found.fish @@ -35,7 +35,7 @@ echo $status set -g PATH . echo banana > foobar foobar --banana -# CHECKERR: checks/command-not-found.fish (line {{\d+}}): Unknown command. './foobar' exists but is not an executable file. +# CHECKERR: {{.*}}checks/command-not-found.fish (line {{\d+}}): Unknown command. './foobar' exists but is not an executable file. # CHECKERR: foobar --banana # CHECKERR: ^~~~~^ diff --git a/tests/checks/complete.fish b/tests/checks/complete.fish index 1db09fd59..e4017be66 100644 --- a/tests/checks/complete.fish +++ b/tests/checks/complete.fish @@ -40,6 +40,8 @@ complete -c t -fa '(t)' complete -C't ' # CHECK: t +touch test.fish + # Ensure file completion happens even though it was disabled above. complete -c t -l fileoption -rF # Only match one file because I don't want to touch this any time we add a test file. diff --git a/tests/checks/eval.fish b/tests/checks/eval.fish index 9552f5a4e..fefde6e88 100644 --- a/tests/checks/eval.fish +++ b/tests/checks/eval.fish @@ -65,7 +65,7 @@ source /banana/\t/foo function eval builtin eval $argv end -# CHECKERR: checks/eval.fish (line {{\d+}}): function: eval: cannot use reserved keyword as function name +# CHECKERR: {{.*}}checks/eval.fish (line {{\d+}}): function: eval: cannot use reserved keyword as function name # CHECKERR: function eval # CHECKERR: ^ diff --git a/tests/checks/expansion.fish b/tests/checks/expansion.fish index 97546c53b..cea0e18a2 100644 --- a/tests/checks/expansion.fish +++ b/tests/checks/expansion.fish @@ -337,7 +337,7 @@ printf '<%s>\n' ($fish -c 'echo "$abc["' 2>&1) set -l pager command less echo foo | $pager -#CHECKERR: checks/expansion.fish (line 339): The expanded command is a keyword. +#CHECKERR: {{.*}}checks/expansion.fish (line 339): The expanded command is a keyword. #CHECKERR: echo foo | $pager #CHECKERR: ^~~~~^ diff --git a/tests/checks/functions.fish b/tests/checks/functions.fish index 23c7969e0..f5a17991e 100644 --- a/tests/checks/functions.fish +++ b/tests/checks/functions.fish @@ -170,7 +170,7 @@ functions --no-details t2 functions --no-details --details t # CHECKERR: functions: invalid option combination # CHECKERR: -# CHECKERR: checks/functions.fish (line {{\d+}}): +# CHECKERR: {{.*}}checks/functions.fish (line {{\d+}}): # CHECKERR: functions --no-details --details t # CHECKERR: ^ # CHECKERR: (Type 'help functions' for related documentation) @@ -205,7 +205,7 @@ functions --names -a | string match __fish_config_interactive functions --description "" # CHECKERR: functions: Expected exactly one function name -# CHECKERR: checks/functions.fish (line {{\d+}}): +# CHECKERR: {{.*}}checks/functions.fish (line {{\d+}}): # CHECKERR: functions --description "" # CHECKERR: ^ # CHECKERR: (Type 'help functions' for related documentation) diff --git a/tests/checks/set.fish b/tests/checks/set.fish index 9d3e9c561..cce47666e 100644 --- a/tests/checks/set.fish +++ b/tests/checks/set.fish @@ -953,7 +953,7 @@ end set -e undefined[x..] # CHECKERR: set: Invalid index starting at 'undefined' -# CHECKERR: checks/set.fish (line 954): +# CHECKERR: {{.*}}checks/set.fish (line {{\d+}}): # CHECKERR: set -e undefined[x..] # CHECKERR: ^ # CHECKERR: (Type 'help set' for related documentation) diff --git a/tests/checks/string.fish b/tests/checks/string.fish index c3494e582..a7c2c1eb9 100644 --- a/tests/checks/string.fish +++ b/tests/checks/string.fish @@ -889,7 +889,7 @@ echo $status function string builtin string $argv end -# CHECKERR: checks/string.fish (line {{\d+}}): function: string: cannot use reserved keyword as function name +# CHECKERR: {{.*}}checks/string.fish (line {{\d+}}): function: string: cannot use reserved keyword as function name # CHECKERR: function string # CHECKERR: ^ diff --git a/tests/checks/switch.fish b/tests/checks/switch.fish index b5393c30e..6623b4c75 100644 --- a/tests/checks/switch.fish +++ b/tests/checks/switch.fish @@ -108,12 +108,12 @@ begin echo Matched! end # CHECKERR: fish: Unknown command: doesnotexist - # CHECKERR: checks/switch.fish (line {{\d+}}): + # CHECKERR: {{.*}}checks/switch.fish (line {{\d+}}): # CHECKERR: doesnotexist # CHECKERR: ^~~~~~~~~~~^ # CHECKERR: in command substitution - # CHECKERR: {{\t}}called on line {{\d+}} of file checks/switch.fish - # CHECKERR: checks/switch.fish (line {{\d+}}): Unknown command + # CHECKERR: {{\t}}called on line {{\d+}} of file {{.*}}checks/switch.fish + # CHECKERR: {{.*}}checks/switch.fish (line {{\d+}}): Unknown command # CHECKERR: switch (doesnotexist) # CHECKERR: ^~~~~~~~~~~~~^ end diff --git a/tests/checks/symlinks-not-overwritten.fish b/tests/checks/symlinks-not-overwritten.fish index b5c6c5a27..125be076e 100644 --- a/tests/checks/symlinks-not-overwritten.fish +++ b/tests/checks/symlinks-not-overwritten.fish @@ -21,6 +21,7 @@ else echo fish_variables is still a symlink end # CHECK: fish_variables is still a symlink +rm $fish_variables # fish_history @@ -45,3 +46,4 @@ else echo fish_history is still a symlink end # CHECK: fish_history is still a symlink +rm $history_file diff --git a/tests/checks/ulimit.fish b/tests/checks/ulimit.fish index 4f5ae7ab5..3fa3bef7e 100644 --- a/tests/checks/ulimit.fish +++ b/tests/checks/ulimit.fish @@ -9,7 +9,7 @@ ulimit --core-size ulimit 4352353252352352334 #CHECKERR: ulimit: Invalid limit '4352353252352352334' #CHECKERR: -#CHECKERR: checks/ulimit.fish (line {{\d+}}): +#CHECKERR: {{.*}}checks/ulimit.fish (line {{\d+}}): #CHECKERR: ulimit 4352353252352352334 #CHECKERR: ^ #CHECKERR: (Type 'help ulimit' for related documentation) diff --git a/tests/checks/wildcard.fish b/tests/checks/wildcard.fish index ee9e4d667..9b6494f98 100644 --- a/tests/checks/wildcard.fish +++ b/tests/checks/wildcard.fish @@ -12,7 +12,7 @@ touch ./b/file.txt set dirs ./a ./b echo $dirs/*.txt # CHECK: ./b/file.txt echo */foo/ -# CHECKERR: checks/wildcard.fish (line {{\d+}}): No matches for wildcard '*/foo/'. See `help wildcards-globbing`. +# CHECKERR: {{.*}}checks/wildcard.fish (line {{\d+}}): No matches for wildcard '*/foo/'. See `help wildcards-globbing`. # CHECKERR: echo */foo/ # CHECKERR: ^~~~~^ diff --git a/tests/interactive.fish b/tests/interactive.fish index 0a6dca8b1..18121f64c 100755 --- a/tests/interactive.fish +++ b/tests/interactive.fish @@ -6,21 +6,23 @@ # `fish_update_completions` when running tests. set -gx FISH_UNIT_TESTS_RUNNING 1 -# Change to directory containing this script -cd (status dirname) +# Save the directory containing this script +# Do not *cd* here, otherwise you'll ruin our nice tmpdir setup!!! +set -l scriptdir (status dirname) # Test files specified on commandline, or all pexpect files. if set -q argv[1] && test -n "$argv[1]" - set pexpect_files_to_test pexpects/$argv + set pexpect_files_to_test $scriptdir/pexpects/$argv else if set -q FISH_PEXPECT_FILES set pexpect_files_to_test (string replace -r '^.*/(?=pexpects/)' '' -- $FISH_PEXPECT_FILES) else say -o cyan "Testing interactive functionality" - set pexpect_files_to_test pexpects/*.py + set pexpect_files_to_test $scriptdir/pexpects/*.py end -source test_util.fish || exit -cat interactive.config >>$XDG_CONFIG_HOME/fish/config.fish +source $scriptdir/test_util.fish || exit +cat $scriptdir/interactive.config >>$XDG_CONFIG_HOME/fish/config.fish +set -lx --prepend PYTHONPATH (realpath $scriptdir) function test_pexpect_file set -l file $argv[1] @@ -33,7 +35,6 @@ function test_pexpect_file # Help the script find the pexpect_helper module in our parent directory. set -q FISHDIR or set -l FISHDIR ../test/root/bin/ - set -lx --prepend PYTHONPATH (realpath $PWD) set -lx fish $FISHDIR/fish set -lx fish_key_reader $FISHDIR/fish_key_reader path is -fx -- $FISHDIR/fish_test_helper diff --git a/tests/test.fish b/tests/test.fish index 0f4f7f798..c73b1edc1 100644 --- a/tests/test.fish +++ b/tests/test.fish @@ -8,15 +8,16 @@ # `fish_update_completions` when running tests. set -x FISH_UNIT_TESTS_RUNNING 1 -# Change to directory containing this script -cd (status dirname) +# Save the directory containing this script +# Do not *cd* here, otherwise you'll ruin our nice tmpdir setup!!! +set -l scriptdir (status dirname) # Test files specified on commandline, or all checks. set -l files_to_test if set -q argv[1] - set files_to_test checks/$argv.fish + set files_to_test $scriptdir/checks/$argv.fish else - set files_to_test checks/*.fish + set files_to_test $scriptdir/checks/*.fish end # Be less verbose when running tests one-by-one @@ -41,11 +42,11 @@ if set -q files_to_test[1] test "$FISH_FORCE_COLOR" = 1 and set force_color --force-color - $python -S littlecheck.py \ + $python -S $scriptdir/littlecheck.py \ --progress $force_color \ -s fish=$FISHDIR/fish \ -s fish_test_helper=$fish_test_helper \ - -s filter-control-sequences="$FISHDIR/fish ../tests/filter-control-sequences.fish" \ + -s filter-control-sequences="$FISHDIR/fish $scriptdir/filter-control-sequences.fish" \ $files_to_test set -l littlecheck_status $status