aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/interactive.fish
diff options
context:
space:
mode:
authorGravatar Kevin Ballard <kevin@sb.org>2014-09-07 19:11:34 -0700
committerGravatar Kevin Ballard <kevin@sb.org>2014-09-07 23:56:59 -0700
commit190712d4b0fe97f8437b2f3c9b642dd5c46cf60f (patch)
treec023bb8866a40e5d278b6ab51256b1429cedf456 /tests/interactive.fish
parentefb1467e4ec70016204baaa9b88af658debbf973 (diff)
Add a test harness for interactive behavior
Add a test harness that uses `expect` to drive Fish to test interactive behavior. Include some tests for `read`.
Diffstat (limited to 'tests/interactive.fish')
-rw-r--r--tests/interactive.fish44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/interactive.fish b/tests/interactive.fish
new file mode 100644
index 00000000..987ad80b
--- /dev/null
+++ b/tests/interactive.fish
@@ -0,0 +1,44 @@
+#!/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
+ expect -n -c 'source interactive.expect.rc' -f $i >tmp.out ^tmp.err
+ end
+ set -l tmp_status $status
+ set res ok
+ if not diff tmp.out $i.out >/dev/null
+ set res fail
+ echo "Output differs for file $i. Diff follows:"
+ diff -u tmp.out $i.out
+ end
+
+ if not diff tmp.err $i.err >/dev/null
+ set res fail
+ echo "Error output differs for file $i. Diff follows:"
+ diff -u tmp.err $i.err
+ end
+
+ if test $tmp_status != (cat $i.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