mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-26 10:43:47 +08:00
Cleanup fish tests a bit
Split `make test` into two targets `make test_low_level` and `make test_fishscript`, primarily so fishscript tests can be rechecked quickly after edits. Reformat the test.fish file and update some of the code to be a little more straightforward (e.g. `if not cmd` instead of `if cmd; else`).
This commit is contained in:
parent
8643a5e266
commit
efb1467e4e
19
Makefile.in
19
Makefile.in
|
@ -282,11 +282,26 @@ doc/refman.pdf: doc
|
|||
# This target runs both the low level code tests and the high level script tests.
|
||||
#
|
||||
|
||||
# normally we'd just depend on test_low_level and test_fishscript
|
||||
# But I'd rather not mix test output when doing parallel building with the -j flag
|
||||
# Instead we'll depend on the dependencies of those targets, for parallel building,
|
||||
# and use recursive make to actually invoke the tests themselves
|
||||
test: $(PROGRAMS) fish_tests
|
||||
./fish_tests
|
||||
cd tests; ../fish -c 'set -x fish_function_path "$$PWD"/../share/functions dummy; source' <test.fish;
|
||||
@$(MAKE) test_low_level
|
||||
@$(MAKE) test_fishscript
|
||||
.PHONY: test
|
||||
|
||||
test_low_level: fish_tests
|
||||
./fish_tests
|
||||
.PHONY: test_low_level
|
||||
|
||||
test_fishscript: $(PROGRAMS)
|
||||
@rm -rf tests/tmp.config
|
||||
@mkdir -p tests/tmp.config/fish
|
||||
@echo 'set fish_function_path "$$PWD/../share/functions"' > tests/tmp.config/fish/config.fish
|
||||
cd tests; XDG_CONFIG_HOME="$$PWD"/tmp.config ../fish test.fish
|
||||
.PHONY: test_fishscript
|
||||
|
||||
|
||||
#
|
||||
# commands.hdr collects documentation on all commands, functions and
|
||||
|
|
122
tests/test.fish
122
tests/test.fish
|
@ -6,82 +6,78 @@
|
|||
|
||||
|
||||
if [ "$argv" != '-n' ]
|
||||
# begin...end has bug in error redirecting...
|
||||
begin
|
||||
../fish -n ./test.fish ^top.tmp.err
|
||||
../fish -n ./test.fish -n ^^top.tmp.err
|
||||
../fish ./test.fish -n ^^top.tmp.err
|
||||
end | tee top.tmp.out
|
||||
echo $status >top.tmp.status
|
||||
set res ok
|
||||
if diff top.tmp.out top.out >/dev/null
|
||||
else
|
||||
set res fail
|
||||
echo Output differs for file test.fish
|
||||
end
|
||||
set -l res ok
|
||||
|
||||
if diff top.tmp.err top.err >/dev/null
|
||||
else
|
||||
set res fail
|
||||
echo Error output differs for file test.fish
|
||||
end
|
||||
# begin...end has bug in error redirecting...
|
||||
begin
|
||||
../fish -n ./test.fish ^top.tmp.err
|
||||
../fish -n ./test.fish -n ^^top.tmp.err
|
||||
../fish ./test.fish -n ^^top.tmp.err
|
||||
end | tee top.tmp.out
|
||||
set -l tmp_status $status
|
||||
if not diff top.tmp.out top.out >/dev/null
|
||||
set res fail
|
||||
echo "Output differs for file test.fish. Diff follows:"
|
||||
diff -u top.out top.tmp.out
|
||||
end
|
||||
|
||||
if test (cat top.tmp.status) = (cat top.status)
|
||||
else
|
||||
set res fail
|
||||
echo Exit status differs for file test.fish
|
||||
end
|
||||
if not diff top.tmp.err top.err >/dev/null
|
||||
set res fail
|
||||
echo "Error output differs for file test.fish. Diff follows:"
|
||||
diff -u top.err top.tmp.err
|
||||
end
|
||||
|
||||
../fish -p /dev/null -c 'echo testing' >/dev/null
|
||||
if test $status -ne 0
|
||||
set res fail
|
||||
echo Profiling fails
|
||||
end
|
||||
if test $tmp_status -ne (cat top.status)
|
||||
set res fail
|
||||
echo "Exit status differs for file test.fish"
|
||||
end
|
||||
|
||||
if test $res = ok;
|
||||
echo File test.fish tested ok
|
||||
if not ../fish -p /dev/null -c 'echo testing' >/dev/null
|
||||
set res fail
|
||||
echo "Profiling failed"
|
||||
end
|
||||
|
||||
if test $res = ok
|
||||
echo "File test.fish tested ok"
|
||||
exit 0
|
||||
else
|
||||
echo File test.fish failed tests
|
||||
else
|
||||
echo "File test.fish failed tests"
|
||||
exit 1
|
||||
end;
|
||||
end
|
||||
end
|
||||
|
||||
echo Testing high level script functionality
|
||||
echo "Testing high level script functionality"
|
||||
|
||||
for i in *.in
|
||||
set template_out (basename $i .in).out
|
||||
set template_err (basename $i .in).err
|
||||
set template_status (basename $i .in).status
|
||||
set -l res ok
|
||||
|
||||
../fish <$i >tmp.out ^tmp.err
|
||||
echo $status >tmp.status
|
||||
set res ok
|
||||
if diff tmp.out $template_out >/dev/null
|
||||
else
|
||||
set res fail
|
||||
echo Output differs for file $i. Diff follows:
|
||||
diff -u tmp.out $template_out
|
||||
end
|
||||
set -l base (basename $i .in)
|
||||
set template_out (basename $i .in).out
|
||||
set template_err (basename $i .in).err
|
||||
set template_status (basename $i .in).status
|
||||
|
||||
if diff tmp.err $template_err >/dev/null
|
||||
else
|
||||
set res fail
|
||||
echo Error output differs for file $i. Diff follows:
|
||||
diff -u tmp.err $template_err
|
||||
end
|
||||
../fish <$i >tmp.out ^tmp.err
|
||||
set -l tmp_status $status
|
||||
if not diff tmp.out $base.out >/dev/null
|
||||
set res fail
|
||||
echo "Output differs for file $i. Diff follows:"
|
||||
diff -u tmp.out $base.out
|
||||
end
|
||||
|
||||
if test (cat tmp.status) = (cat $template_status)
|
||||
else
|
||||
set res fail
|
||||
echo Exit status differs for file $i
|
||||
end
|
||||
if not diff tmp.err $base.err >/dev/null
|
||||
set res fail
|
||||
echo "Error output differs for file $i. Diff follows:"
|
||||
diff -u tmp.err $base.err
|
||||
end
|
||||
|
||||
if test $res = ok;
|
||||
echo File $i tested ok
|
||||
else
|
||||
echo File $i failed tests
|
||||
end;
|
||||
if test $tmp_status -ne (cat $template_status)
|
||||
set res fail
|
||||
echo "Exit status differs for file $i"
|
||||
end
|
||||
|
||||
if test $res = ok
|
||||
echo "File $i tested ok"
|
||||
else
|
||||
echo "File $i failed tests"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user