Skip to content

Commit 9b36a7a

Browse files
use mtt for testing (#113)
* use `mtt` for testing * fix modname typo --------- Co-authored-by: BuckarooBanzay <[email protected]>
1 parent 0cc652e commit 9b36a7a

8 files changed

+64
-130
lines changed

.github/workflows/integration-test.yml

-14
This file was deleted.

.github/workflows/test.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- uses: buckaroobanzay/mtt@main
12+
with:
13+
modname: jumpdrive
14+
git_dependencies: |
15+
https://github.com/minetest-mods/areas.git

.luacheckrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ read_globals = {
3434
"player_monoids",
3535
"vizlib",
3636
"mcl_sounds",
37-
"mcl_formspec"
37+
"mcl_formspec",
38+
"mtt"
3839
}

init.lua

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ jumpdrive = {
2222
jumpdrive.sounds = {}
2323

2424
if minetest.get_modpath("default") then
25-
jumpdrive.sounds = default
25+
jumpdrive.sounds = default
2626
end
2727

2828
if minetest.get_modpath("mcl_sounds") then
29-
jumpdrive.sounds = mcl_sounds
29+
jumpdrive.sounds = mcl_sounds
3030
end
3131

3232
local MP = minetest.get_modpath("jumpdrive")
@@ -81,8 +81,8 @@ if minetest.get_modpath("monitoring") then
8181
dofile(MP.."/metrics.lua")
8282
end
8383

84-
if minetest.settings:get_bool("enable_jumpdrive_integration_test") then
85-
dofile(MP.."/integration_test.lua")
84+
if minetest.get_modpath("mtt") and mtt.enabled then
85+
dofile(MP.."/mtt.lua")
8686
end
8787

8888
print("[OK] Jumpdrive")

integration-test.sh

-27
This file was deleted.

integration_test.lua

-83
This file was deleted.

mod.conf

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ player_monoids,
2323
planet_mars,
2424
vizlib,
2525
mcl_sounds,
26-
mcl_formspec
26+
mcl_formspec,
27+
mtt
2728
"""

mtt.lua

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
local pos1 = { x=-50, y=-10, z=-50 }
2+
local pos2 = { x=50, y=50, z=50 }
3+
4+
mtt.emerge_area(pos1, pos2)
5+
6+
mtt.register("basic move-test", function(callback)
7+
local source_pos1 = { x=0, y=0, z=0 }
8+
local source_pos2 = { x=5, y=5, z=5 }
9+
local target_pos1 = { x=10, y=10, z=10 }
10+
local target_pos2 = { x=15, y=15, z=15 }
11+
12+
minetest.get_voxel_manip(source_pos1, source_pos1)
13+
local src_node = minetest.get_node(source_pos1)
14+
15+
areas:add("dummy", "landscape", source_pos1, source_pos2)
16+
areas:save()
17+
18+
assert(not minetest.is_protected(source_pos1, "dummy"))
19+
assert(minetest.is_protected(source_pos1, "dummy2"))
20+
21+
jumpdrive.move(source_pos1, source_pos2, target_pos1, target_pos2)
22+
23+
assert(not minetest.is_protected(source_pos1, "dummy"))
24+
assert(not minetest.is_protected(source_pos1, "dummy2"))
25+
26+
assert(not minetest.is_protected(target_pos1, "dummy"))
27+
assert(minetest.is_protected(target_pos1, "dummy2"))
28+
29+
minetest.get_voxel_manip(target_pos1, target_pos1)
30+
local target_node = minetest.get_node(target_pos1)
31+
32+
if target_node.name ~= src_node.name then
33+
error("moved node name does not match")
34+
end
35+
36+
if target_node.param2 ~= src_node.param2 then
37+
error("moved param2 does not match")
38+
end
39+
40+
callback()
41+
end)

0 commit comments

Comments
 (0)