Diff options
| -rw-r--r-- | Makefile | 3 | |
| -rw-r--r-- | README.txt | 3 | |
| -rwxr-xr-x | tests/t0006-nolua.sh | 29 | |
| -rwxr-xr-x | tests/valgrind/bin/cgit | 3 |
4 files changed, 21 insertions, 17 deletions
@@ -86,7 +86,8 @@ cgit: $(CGIT_ROOT)/$(BUILDDIR)/cgit $(EXTRA_GIT_TARGETS) $(GIT_BUILD_FLAGS) # The same program without Lua, built beside the full one so a change cannot -# break that configuration unnoticed. The suite runs both. +# break that configuration unnoticed. make test builds it, and t0006 checks +# that it serves pages, runs exec filters and refuses lua ones. .PHONY: cgit-nolua cgit-nolua: +@$(MAKE) -C $(GITDIR) -f $(CGIT_ROOT)/$(SRCDIR)/cgit.mk \ @@ -89,7 +89,8 @@ Lua at runtime, turn it off. A binary built this way still runs every exec: filter, but a filter named with the lua: prefix has no interpreter to run in, so it is refused with an error on every page until the setting is taken out of cgitrc. make test builds this -variant as well, into build/nolua, and checks it the same way. +variant as well, into build/nolua, and checks that it serves pages, runs exec +filters and refuses lua ones, while the rest of the suite runs the full build. Quick start diff --git a/tests/t0006-nolua.sh b/tests/t0006-nolua.sh index f68e731..d0ec2fe 100755 --- a/tests/t0006-nolua.sh +++ b/tests/t0006-nolua.sh @@ -17,35 +17,36 @@ test_have_prereq CGIT_NOLUA || { test_done } -nolua_query() { CGIT_CONFIG="$PWD/$1" QUERY_STRING="$2" "$nolua"; } +# The helpers run the first cgit on PATH, which this binary now becomes, or +# under Valgrind the one the wrapper is pointed at. +if test -n "$CGIT_TEST_VALGRIND" +then + CGIT_VALGRIND_BINARY=$nolua + export CGIT_VALGRIND_BINARY +else + PATH="${nolua%/cgit}:$PATH" +fi test_expect_success 'the binary reports no Lua' ' - "$nolua" --version >tmp && + cgit --version >tmp && grep -F "[-] Lua scripting" tmp ' test_expect_success 'it serves a page' ' cgitrc_repo plainrc foo && - nolua_query plainrc "url=foo/log/" >tmp && - grep "^Status: 200" tmp && + cgit_ok plainrc "url=foo/log/" >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 && + cgitrc_repo execrc foo "repo.commit-filter=exec:$FILTER_DIRECTORY/dump.sh" && + cgit_ok 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 && + cgitrc_repo luarc foo "repo.commit-filter=lua:$FILTER_DIRECTORY/dump.lua" && + cgit_rc luarc "url=foo/commit/" >tmp 2>err && grep "^Status: 500" tmp && test $(grep -c "^Status:" tmp) = 1 && grep "Built without Lua" err diff --git a/tests/valgrind/bin/cgit b/tests/valgrind/bin/cgit index e5666b5..e50767c 100755 --- a/tests/valgrind/bin/cgit +++ b/tests/valgrind/bin/cgit @@ -6,6 +6,7 @@ # points into the bundled Git tree while CGIT_VALGRIND points back at this # wrapper's home. The tool comes from --valgrind=<tool> and its options follow # Git's own wrapper, with any in GIT_VALGRIND_OPTIONS added after them. +# CGIT_VALGRIND_BINARY names a binary to watch other than build/cgit. case "$CGIT_TEST_VALGRIND" in memcheck) tool_options="--leak-check=no --track-origins=yes" @@ -25,4 +26,4 @@ exec "$CGIT_VALGRIND_PROGRAM" -q --error-exitcode=126 \ --log-fd=4 \ --input-fd=4 \ $GIT_VALGRIND_OPTIONS \ - "$CGIT_VALGRIND/../../build/cgit" "$@" + "${CGIT_VALGRIND_BINARY:-$CGIT_VALGRIND/../../build/cgit}" "$@" |
