From 7bd511c31cb5d923eecd4a47c34bb43c5ab1c2b3 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 10:14:17 -1000 Subject: Run each standalone Lua version once A plain lua is usually one of the versioned names again, as lua and lua5.5 are here, so every 5.5 check ran twice, while names such as lua54 and lua-5.4 were never looked for. A test now names the version that ran, since "under lua" did not say which one it was. --- tests/extensions/lib.sh | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'tests/extensions/lib.sh') diff --git a/tests/extensions/lib.sh b/tests/extensions/lib.sh index 4ca7522..d490655 100644 --- a/tests/extensions/lib.sh +++ b/tests/extensions/lib.sh @@ -8,18 +8,40 @@ EXTENSIONS_DIRECTORY=$(cd "$TEST_OUTPUT_DIRECTORY/../custom/extensions" && pwd) EXT_TEST_DIRECTORY=$(cd "$TEST_OUTPUT_DIRECTORY/extensions" && pwd) +# Prints the version an interpreter reports, LuaJIT by its own name rather +# than the 5.1 it is compatible with, or the name it was given when it does +# not run. +lua_version() { + "$1" -e 'io.write(jit and jit.version or _VERSION)' 2>/dev/null || + printf '%s' "$1" +} + # 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. +# never claimed to run on. Systems spell a versioned name in one of three +# ways, and a plain lua is usually one of those again, so each version runs +# once, under the first name found for it. interpreters= -for ext_lua_bin in luajit lua5.1 lua5.2 lua5.3 lua5.4 lua5.5 lua +ext_lua_versions= +for ext_lua_bin in luajit lua5.1 lua51 lua-5.1 lua5.2 lua52 lua-5.2 \ + lua5.3 lua53 lua-5.3 lua5.4 lua54 lua-5.4 lua5.5 lua55 lua-5.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" + ext_lua_version=$(lua_version "$ext_lua_bin") + case "$ext_lua_version" in + "Lua 5."[1-5]|"LuaJIT 2."*) + ;; + *) + continue + ;; + esac + case "$ext_lua_versions" in + *"|$ext_lua_version|"*) + continue ;; esac + ext_lua_versions="$ext_lua_versions|$ext_lua_version|" + interpreters="$interpreters $ext_lua_bin" done test -n "$interpreters" || say 'no standalone lua on the path, unit checks skipped' -- cgit 2.12.1