From d0754ab7835a0e426159aeb903742e8334e577f4 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Thu, 1 Oct 2026 14:12:04 -1000 Subject: Keep the Lua-less build compiling `cgit_abort_filters` unhooks the Lua write interposer under NO_LUA too, where neither the hook nor its state exists, so `make NO_LUA=1` and the default mode of `tools/release-build.sh` have not compiled since the die path learned to take stdout back from a filter. The suite now builds that variant into `build/nolua` and runs it, and a `lua:` filter in such a build is refused with a message naming the cause instead of an unknown filter type. --- tests/t0006-nolua.sh | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 tests/t0006-nolua.sh (limited to 'tests') 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" 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 -- cgit v2.8.0