update integration-tests, execute simple function / update to 5.3.0
This commit is contained in:
parent
9a498c45cb
commit
9d2dc4c918
@ -7,6 +7,7 @@ WORLDDIR=${MTDIR}/worlds/world
|
||||
|
||||
cat <<EOF > ${CFG}
|
||||
enable_epic_integration_test = true
|
||||
epic.log_executor = true
|
||||
EOF
|
||||
|
||||
mkdir -p ${WORLDDIR}
|
||||
@ -15,6 +16,6 @@ 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/epic \
|
||||
registry.gitlab.com/minetest/minetest/server:5.0.1
|
||||
registry.gitlab.com/minetest/minetest/server:5.3.0
|
||||
|
||||
test -f ${WORLDDIR}/integration_test.json && exit 0 || exit 1
|
||||
|
@ -1,25 +1,74 @@
|
||||
|
||||
minetest.log("warning", "[TEST] integration-test enabled!")
|
||||
|
||||
-- param0 == 0: execution in the X+ direction
|
||||
|
||||
local function stop_server(success)
|
||||
local data = minetest.write_json({ success = success }, 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
|
||||
|
||||
minetest.get_player_by_name = function(name)
|
||||
if name == "testuser" then
|
||||
return {
|
||||
get_player_name = function() return name end,
|
||||
hud_add = function() return 0 end,
|
||||
hud_change = function() end,
|
||||
hud_remove = function() end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
local sent_messages = {}
|
||||
minetest.chat_send_player = function(name, message)
|
||||
sent_messages[name] = message
|
||||
end
|
||||
|
||||
local function setup_simple(callback)
|
||||
minetest.set_node({ x=0, y=110, z=0 }, { name = "epic:epic" })
|
||||
local meta = minetest.get_meta({ x=0, y=110, z=0 })
|
||||
meta:set_string("owner", "admin")
|
||||
meta:set_string("name", "")
|
||||
meta:set_int("time", "600")
|
||||
meta:set_string("main_pos", minetest.pos_to_string({ x=2, y=0, z=0 }))
|
||||
|
||||
minetest.set_node({ x=2, y=110, z=0 }, { name = "epic:function" })
|
||||
|
||||
minetest.set_node({ x=3, y=110, z=0 }, { name = "epic:message" })
|
||||
meta = minetest.get_meta({ x=3, y=110, z=0 })
|
||||
meta:set_string("text", "test123")
|
||||
|
||||
epic.start("testuser", { x=0, y=110, z=0 })
|
||||
|
||||
minetest.after(2, function()
|
||||
assert(sent_messages["testuser"] == "test123")
|
||||
callback()
|
||||
end)
|
||||
end
|
||||
|
||||
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')
|
||||
local pos1 = { x=-50, y=100, z=-50}
|
||||
local pos2 = { x=50, y=150, z=50 }
|
||||
minetest.emerge_area(pos1, pos2, function(_, _, calls_remaining)
|
||||
if calls_remaining == 0 then
|
||||
setup_simple(stop_server)
|
||||
end
|
||||
file:close()
|
||||
end
|
||||
|
||||
minetest.log("warning", "[TEST] integration tests done!")
|
||||
minetest.request_shutdown("success")
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
Loading…
x
Reference in New Issue
Block a user