diff options
| author | Josh Wainwright <josh.wainwright@ldra.com> | 2016-04-20 12:26:50 +0100 |
|---|---|---|
| committer | Josh Wainwright <josh.wainwright@ldra.com> | 2016-04-20 12:26:50 +0100 |
| commit | b474d7aa119fc6d1d28a574296ed341194eede31 (patch) | |
| tree | 2d46f312dd4497ef08a5272e03208efa9b255cdc /lua/test.sh | |
| parent | 6bff371e3cce703ffc2a9c0df7c89d361e4ebf00 (diff) | |
| download | vis-b474d7aa119fc6d1d28a574296ed341194eede31.tar.gz vis-b474d7aa119fc6d1d28a574296ed341194eede31.tar.xz | |
Add first set of basic lua api tests
There are two types of lua tests here:
1. Tests are formed from a <test>.in, <test>.ref and <test>.out triplet. The
<test>.in file is opened by vis, some operatations are performed and the
modified file is written to <test>.out. The new <test>.out is compared to
<test>.ref and the test passes if they are identical.
2. Tests are formed from a single <test>.true file. This file is created by the
lua code in the test. It contains a single line per test case, this single
line should be `true` if the test case passed. The <test>.true file is
checked to ensure it contains only `true` lines and if so, the test passes.
Diffstat (limited to 'lua/test.sh')
| -rw-r--r-- | lua/test.sh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lua/test.sh b/lua/test.sh new file mode 100644 index 0000000..bfc686e --- /dev/null +++ b/lua/test.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +export VIS_PATH=. +export VIS_THEME=theme +printf "<Escape>Q:q<Enter>" | ../util/keys | vis + +TESTS_OK=0 +TESTS_RUN=0 + +ref_files=$(find . -type f -name "*.ref") + +for ref in $ref_files; do + TESTS_RUN=$((TESTS_RUN + 1)) + out=${ref%.ref}.out + printf "%-30s" "$ref" + if cmp $ref $out 2> /dev/null; then + printf "PASS\n" + TESTS_OK=$((TESTS_OK + 1)) + else + printf "FAIL\n" + diff -u $ref $out + fi +done + +true_files=$(find . -type f -name "*.true") + +for t in $true_files; do + TESTS_RUN=$((TESTS_RUN + 1)) + printf "%-30s" "$t" + if ! grep -v true $t > /dev/null; then + printf "PASS\n" + TESTS_OK=$((TESTS_OK + 1)) + else + printf "FAIL\n" + grep -vn true $t + fi +done + +printf "Tests ok %d/%d\n" $TESTS_OK $TESTS_RUN + +# set exit status +[ $TESTS_OK -eq $TESTS_RUN ] |
