Diff options
Diffstat (limited to '')
-rw-r--r--tests/extensions/lib.sh41
-rwxr-xr-xtests/setup.sh5
-rwxr-xr-xtests/t0201-filters.sh3
-rwxr-xr-xtests/t0501-about-render.sh21
-rwxr-xr-xtests/t0502-syntax-highlight.sh8
-rwxr-xr-xtests/t0503-link-commits.sh8
-rwxr-xr-xtests/t0504-email-avatar.sh10
-rwxr-xr-xtests/t0505-auth.sh10
-rwxr-xr-xtests/t0506-link-trailers.sh8
9 files changed, 27 insertions, 87 deletions
diff --git a/tests/extensions/lib.sh b/tests/extensions/lib.sh
index 30a9cc8..92db245 100644
--- a/tests/extensions/lib.sh
+++ b/tests/extensions/lib.sh
@@ -1,6 +1,6 @@
# Shared groundwork for the t05xx scripts, sourced after setup.sh from inside
# the trash directory. It locates the shipped extensions and the unit checks
-# beside this file, finds the standalone Lua interpreters the checks can run
+# beside this file, lists the standalone Lua interpreters the checks can run
# under, and offers a probe that asks the Lua inside the cgit binary itself
# whether a module is available to it, since that interpreter can differ from
# every standalone one on the path.
@@ -8,30 +8,21 @@
EXTENSIONS_DIRECTORY=$(cd "$TEST_OUTPUT_DIRECTORY/../custom/extensions" && pwd)
EXT_TEST_DIRECTORY=$(cd "$TEST_OUTPUT_DIRECTORY/extensions" && pwd)
-# Prints the Lua version a binary reports, like 5.1, which is also what
-# LuaJIT reports.
-ext_lua_version() {
- "$1" -e 'io.write(string.match(_VERSION, "%d+%.%d+"))' 2>/dev/null
-}
-
-# Prints the interpreters found on the path whose version falls between 5.1
-# and the given 5.x ceiling, one per line, so a script is never failed on a
-# version it never claimed to run on.
-ext_lua_interpreters() {
- ext_lua_ceiling=$1
- for ext_lua_bin in luajit lua5.1 lua5.2 lua5.3 lua5.4 lua5.5 lua
- do
- command -v "$ext_lua_bin" >/dev/null 2>&1 || continue
- case "$(ext_lua_version "$ext_lua_bin")" in
- 5.[1-9])
- ext_lua_minor=$(ext_lua_version "$ext_lua_bin")
- ext_lua_minor=${ext_lua_minor#5.}
- test "$ext_lua_minor" -le "$ext_lua_ceiling" &&
- echo "$ext_lua_bin"
- ;;
- esac
- done
-}
+# The interpreters on the path whose version the extensions claim, 5.1 to
+# 5.5 with LuaJIT counting as 5.1, so no script is failed on a version it
+# never claimed to run on.
+interpreters=
+for ext_lua_bin in luajit lua5.1 lua5.2 lua5.3 lua5.4 lua5.5 lua
+do
+ command -v "$ext_lua_bin" >/dev/null 2>&1 || continue
+ case "$("$ext_lua_bin" -e 'io.write(_VERSION)' 2>/dev/null)" in
+ "Lua 5."[1-5])
+ interpreters="$interpreters $ext_lua_bin"
+ ;;
+ esac
+done
+test -n "$interpreters" ||
+ say 'no standalone lua on the path, unit checks skipped'
# Asks whether cgit's own Lua can require every module named, by pointing a
# throwaway commit-filter at the given repository and reading its answer off
diff --git a/tests/setup.sh b/tests/setup.sh
index a1f2d15..642faab 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -69,9 +69,10 @@ FILTER_DIRECTORY=$(cd "$TEST_OUTPUT_DIRECTORY/filters" && pwd)
# them have to ask the binary rather than assume.
if cgit --version | grep -F -q "[+] Lua scripting"
then
- export CGIT_HAS_LUA=1
+ CGIT_HAS_LUA=1
+ test_set_prereq CGIT_LUA
else
- export CGIT_HAS_LUA=0
+ CGIT_HAS_LUA=0
fi
# Creates a repository holding the given number of one file commits. A third
diff --git a/tests/t0201-filters.sh b/tests/t0201-filters.sh
index 6d33803..ffac3e4 100755
--- a/tests/t0201-filters.sh
+++ b/tests/t0201-filters.sh
@@ -107,9 +107,6 @@ test_expect_success 'only a repository page hands filters its variables' '
grep "repo url: \." tmp
'
-test "$CGIT_HAS_LUA" -eq 1 && test_set_prereq CGIT_LUA
-test "$CGIT_HAS_LUA" -eq 1 || say 'cgit built without lua, error page check skipped'
-
# A die inside a lua filter has to reach the visitor as an error page rather
# than being fed back into the filter that just failed, and the reason goes to
# the log.
diff --git a/tests/t0501-about-render.sh b/tests/t0501-about-render.sh
index 222ddfd..97ac08c 100755
--- a/tests/t0501-about-render.sh
+++ b/tests/t0501-about-render.sh
@@ -13,10 +13,6 @@ CGIT_TEST_NO_CREATE_REPOS=YesPlease
. ./setup.sh
. "$TEST_OUTPUT_DIRECTORY/extensions/lib.sh"
-interpreters=$(ext_lua_interpreters 5)
-test -z "$interpreters" &&
- say 'no standalone lua on the path, unit checks skipped'
-
for lua in $interpreters
do
test_expect_success "unit checks under $lua" "
@@ -77,18 +73,13 @@ test_expect_success 'point cgit at it through the about filter' '
EOF
'
-if test "$CGIT_HAS_LUA" -eq 1
+if cgit_lua_probe "$PWD/repos/md/.git" lpeg
+then
+ test_set_prereq CGIT_LUA_LPEG
+elif test "$CGIT_HAS_LUA" -eq 1
then
- test_set_prereq CGIT_LUA
- if cgit_lua_probe "$PWD/repos/md/.git" lpeg
- then
- test_set_prereq CGIT_LUA_LPEG
- else
- test_set_prereq CGIT_LUA_NOLPEG
- say 'cgit lua has no lpeg, expecting the plain text fallback'
- fi
-else
- say 'cgit built without lua, filter checks through cgit skipped'
+ test_set_prereq CGIT_LUA_NOLPEG
+ say 'cgit lua has no lpeg, expecting the plain text fallback'
fi
test_expect_success CGIT_LUA_LPEG 'the about page renders the markdown' '
diff --git a/tests/t0502-syntax-highlight.sh b/tests/t0502-syntax-highlight.sh
index 4c0e412..2ca3c9f 100755
--- a/tests/t0502-syntax-highlight.sh
+++ b/tests/t0502-syntax-highlight.sh
@@ -15,10 +15,6 @@ CGIT_TEST_NO_CREATE_REPOS=YesPlease
. ./setup.sh
. "$TEST_OUTPUT_DIRECTORY/extensions/lib.sh"
-interpreters=$(ext_lua_interpreters 5)
-test -z "$interpreters" &&
- say 'no standalone lua on the path, unit checks skipped'
-
for lua in $interpreters
do
test_expect_success "highlighting checks under $lua" "
@@ -35,10 +31,6 @@ do
"
done
-test "$CGIT_HAS_LUA" -eq 1 && test_set_prereq CGIT_LUA
-test "$CGIT_HAS_LUA" -eq 1 ||
- say 'cgit built without lua, filter checks through cgit skipped'
-
test_expect_success 'create a repository holding a lexable file' '
test_create_repo repos/fake &&
(
diff --git a/tests/t0503-link-commits.sh b/tests/t0503-link-commits.sh
index e6e8816..d38093a 100755
--- a/tests/t0503-link-commits.sh
+++ b/tests/t0503-link-commits.sh
@@ -11,10 +11,6 @@ CGIT_TEST_NO_CREATE_REPOS=YesPlease
. ./setup.sh
. "$TEST_OUTPUT_DIRECTORY/extensions/lib.sh"
-interpreters=$(ext_lua_interpreters 5)
-test -z "$interpreters" &&
- say 'no standalone lua on the path, unit checks skipped'
-
for lua in $interpreters
do
test_expect_success "unit checks under $lua" "
@@ -22,10 +18,6 @@ do
"
done
-test "$CGIT_HAS_LUA" -eq 1 && test_set_prereq CGIT_LUA
-test "$CGIT_HAS_LUA" -eq 1 ||
- say 'cgit built without lua, filter checks through cgit skipped'
-
test_expect_success 'create a repository whose commit message holds matches' '
test_create_repo repos/linky &&
(
diff --git a/tests/t0504-email-avatar.sh b/tests/t0504-email-avatar.sh
index ec1f5da..60db6d6 100755
--- a/tests/t0504-email-avatar.sh
+++ b/tests/t0504-email-avatar.sh
@@ -14,10 +14,6 @@ CGIT_TEST_NO_CREATE_REPOS=YesPlease
. ./setup.sh
. "$TEST_OUTPUT_DIRECTORY/extensions/lib.sh"
-interpreters=$(ext_lua_interpreters 5)
-test -z "$interpreters" &&
- say 'no standalone lua on the path, unit checks skipped'
-
for lua in $interpreters
do
for script in email-gravatar email-libravatar
@@ -48,18 +44,14 @@ test_expect_success 'create a repository with one commit' '
)
'
-if test "$CGIT_HAS_LUA" -eq 1 &&
- cgit_lua_probe "$PWD/repos/avatar/.git" openssl.digest
+if cgit_lua_probe "$PWD/repos/avatar/.git" openssl.digest
then
test_set_prereq CGIT_LUA_OSSL
elif test "$CGIT_HAS_LUA" -eq 1
then
test_set_prereq CGIT_LUA_NOOSSL
say 'cgit lua has no luaossl, expecting names without icons'
-else
- say 'cgit built without lua, filter checks through cgit skipped'
fi
-test "$CGIT_HAS_LUA" -eq 1 && test_set_prereq CGIT_LUA
test_expect_success CGIT_LUA 'point cgit at it through the email filter' '
cat >cgitrc <<-EOF
diff --git a/tests/t0505-auth.sh b/tests/t0505-auth.sh
index be0f0ce..177a5a6 100755
--- a/tests/t0505-auth.sh
+++ b/tests/t0505-auth.sh
@@ -13,10 +13,6 @@ CGIT_TEST_NO_CREATE_REPOS=YesPlease
. ./setup.sh
. "$TEST_OUTPUT_DIRECTORY/extensions/lib.sh"
-interpreters=$(ext_lua_interpreters 5)
-test -z "$interpreters" &&
- say 'no standalone lua on the path, unit checks skipped'
-
for lua in $interpreters
do
for variant in inline file
@@ -37,18 +33,14 @@ test_expect_success 'create a repository with one commit' '
)
'
-if test "$CGIT_HAS_LUA" -eq 1 &&
- cgit_lua_probe "$PWD/repos/authy/.git" openssl.rand openssl.hmac posix.sys.stat posix.unistd
+if cgit_lua_probe "$PWD/repos/authy/.git" openssl.rand openssl.hmac posix.sys.stat posix.unistd
then
test_set_prereq CGIT_LUA_AUTH
elif test "$CGIT_HAS_LUA" -eq 1
then
test_set_prereq CGIT_LUA_NOAUTH
say 'cgit lua lacks luaossl or luaposix, expecting protected pages refused'
-else
- say 'cgit built without lua, checks through cgit skipped'
fi
-test "$CGIT_HAS_LUA" -eq 1 && test_set_prereq CGIT_LUA
test_expect_success CGIT_LUA 'point cgit at the unedited auth filter' '
cat >cgitrc <<-EOF
diff --git a/tests/t0506-link-trailers.sh b/tests/t0506-link-trailers.sh
index c2e4f91..03db63a 100755
--- a/tests/t0506-link-trailers.sh
+++ b/tests/t0506-link-trailers.sh
@@ -11,10 +11,6 @@ CGIT_TEST_NO_CREATE_REPOS=YesPlease
. ./setup.sh
. "$TEST_OUTPUT_DIRECTORY/extensions/lib.sh"
-interpreters=$(ext_lua_interpreters 5)
-test -z "$interpreters" &&
- say 'no standalone lua on the path, unit checks skipped'
-
for lua in $interpreters
do
test_expect_success "unit checks under $lua" "
@@ -22,10 +18,6 @@ do
"
done
-test "$CGIT_HAS_LUA" -eq 1 && test_set_prereq CGIT_LUA
-test "$CGIT_HAS_LUA" -eq 1 ||
- say 'cgit built without lua, filter checks through cgit skipped'
-
test_expect_success 'create a repository whose commit carries linkable trailers' '
test_create_repo repos/linky &&
(