Add integration test (based on 3D Armor's integration test) (#7)
* Add integration test (based from 3D Armor's... ...integration test). * Add Integration Test status badge * make the `integration-test.sh` file executable Co-authored-by: BuckarooBanzay <BuckarooBanzay@users.noreply.github.com>
This commit is contained in:
parent
f3e77cc744
commit
696548f6d3
14
.github/workflows/integration-test.yml
vendored
Normal file
14
.github/workflows/integration-test.yml
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
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
|
@ -1,6 +1,7 @@
|
||||
# TravelNet
|
||||
|
||||
![](https://github.com/mt-mods/travelnet/workflows/luacheck/badge.svg)
|
||||
[![Build status](https://github.com/mt-mods/travelnet/workflows/luacheck/badge.svg)](https://github.com/mt-mods/travelnet/actions?query=workflow%3Aluacheck)
|
||||
[![Integration test status](https://github.com/mt-mods/travelnet/workflows/integration-test/badge.svg)](https://github.com/mt-mods/travelnet/actions?query=workflow%3Aintegration-test)
|
||||
|
||||
How this works:
|
||||
|
||||
|
5
init.lua
5
init.lua
@ -85,6 +85,11 @@
|
||||
- target list is now centered if there are less than 9 targets
|
||||
--]]
|
||||
|
||||
-- integration test
|
||||
if minetest.settings:get_bool("travelnet.enable_travelnet_integration_test") then
|
||||
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/integration_test.lua")
|
||||
end
|
||||
|
||||
-- Required to save the travelnet data properly in all cases
|
||||
if not minetest.safe_file_write then
|
||||
error("[Mod travelnet] Your Minetest version is no longer supported. (version < 0.4.17)")
|
||||
|
20
integration-test.sh
Executable file
20
integration-test.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
# simple integration test
|
||||
|
||||
CFG=/tmp/minetest.conf
|
||||
MTDIR=/tmp/mt
|
||||
WORLDDIR=${MTDIR}/worlds/world
|
||||
|
||||
cat <<EOF > ${CFG}
|
||||
travelnet.enable_travelnet_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/travelnet \
|
||||
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
25
integration_test.lua
Normal 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)
|
Loading…
x
Reference in New Issue
Block a user