summaryrefslogtreecommitdiff
path: root/vis
diff options
context:
space:
mode:
Diffstat (limited to 'vis')
-rw-r--r--vis/.gitignore3
-rw-r--r--vis/Makefile15
-rw-r--r--vis/README.md17
-rw-r--r--vis/multiple-cursors/basic.in4
-rw-r--r--vis/multiple-cursors/basic.keys6
-rw-r--r--vis/multiple-cursors/basic.ref4
-rwxr-xr-xvis/test.sh35
7 files changed, 84 insertions, 0 deletions
diff --git a/vis/.gitignore b/vis/.gitignore
new file mode 100644
index 0000000..589a89a
--- /dev/null
+++ b/vis/.gitignore
@@ -0,0 +1,3 @@
+*.out
+*.err
+*.disabled \ No newline at end of file
diff --git a/vis/Makefile b/vis/Makefile
new file mode 100644
index 0000000..36a4ce7
--- /dev/null
+++ b/vis/Makefile
@@ -0,0 +1,15 @@
+test: ../../vis ../util/keys
+ @./test.sh
+
+../../vis: ../../*.[ch]
+ @echo Compiling vis
+ @$(MAKE) -C ../..
+
+../util/keys: ../util/keys.c
+ @$(MAKE) -C ../util
+
+clean:
+ @echo cleaning
+ @find . -name '*.out' -o -name '*.err' | xargs rm -f
+
+.PHONY: clean test
diff --git a/vis/README.md b/vis/README.md
new file mode 100644
index 0000000..e7e655d
--- /dev/null
+++ b/vis/README.md
@@ -0,0 +1,17 @@
+Tests for vis specific editing features
+---------------------------------------
+
+The basic idea is to feed keyboard input to `vis` and compare the
+produced output with a known reference solution.
+
+A test constitutes of 3 files:
+
+ * `test.in` the file/buffer content with which the editor is started
+ * `test.keys` a file containing the keyboard input as would normally
+ be typed by a user
+ * `test.ref` a reference file at the end of the editing session
+
+The toplevel shell script `test.sh` looks for these files in sub
+directories, feeds the keys to `vis` and compares the produces output.
+
+Type `make` to run all tests.
diff --git a/vis/multiple-cursors/basic.in b/vis/multiple-cursors/basic.in
new file mode 100644
index 0000000..949ea37
--- /dev/null
+++ b/vis/multiple-cursors/basic.in
@@ -0,0 +1,4 @@
+1 : first
+2 : second
+3 : third
+4 : fourth
diff --git a/vis/multiple-cursors/basic.keys b/vis/multiple-cursors/basic.keys
new file mode 100644
index 0000000..df8738e
--- /dev/null
+++ b/vis/multiple-cursors/basic.keys
@@ -0,0 +1,6 @@
+vGI /* create cursor at start of every line */
+df<Space> /* delete to first space */
+. /* delete to second space */
+A : end<Escape> /* append " : end" to line */
+. /* repeat */
+u /* undo */
diff --git a/vis/multiple-cursors/basic.ref b/vis/multiple-cursors/basic.ref
new file mode 100644
index 0000000..7c5bd13
--- /dev/null
+++ b/vis/multiple-cursors/basic.ref
@@ -0,0 +1,4 @@
+first : end
+second : end
+third : end
+fourth : end
diff --git a/vis/test.sh b/vis/test.sh
new file mode 100755
index 0000000..a52fe0f
--- /dev/null
+++ b/vis/test.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+[ -z "$VIS" ] && VIS="../../vis"
+
+TESTS=$1
+[ -z "$TESTS" ] && TESTS=$(find . -name '*.keys' | sed 's/\.keys$//g')
+
+TESTS_RUN=0
+TESTS_OK=0
+
+$VIS -v
+
+for t in $TESTS; do
+ ERR="$t.err"
+ OUT="$t.out"
+ REF="$t.ref"
+ printf "Running test %s ... " "$t"
+ rm -f "$OUT" "$ERR"
+ { cat "$t.keys"; printf "<Escape>:wq! $OUT<Enter>"; } | cpp -P | ../util/keys | $VIS "$t.in" 2> /dev/null
+ if [ -e "$OUT" ]; then
+ if cmp -s "$REF" "$OUT"; then
+ printf "OK\n"
+ TESTS_OK=$((TESTS_OK+1))
+ else
+ printf "FAIL\n"
+ diff -u "$REF" "$OUT" > "$ERR"
+ fi
+ TESTS_RUN=$((TESTS_RUN+1))
+ fi
+done
+
+printf "Tests ok %d/%d\n" $TESTS_OK $TESTS_RUN
+
+# set exit status
+[ $TESTS_OK -eq $TESTS_RUN ]