1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-09-15 18:57:08 +00:00

Fix node callbacks unit test

This commit is contained in:
sfan5 2024-02-24 00:53:22 +01:00
parent 9b97147637
commit 91ea47fddf
3 changed files with 22 additions and 13 deletions

View file

@ -108,9 +108,9 @@ local function wait_for_player(callback)
end)
end
local function wait_for_map(player, callback)
local function wait_for_map(pos, callback)
local function check()
if core.get_node_or_nil(player:get_pos()) ~= nil then
if core.get_node(pos).name ~= "ignore" then
callback()
else
core.after(0, check)
@ -119,8 +119,8 @@ local function wait_for_map(player, callback)
check()
end
-- This runs in a coroutine so it uses await()
function unittests.run_all()
-- This runs in a coroutine so it uses await().
local counters = { time = 0, total = 0, passed = 0 }
-- Run standalone tests first
@ -143,10 +143,11 @@ function unittests.run_all()
end
-- Wait for the world to generate/load, run tests that require map access
local pos = player:get_pos():round():offset(0, 5, 0)
core.forceload_block(pos, true, -1)
await(function(cb)
wait_for_map(player, cb)
wait_for_map(pos, cb)
end)
local pos = vector.round(player:get_pos())
for idx = 1, #unittests.list do
local def = unittests.list[idx]
if not def.done then