Move lua environment detection to its own file and source in the test scripts

This commit is contained in:
teknomunk
2025-02-25 07:05:32 -06:00
parent de3cf45f74
commit f7d9e1c2c0
4 changed files with 20 additions and 17 deletions

16
tests/env.sh Normal file

@ -0,0 +1,16 @@
#!/bin/bash
which luarocks && eval $(luarocks path)
which luarocks-5.3 && eval $(luarocks-5.3 path)
if [[ -d /usr/share/minetest ]]; then
export LUANTI_PATH=/usr/share/minetest
elif [[ -d /usr/share/luanti ]]; then
export LUANTI_PATH=/usr/share/luanti
else
echo "Unable to find luanti/minetest path, cannot run tests"
exit 1
fi
LUACHECK=$HOME/.luarocks/bin/luacheck
LUA=$( which lua || which lua5.1 || which lua5.2 || which lua5.3 || which luajit )

@ -1,7 +1,7 @@
#!/bin/sh
source tests/env.sh
set -e
LUA=$( which lua || which lua5.1 || which lua5.2 || which lua5.3 || which luajit )
# Make sure luanti lls definitions are up-to-date
(

@ -1,19 +1,8 @@
#!/bin/bash
which luarocks && eval $(luarocks path)
which luarocks-5.3 && eval $(luarocks-5.3 path)
source tests/env.sh
set -e
if [[ -d /usr/share/minetest ]]; then
export LUANTI_PATH=/usr/share/minetest
elif [[ -d /usr/share/luanti ]]; then
export LUANTI_PATH=/usr/share/luanti
else
echo "Unable to find luanti/minetest path, cannot run tests"
exit 1
fi
LUACHECK=$HOME/.luarocks/bin/luacheck
LUA=$( which lua || which lua5.1 || which lua5.2 || which lua5.3 || which luajit )
if [[ -z "$LUA" ]]; then
echo "Unable to find lua interpreter"
exit 1

@ -1,10 +1,8 @@
#!/bin/sh
source tests/env.sh
set -e
which luarocks && eval $(luarocks path)
which luarocks-5.3 && eval $(luarocks-5.3 path)
find ./ -name 'mod.conf' | sort | while read MOD; do
(
set -e