Skip to content

Commit

Permalink
add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay committed Jun 29, 2020
1 parent c59fa80 commit 2d9b84d
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 1 deletion.
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 @@ -27,3 +27,7 @@ dofile(MP .. "/delete.lua")
dofile(MP .. "/chat.lua")
dofile(MP .. "/globalstep.lua")
dofile(MP .. "/journal.lua")

if minetest.settings:get_bool("enable_mapcleaner_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_mapcleaner_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/mapcleaner \
registry.gitlab.com/minetest/minetest/server:5.2.0

test -f ${WORLDDIR}/integration_test.json && exit 0 || exit 1
34 changes: 34 additions & 0 deletions integration_test.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

minetest.log("warning", "[TEST] integration-test enabled!")

local function after_emerge()
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.log("warning", "[TEST] integration tests done!")
minetest.request_shutdown("success")
end

local function emerge()
minetest.emerge_area({
x = 0,
y = 0,
z = 0,
}, {
x = 120,
y = 120,
z = 120
}, function(_, _, calls_remaining)
if calls_remaining == 0 then
after_emerge()
end
end)
end

minetest.register_on_mods_loaded(function()
minetest.after(1, emerge)
end)
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ mapcleaner

A mod for [minetest](http://www.minetest.net)

![](https://github.com/thomasrudin-mt/mapcleaner/workflows/luacheck/badge.svg)
![](https://github.com/BuckarooBanzay/mapcleaner/workflows/luacheck/badge.svg)
![](https://github.com/BuckarooBanzay/mapcleaner/workflows/integration-test/badge.svg)

# Overview

Expand Down

0 comments on commit 2d9b84d

Please sign in to comment.