Skip to content

Commit

Permalink
use mtt for testing (#113)
Browse files Browse the repository at this point in the history
* use `mtt` for testing

* fix modname typo

---------

Co-authored-by: BuckarooBanzay <[email protected]>
  • Loading branch information
BuckarooBanzay and BuckarooBanzay authored Apr 21, 2024
1 parent 0cc652e commit 9b36a7a
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 130 deletions.
14 changes: 0 additions & 14 deletions .github/workflows/integration-test.yml

This file was deleted.

15 changes: 15 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: test

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: buckaroobanzay/mtt@main
with:
modname: jumpdrive
git_dependencies: |
https://github.com/minetest-mods/areas.git
3 changes: 2 additions & 1 deletion .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ read_globals = {
"player_monoids",
"vizlib",
"mcl_sounds",
"mcl_formspec"
"mcl_formspec",
"mtt"
}
8 changes: 4 additions & 4 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jumpdrive = {
jumpdrive.sounds = {}

if minetest.get_modpath("default") then
jumpdrive.sounds = default
jumpdrive.sounds = default
end

if minetest.get_modpath("mcl_sounds") then
jumpdrive.sounds = mcl_sounds
jumpdrive.sounds = mcl_sounds
end

local MP = minetest.get_modpath("jumpdrive")
Expand Down Expand Up @@ -81,8 +81,8 @@ if minetest.get_modpath("monitoring") then
dofile(MP.."/metrics.lua")
end

if minetest.settings:get_bool("enable_jumpdrive_integration_test") then
dofile(MP.."/integration_test.lua")
if minetest.get_modpath("mtt") and mtt.enabled then
dofile(MP.."/mtt.lua")
end

print("[OK] Jumpdrive")
27 changes: 0 additions & 27 deletions integration-test.sh

This file was deleted.

83 changes: 0 additions & 83 deletions integration_test.lua

This file was deleted.

3 changes: 2 additions & 1 deletion mod.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ player_monoids,
planet_mars,
vizlib,
mcl_sounds,
mcl_formspec
mcl_formspec,
mtt
"""
41 changes: 41 additions & 0 deletions mtt.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
local pos1 = { x=-50, y=-10, z=-50 }
local pos2 = { x=50, y=50, z=50 }

mtt.emerge_area(pos1, pos2)

mtt.register("basic move-test", function(callback)
local source_pos1 = { x=0, y=0, z=0 }
local source_pos2 = { x=5, y=5, z=5 }
local target_pos1 = { x=10, y=10, z=10 }
local target_pos2 = { x=15, y=15, z=15 }

minetest.get_voxel_manip(source_pos1, source_pos1)
local src_node = minetest.get_node(source_pos1)

areas:add("dummy", "landscape", source_pos1, source_pos2)
areas:save()

assert(not minetest.is_protected(source_pos1, "dummy"))
assert(minetest.is_protected(source_pos1, "dummy2"))

jumpdrive.move(source_pos1, source_pos2, target_pos1, target_pos2)

assert(not minetest.is_protected(source_pos1, "dummy"))
assert(not minetest.is_protected(source_pos1, "dummy2"))

assert(not minetest.is_protected(target_pos1, "dummy"))
assert(minetest.is_protected(target_pos1, "dummy2"))

minetest.get_voxel_manip(target_pos1, target_pos1)
local target_node = minetest.get_node(target_pos1)

if target_node.name ~= src_node.name then
error("moved node name does not match")
end

if target_node.param2 ~= src_node.param2 then
error("moved param2 does not match")
end

callback()
end)

0 comments on commit 9b36a7a

Please sign in to comment.