diff options
author | Kevin Ballard <kevin@sb.org> | 2014-09-04 22:26:10 -0700 |
---|---|---|
committer | Kevin Ballard <kevin@sb.org> | 2014-09-07 23:50:44 -0700 |
commit | efb1467e4ec70016204baaa9b88af658debbf973 (patch) | |
tree | 3a3cab6bf54718cd7649026599840707ce293529 | |
parent | 8643a5e2666bf043dcc53a9a3694e98f7475aa08 (diff) |
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`).
-rw-r--r-- | Makefile.in | 19 | ||||
-rwxr-xr-x | tests/test.fish | 122 |
2 files changed, 76 insertions, 65 deletions
diff --git a/Makefile.in b/Makefile.in index 4995dddc..6634c94f 100644 --- a/Makefile.in +++ b/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 diff --git a/tests/test.fish b/tests/test.fish index 2f2b8533..a74165b9 100755 --- a/tests/test.fish +++ b/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 - |