Diff options
Diffstat (limited to 'tests/extensions/lib.sh')
-rw-r--r--tests/extensions/lib.sh41
1 file changed, 16 insertions, 25 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