Browse Source

add integration-test

pull/38/head
BuckarooBanzay 4 months ago
committed by Buckaroo Banzai
parent
commit
6d6432940f
5 changed files with 83 additions and 0 deletions
  1. +15
    -0
      .github/workflows/integration-test.yml
  2. +1
    -0
      README.md
  3. +25
    -0
      test/integration-test.sh
  4. +40
    -0
      test/test_mod/init.lua
  5. +2
    -0
      test/test_mod/mod.conf

+ 15
- 0
.github/workflows/integration-test.yml View 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

+ 1
- 0
README.md View File

@@ -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
- 0
test/integration-test.sh View 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
- 0
test/test_mod/init.lua View 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
- 0
test/test_mod/mod.conf View File

@@ -0,0 +1,2 @@
name = scifi_nodes_test
depends = scifi_nodes

Loading…
Cancel
Save