Skip to content

Commit

Permalink
add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay committed Apr 13, 2020
1 parent 43ecc7d commit fa079b5
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,7 @@ end


print("[OK] Mapserver")

if minetest.settings:get_bool("enable_mapserver_integration_test") then
dofile(MP.."/integration_test.lua")
end
20 changes: 20 additions & 0 deletions integration-test.sh
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions integration_test.lua
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# mapserver mod

![](https://github.com/minetest-mapserver/mapserver_mod/workflows/luacheck/badge.svg)
![](https://github.com/minetest-mapserver/mapserver_mod/workflows/integration-test/badge.svg)

This is the complementary mod for the mapserver: https://github.com/minetest-tools/mapserver

Expand Down

0 comments on commit fa079b5

Please sign in to comment.