2021-09-20 23:00:21 +02:00
|
|
|
#!/bin/bash
|
2024-03-25 16:48:09 +01:00
|
|
|
tempdir=$(mktemp -d)
|
2021-09-20 23:00:21 +02:00
|
|
|
confpath=$tempdir/minetest.conf
|
|
|
|
worldpath=$tempdir/world
|
2024-03-25 16:48:09 +01:00
|
|
|
trap 'rm -rf "$tempdir"' EXIT
|
2021-09-20 23:00:21 +02:00
|
|
|
|
2024-03-25 16:48:09 +01:00
|
|
|
[ -f worldedit/mod.conf ] || { echo "Must be run in modpack root folder." >&2; exit 1; }
|
2021-09-20 23:00:21 +02:00
|
|
|
|
2024-03-25 16:48:09 +01:00
|
|
|
mtserver=
|
|
|
|
if [ "$1" == "--docker" ]; then
|
|
|
|
command -v docker >/dev/null || { echo "Docker is not installed." >&2; exit 1; }
|
|
|
|
[ -d minetest_game ] || { echo "To run the test with Docker, a source checkout of minetest_game is required." >&2; exit 1; }
|
|
|
|
else
|
|
|
|
mtserver=$(command -v minetestserver)
|
|
|
|
[[ -z "$mtserver" && -x ../../bin/minetestserver ]] && mtserver=../../bin/minetestserver
|
|
|
|
[ -z "$mtserver" ] && { echo "To run the test outside of Docker, an installation of minetestserver is required." >&2; exit 1; }
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir $worldpath
|
2021-09-20 23:00:21 +02:00
|
|
|
printf '%s\n' mg_name=singlenode '[end_of_params]' >$worldpath/map_meta.txt
|
2024-03-25 16:48:09 +01:00
|
|
|
printf '%s\n' worldedit_run_tests=true >$confpath
|
2021-09-20 23:00:21 +02:00
|
|
|
|
2024-03-25 16:48:09 +01:00
|
|
|
if [ -z "$mtserver" ]; then
|
2021-09-20 23:00:21 +02:00
|
|
|
chmod -R 777 $tempdir
|
2024-03-25 16:48:09 +01:00
|
|
|
[ -z "$DOCKER_IMAGE" ] && DOCKER_IMAGE="ghcr.io/minetest/minetest:master"
|
2021-09-20 23:00:21 +02:00
|
|
|
docker run --rm -i \
|
2024-03-25 16:48:09 +01:00
|
|
|
-v "$confpath":/etc/minetest/minetest.conf \
|
|
|
|
-v "$tempdir":/var/lib/minetest/.minetest \
|
|
|
|
-v "$PWD/minetest_game":/var/lib/minetest/.minetest/games/minetest_game \
|
2021-09-20 23:00:21 +02:00
|
|
|
-v "$PWD/worldedit":/var/lib/minetest/.minetest/world/worldmods/worldedit \
|
2024-03-25 16:48:09 +01:00
|
|
|
"$DOCKER_IMAGE"
|
2021-09-20 23:00:21 +02:00
|
|
|
else
|
|
|
|
mkdir $worldpath/worldmods
|
|
|
|
ln -s "$PWD/worldedit" $worldpath/worldmods/worldedit
|
2024-03-25 16:48:09 +01:00
|
|
|
$mtserver --config "$confpath" --world "$worldpath" --logfile /dev/null
|
2021-09-20 23:00:21 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
test -f $worldpath/tests_ok || exit 1
|
|
|
|
exit 0
|