forked from mtcontrib/scifi_nodes
add integration-test
This commit is contained in:
parent
242dbde0e6
commit
6d6432940f
15
.github/workflows/integration-test.yml
vendored
Normal file
15
.github/workflows/integration-test.yml
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
name: integration-test
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: integration-test
|
||||
run: ./test/integration-test-standalone.sh
|
@ -3,6 +3,7 @@
|
||||
# scifi_nodes
|
||||
|
||||
![](https://github.com/D00Med/scifi_nodes/workflows/luacheck/badge.svg)
|
||||
![](https://github.com/D00Med/scifi_nodes/workflows/integration-test/badge.svg)
|
||||
|
||||
Minetest mod that adds scifi themed blocks, doors, materials, plants and other assets.
|
||||
|
||||
|
25
test/integration-test.sh
Executable file
25
test/integration-test.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
# Spins up a test world to ensure proper working recipes and registrations
|
||||
|
||||
CWD=$(dirname $0)
|
||||
cd ${CWD}/../
|
||||
|
||||
CFG=/tmp/minetest.conf
|
||||
MTDIR=/tmp/mt
|
||||
WORLDDIR=${MTDIR}/worlds/world
|
||||
|
||||
cat <<EOF > ${CFG}
|
||||
# empty
|
||||
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/scifi_nodes \
|
||||
-v $(pwd)/test/test_mod/:/var/lib/minetest/.minetest/worlds/world/worldmods/scifi_nodes_test \
|
||||
--network host \
|
||||
registry.gitlab.com/minetest/minetest/server:5.2.0
|
||||
|
||||
test -f ${WORLDDIR}/integration_test.json && exit 0 || exit 1
|
40
test/test_mod/init.lua
Normal file
40
test/test_mod/init.lua
Normal file
@ -0,0 +1,40 @@
|
||||
|
||||
minetest.log("warning", "[TEST] integration-test enabled!")
|
||||
|
||||
-- those mods have to be present
|
||||
local assert_mods = {
|
||||
"scifi_nodes"
|
||||
}
|
||||
|
||||
-- those nodes have to be present
|
||||
local assert_nodes = {
|
||||
"scifi_nodes:crate",
|
||||
"scifi_nodes:door1a"
|
||||
}
|
||||
|
||||
minetest.register_on_mods_loaded(function()
|
||||
minetest.after(0, function()
|
||||
-- check mods
|
||||
for _, modname in ipairs(assert_mods) do
|
||||
if not minetest.get_modpath(modname) then
|
||||
error("Mod not present: " .. modname)
|
||||
end
|
||||
end
|
||||
|
||||
-- check nodes
|
||||
for _, nodename in ipairs(assert_nodes) do
|
||||
if not minetest.registered_nodes[nodename] then
|
||||
error("Node not present: " .. nodename)
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
minetest.request_shutdown("success")
|
||||
|
||||
end)
|
||||
end)
|
2
test/test_mod/mod.conf
Normal file
2
test/test_mod/mod.conf
Normal file
@ -0,0 +1,2 @@
|
||||
name = scifi_nodes_test
|
||||
depends = scifi_nodes
|
Loading…
Reference in New Issue
Block a user