From fa079b52954b615e03a8034826b2ba5c1033c474 Mon Sep 17 00:00:00 2001 From: BuckarooBanzay <BuckarooBanzay@users.noreply.github.com> Date: Mon, 13 Apr 2020 20:00:35 +0200 Subject: [PATCH] add integration test --- .github/workflows/integration-test.yml | 14 ++++++++++++++ init.lua | 4 ++++ integration-test.sh | 20 ++++++++++++++++++++ integration_test.lua | 25 +++++++++++++++++++++++++ readme.md | 1 + 5 files changed, 64 insertions(+) create mode 100644 .github/workflows/integration-test.yml create mode 100755 integration-test.sh create mode 100644 integration_test.lua diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml new file mode 100644 index 0000000..4bea2fa --- /dev/null +++ b/.github/workflows/integration-test.yml @@ -0,0 +1,14 @@ +name: integration-test + +on: [push, pull_request] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + + - name: integration-test + run: ./integration-test.sh diff --git a/init.lua b/init.lua index 5f5af2d..13c1efe 100644 --- a/init.lua +++ b/init.lua @@ -71,3 +71,7 @@ end print("[OK] Mapserver") + +if minetest.settings:get_bool("enable_mapserver_integration_test") then + dofile(MP.."/integration_test.lua") +end diff --git a/integration-test.sh b/integration-test.sh new file mode 100755 index 0000000..19bdb6a --- /dev/null +++ b/integration-test.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# simple integration test + +CFG=/tmp/minetest.conf +MTDIR=/tmp/mt +WORLDDIR=${MTDIR}/worlds/world + +cat <<EOF > ${CFG} + enable_mapserver_integration_test = true +EOF + +mkdir -p ${WORLDDIR} +chmod 777 ${MTDIR} -R +docker run --rm -i \ + -v ${CFG}:/etc/minetest/minetest.conf:ro \ + -v ${MTDIR}:/var/lib/minetest/.minetest \ + -v $(pwd):/var/lib/minetest/.minetest/worlds/world/worldmods/mapserver \ + registry.gitlab.com/minetest/minetest/server:5.2.0 + +test -f ${WORLDDIR}/integration_test.json && exit 0 || exit 1 diff --git a/integration_test.lua b/integration_test.lua new file mode 100644 index 0000000..65e9dfd --- /dev/null +++ b/integration_test.lua @@ -0,0 +1,25 @@ + +minetest.log("warning", "[TEST] integration-test enabled!") + +minetest.register_on_mods_loaded(function() + minetest.after(1, function() + + local data = minetest.write_json({ success = true }, true); + local file = io.open(minetest.get_worldpath().."/integration_test.json", "w" ); + if file then + file:write(data) + file:close() + end + + file = io.open(minetest.get_worldpath().."/registered_nodes.txt", "w" ); + if file then + for name in pairs(minetest.registered_nodes) do + file:write(name .. '\n') + end + file:close() + end + + minetest.log("warning", "[TEST] integration tests done!") + minetest.request_shutdown("success") + end) +end) diff --git a/readme.md b/readme.md index b3213bc..c8087da 100644 --- a/readme.md +++ b/readme.md @@ -2,6 +2,7 @@ # mapserver mod  + This is the complementary mod for the mapserver: https://github.com/minetest-tools/mapserver -- GitLab