refactor(base.lua): improve run_tests function logic
Refactor the run_tests function in base.lua to enhance its logic and readability. The changes ensure proper handling of the tests_state enumeration.
This commit is contained in:
parent
14860ab625
commit
199abfba88
9
base.lua
9
base.lua
@ -554,10 +554,14 @@ local run_tests = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
print("Server tests done, " .. failed .. " tests failed.")
|
print("Server tests done, " .. failed .. " tests failed.")
|
||||||
if minetest.settings:get_bool("test_harness_stop_server", true) and next(players_tests) == nil then
|
if minetest.settings:get_bool("test_harness_stop_server", true) and ( next(players_tests) == nil or tests_state == TESTS_STATE_ENUM.DONE) then
|
||||||
request_shutdown()
|
request_shutdown()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if tests_state == TESTS_STATE_ENUM.DONE then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- list of needed players
|
-- list of needed players
|
||||||
local players_table = {}
|
local players_table = {}
|
||||||
for _, t in ipairs(players_tests) do
|
for _, t in ipairs(players_tests) do
|
||||||
@ -591,13 +595,12 @@ local run_tests = function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player, timeout)
|
minetest.register_on_leaveplayer(function(player, timeout)
|
||||||
if tests_state ~= TESTS_STATE_ENUM.STARTED_PLAYERS then
|
if tests_state ~= TESTS_STATE_ENUM.STARTED_PLAYERS then return end
|
||||||
-- check that needed playernames is still in the list of connected players
|
-- check that needed playernames is still in the list of connected players
|
||||||
local connected_player_names = get_connected_player_names()
|
local connected_player_names = get_connected_player_names()
|
||||||
if not all_in_table(needed_playernames, connected_player_names) then
|
if not all_in_table(needed_playernames, connected_player_names) then
|
||||||
tests_state = TESTS_STATE_ENUM.STARTED
|
tests_state = TESTS_STATE_ENUM.STARTED
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user