chore(base): refactor variable names for clarity

Refactored loops to correctly count the number of mods in `tests_mod_list`.
This commit is contained in:
Yves-Marie Haussonne 2024-10-06 10:31:07 +02:00
parent f8dbd2360a
commit d97e252372

View File

@ -13,8 +13,8 @@ local tests_context = {}
local tests_mod_list = {}
local test_mods_str = minetest.settings:get("test_harness_mods") or ""
for str in string.gmatch(test_mods_str, "[^,]+") do
local tests_mods_str = minetest.settings:get("test_harness_mods") or ""
for str in string.gmatch(tests_mods_str, "[^,]+") do
str = str:gsub("%s+", "")
tests_mod_list[str] = true
end
@ -61,7 +61,10 @@ test_harness.get_test_registrator = function(mod, version_string)
end
end
if not is_mod then error("get_test_registrator given mod "..mod.." is not a mod.") end
if #tests_mod_list == 0 or tests_mod_list[mod] then
-- count nb of mod in tests_mod_list
local tests_mod_list_size = 0
for _,_ in pairs(tests_mod_list) do tests_mod_list_size = tests_mod_list_size +1 end
if tests_mod_list_size ==0 or tests_mod_list[mod] then
set_context(mod, version_string)
return function(name, func, opts)
register_test_template(mod, name, func, opts)
@ -726,8 +729,6 @@ local run_tests = function()
minetest.settings:get("test_harness_test_players_password") or "test"))
end
print(test_harness.dump(players_tests))
-- launch test
test_harness.run_player_tests(players_tests, area)
end)