diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/t0006-nolua.sh58
1 file changed, 58 insertions, 0 deletions
diff --git a/tests/t0006-nolua.sh b/tests/t0006-nolua.sh
new file mode 100755
index 0000000..c315e41
--- /dev/null
+++ b/tests/t0006-nolua.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+# The build without Lua has to serve pages like the full one and run the exec
+# filters, and a filter written with the lua: prefix has to be refused with a
+# message naming the cause. make test builds it into build/nolua beside the
+# ordinary binary. The shared cgitrc may itself name lua filters, so every
+# request here carries a config of its own.
+
+test_description='Check the build without Lua'
+. ./setup.sh
+
+nolua="$TEST_OUTPUT_DIRECTORY/../build/nolua/cgit"
+test -x "$nolua" || {
+ skip_all='Skipping the Lua-less checks: build/nolua/cgit is missing, run make test'
+ test_done
+ exit
+}
+
+nolua_query() { CGIT_CONFIG="$PWD/$1" QUERY_STRING="$2" "$nolua"; }
+
+test_expect_success 'the binary reports no Lua' '
+ "$nolua" --version >tmp &&
+ grep -F "[-] Lua scripting" tmp
+'
+
+test_expect_success 'it serves a page' '
+ {
+ echo "virtual-root=/" &&
+ echo "cache-size=0" &&
+ echo "repo.url=foo" &&
+ echo "repo.path=$PWD/repos/foo/.git"
+ } >plainrc &&
+ nolua_query plainrc "url=foo/log/" >tmp &&
+ grep "^Status: 200" tmp &&
+ grep ">commit 5</a>" tmp
+'
+
+test_expect_success 'an exec filter still runs' '
+ {
+ cat plainrc &&
+ echo "repo.commit-filter=exec:$FILTER_DIRECTORY/dump.sh"
+ } >execrc &&
+ nolua_query execrc "url=foo/commit/" >tmp &&
+ grep "COMMIT 5" tmp
+'
+
+test_expect_success 'a lua filter is refused with one error page' '
+ {
+ cat plainrc &&
+ echo "repo.commit-filter=lua:$FILTER_DIRECTORY/dump.lua"
+ } >luarc &&
+ nolua_query luarc "url=foo/commit/" >tmp 2>err &&
+ grep "^Status: 500" tmp &&
+ test $(grep -c "^Status:" tmp) = 1 &&
+ grep "Built without Lua" err
+'
+
+test_done