2014-09-08 02:11:34 +00:00
|
|
|
#!/usr/local/bin/fish
|
|
|
|
#
|
|
|
|
# Interactive tests using `expect`
|
|
|
|
|
|
|
|
function die
|
|
|
|
echo $argv[1] >&2
|
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
|
|
|
|
for i in *.expect
|
|
|
|
rm -Rf tmp.interactive.config; or die "Couldn't remove tmp.interactive.config"
|
|
|
|
mkdir -p tmp.interactive.config/fish; or die "Couldn't create tmp.interactive.config/fish"
|
|
|
|
cp interactive.config tmp.interactive.config/fish/config.fish; or die "Couldn't create tmp.interactive.config/fish/config.fish"
|
|
|
|
|
|
|
|
begin
|
|
|
|
set -lx XDG_CONFIG_HOME $PWD/tmp.interactive.config
|
|
|
|
set -lx TERM dumb
|
2014-09-18 22:45:07 +00:00
|
|
|
expect -n -c 'source interactive.expect.rc' -f $i >$i.tmp.out ^$i.tmp.err
|
2014-09-08 02:11:34 +00:00
|
|
|
end
|
|
|
|
set -l tmp_status $status
|
|
|
|
set res ok
|
2014-09-18 22:45:07 +00:00
|
|
|
mv -f interactive.tmp.log $i.tmp.log
|
|
|
|
if not diff $i.tmp.out $i.out >/dev/null
|
2014-09-08 02:11:34 +00:00
|
|
|
set res fail
|
|
|
|
echo "Output differs for file $i. Diff follows:"
|
2014-09-18 22:45:07 +00:00
|
|
|
diff -u $i.tmp.out $i.out
|
2014-09-08 02:11:34 +00:00
|
|
|
end
|
|
|
|
|
2014-09-18 22:45:07 +00:00
|
|
|
if not diff $i.tmp.err $i.err >/dev/null
|
2014-09-08 02:11:34 +00:00
|
|
|
set res fail
|
|
|
|
echo "Error output differs for file $i. Diff follows:"
|
2014-09-18 22:45:07 +00:00
|
|
|
diff -u $i.tmp.err $i.err
|
2014-09-08 02:11:34 +00:00
|
|
|
end
|
|
|
|
|
2014-09-19 23:22:37 +00:00
|
|
|
set -l exp_status (cat $i.status)[1]
|
|
|
|
if test $tmp_status != $exp_status
|
2014-09-08 02:11:34 +00:00
|
|
|
set res fail
|
|
|
|
echo "Exit status differs for file $i."
|
2014-09-19 23:22:37 +00:00
|
|
|
echo "Expected $exp_status, got $tmp_status."
|
2014-09-08 02:11:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if test $res = ok
|
|
|
|
echo "File $i tested ok"
|
2014-09-18 22:45:07 +00:00
|
|
|
# clean up tmp files
|
|
|
|
rm -f $i.tmp.{err,out,log}
|
2014-09-08 02:11:34 +00:00
|
|
|
else
|
2014-09-19 21:50:34 +00:00
|
|
|
if set -qgx SHOW_INTERACTIVE_LOG
|
|
|
|
# dump the interactive log
|
|
|
|
# primarily for use in travis where we can't check it manually
|
|
|
|
echo "Log for file $i:"
|
|
|
|
cat $i.tmp.log
|
|
|
|
end
|
2014-09-08 02:11:34 +00:00
|
|
|
echo "File $i failed tests"
|
|
|
|
end
|
|
|
|
end
|