mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-14 17:07:44 +00:00
Remove classic ".in" test machinery
We have now entirely switched the script tests to littlecheck. Note: This adjusts the complete_directories test, because it removes a directory that was created before by a .in test. There's no real change in behavior. This does require the test directory be cleaned, or the tests will fail. test_util gets to stay for a while longer, because it sets up the testing env (locale and such).
This commit is contained in:
parent
957526a283
commit
4d052da922
7 changed files with 1 additions and 183 deletions
|
@ -13,7 +13,6 @@ __fish_complete_directories test/z
|
|||
__fish_complete_directories test/d
|
||||
#CHECK: test/data/ Directory
|
||||
#CHECK: test/buildroot/ Directory
|
||||
#CHECK: test/fish_expand_test/ Directory
|
||||
__fish_complete_directories test/data
|
||||
#CHECK: test/data/ Directory
|
||||
__fish_complete_directories test/data/
|
||||
|
|
|
@ -15,7 +15,7 @@ cd (dirname (status -f))
|
|||
if set -q argv[1]
|
||||
set files_to_test $argv.in
|
||||
else
|
||||
set files_to_test *.in checks/*.fish
|
||||
set files_to_test checks/*.fish
|
||||
end
|
||||
|
||||
# These env vars should not be inherited from the user environment because they can affect the
|
||||
|
@ -29,56 +29,8 @@ or exit
|
|||
|
||||
say -o cyan "Testing high level script functionality"
|
||||
|
||||
function test_in_file
|
||||
set -l file $argv[1]
|
||||
set -l base (basename $file .in)
|
||||
|
||||
echo -n "Testing file $file ... "
|
||||
set starttime (timestamp)
|
||||
|
||||
../test/root/bin/fish <$file >$base.tmp.out 2>$base.tmp.err
|
||||
set -l exit_status $status
|
||||
set -l res ok
|
||||
set test_duration (delta $starttime)
|
||||
|
||||
diff $base.tmp.out $base.out >/dev/null
|
||||
set -l out_status $status
|
||||
diff $base.tmp.err $base.err >/dev/null
|
||||
set -l err_status $status
|
||||
|
||||
if test $out_status -eq 0 -a $err_status -eq 0 -a $exit_status -eq 0
|
||||
say green "ok ($test_duration $unit)"
|
||||
# clean up tmp files
|
||||
rm -f $base.tmp.{err,out}
|
||||
return 0
|
||||
else
|
||||
say red fail
|
||||
if test $out_status -ne 0
|
||||
say yellow "Output differs for file $file. Diff follows:"
|
||||
colordiff -u $base.out $base.tmp.out
|
||||
end
|
||||
if test $err_status -ne 0
|
||||
say yellow "Error output differs for file $file. Diff follows:"
|
||||
colordiff -u $base.err $base.tmp.err
|
||||
end
|
||||
if test $exit_status -ne 0
|
||||
say yellow "Exit status differs for file $file."
|
||||
echo "Unexpected test exit status $exit_status."
|
||||
end
|
||||
return 1
|
||||
end
|
||||
end
|
||||
|
||||
set -g python (__fish_anypython)
|
||||
|
||||
# Test classic '.in' files.
|
||||
set -l failed 0
|
||||
for i in (string match '*.in' -- $files_to_test)
|
||||
if not test_in_file $i
|
||||
set failed (math $failed + 1)
|
||||
end
|
||||
end
|
||||
|
||||
# Test littlecheck files.
|
||||
set littlecheck_files (string match '*.fish' -- $files_to_test)
|
||||
if set -q littlecheck_files[1]
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
# We don't want syntax errors to emit command usage help. This makes the
|
||||
# stderr output considerably shorter and makes it easier to updates the tests
|
||||
# and documentation without having to make pointless changes to the test
|
||||
# output files.
|
||||
function __fish_print_help
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
# This is needed because GNU and BSD implementations of `od` differ in the whitespace they emit.
|
||||
# In the past we used the `xxd` command which doesn't suffer from such idiosyncrasies but it isn't
|
||||
# available on some systems unless you install the Vim editor. Whereas `od` is pretty much
|
||||
# universally available. See issue #3797.
|
||||
#
|
||||
# We use the lowest common denominator format, `-b`, because it should work in all implementations.
|
||||
# I wish we could use the `-t` flag but it isn't available in every OS we're likely to run on.
|
||||
#
|
||||
function display_bytes
|
||||
od -b | sed -e 's/ */ /g' -e 's/ *$//'
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
function logmsg
|
||||
echo
|
||||
echo "####################"
|
||||
echo "# $argv"
|
||||
|
||||
echo >&2
|
||||
echo "####################" >&2
|
||||
echo "# $argv" >&2
|
||||
end
|
|
@ -1,102 +0,0 @@
|
|||
# GNU and BSD mktemp differ in their handling of arguments
|
||||
# Let's expose a simplified common interface
|
||||
function mktemp
|
||||
# usage: mktemp [-d] [-t] [template]
|
||||
#
|
||||
# If the -d flag is given, create a directory.
|
||||
#
|
||||
# If the -t flag is given, treat the template as a filename relative
|
||||
# to the temporary directory. The template may contain slashes but only
|
||||
# the final path component is created by mktemp. The template must not be
|
||||
# absolute
|
||||
#
|
||||
# If no template is given, assume tmp.XXXXXXXXXX and -t.
|
||||
set -l opts
|
||||
while set -q argv[1]
|
||||
switch $argv[1]
|
||||
case -d
|
||||
set opts $opts d
|
||||
case -t
|
||||
set opts $opts t
|
||||
case -u
|
||||
set opts $opts u
|
||||
case --
|
||||
set -e argv[1]
|
||||
break
|
||||
case '-*'
|
||||
echo "mktemp: unknown flag $argv[1]" >&2
|
||||
_mktemp_help >&2
|
||||
exit 2
|
||||
case '*'
|
||||
break
|
||||
end
|
||||
set -e argv[1]
|
||||
end
|
||||
|
||||
set -l template
|
||||
if set -q argv[1]
|
||||
set template $argv[1]
|
||||
else
|
||||
set template 'tmp.XXXXXXXXXX'
|
||||
set opts $opts t
|
||||
end
|
||||
|
||||
if set -q argv[2]
|
||||
echo 'mktemp: too many templates' >&2
|
||||
_mktemp_help >&2
|
||||
exit 1
|
||||
end
|
||||
|
||||
# GNU mktemp treats the final occurrence of a sequence of X's as the template token.
|
||||
# BSD mktemp only treats X's as the template token if they suffix the string.
|
||||
# So let's outlaw them anywhere besides the end.
|
||||
# Similarly GNU mktemp requires at least 3 X's, BSD mktemp requires none. Let's require 3.
|
||||
begin
|
||||
set -l chars (string split '' -- $template)
|
||||
set -l found_x
|
||||
for c in $chars
|
||||
if test $c = X
|
||||
set found_x $found_x X
|
||||
else if set -q found_x[1]
|
||||
echo 'mktemp: X\'s may only occur at the end of the template' >&2
|
||||
_mktemp_help >&2
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
if test (count $found_x) -lt 3
|
||||
echo "mktemp: too few X's in template '$template'" >&2
|
||||
_mktemp_usage >&2
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
|
||||
set -l args
|
||||
if contains u $opts
|
||||
set args $args -u
|
||||
end
|
||||
if contains d $opts
|
||||
set args $args -d
|
||||
end
|
||||
if contains t $opts
|
||||
switch $template
|
||||
case '/*'
|
||||
echo "mktemp: invalid template '$template' with -t, template must not be absolute" >&2
|
||||
_mktemp_help >&2
|
||||
exit 1
|
||||
end
|
||||
|
||||
if set -q TMPDIR[1]
|
||||
set template $TMPDIR/$template
|
||||
else
|
||||
set template /tmp/$template
|
||||
end
|
||||
end
|
||||
set args $args $template
|
||||
|
||||
realpath (command mktemp $args)
|
||||
end
|
||||
|
||||
function _mktemp_help
|
||||
echo 'usage: mktemp [-d] [-t] [template]'
|
||||
echo 'note: mktemp is a test function, see tests/test_functions/mktemp.fish'
|
||||
end
|
|
@ -1,5 +0,0 @@
|
|||
function r2l
|
||||
read line1
|
||||
read line2
|
||||
echo $line1 then $line2
|
||||
end
|
Loading…
Reference in a new issue