Add Integration Test

This commit is contained in:
David Leal 2020-11-04 15:26:05 -06:00
parent 388f1c2853
commit f9348593aa
No known key found for this signature in database
GPG Key ID: 3C482B03FD220E68
4 changed files with 63 additions and 0 deletions

13
.github/workflows/integration-test.yml vendored Normal file
View File

@ -0,0 +1,13 @@
name: integration-test
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: integration-test
run: ./integration-test.sh

View File

@ -1,3 +1,8 @@
-- integration test
if minetest.settings:get_bool("technic_armor.enable_technic_armor_integration_test") then
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/integration_test.lua")
end
-- support for i18n
local S = minetest.get_translator("3d_armor")

20
integration-test.sh Normal file
View File

@ -0,0 +1,20 @@
#!/bin/sh
# simple integration test
CFG=/tmp/minetest.conf
MTDIR=/tmp/mt
WORLDDIR=${MTDIR}/worlds/world
cat <<EOF > ${CFG}
technic_armor.enable_technic_armor_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/technic_armor \
registry.gitlab.com/minetest/minetest/server:5.3.0
test -f ${WORLDDIR}/integration_test.json && exit 0 || exit 1

25
integration_test.lua Normal file
View File

@ -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)