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:
parent
f8dbd2360a
commit
d97e252372
11
base.lua
11
base.lua
@ -13,8 +13,8 @@ local tests_context = {}
|
|||||||
|
|
||||||
local tests_mod_list = {}
|
local tests_mod_list = {}
|
||||||
|
|
||||||
local test_mods_str = minetest.settings:get("test_harness_mods") or ""
|
local tests_mods_str = minetest.settings:get("test_harness_mods") or ""
|
||||||
for str in string.gmatch(test_mods_str, "[^,]+") do
|
for str in string.gmatch(tests_mods_str, "[^,]+") do
|
||||||
str = str:gsub("%s+", "")
|
str = str:gsub("%s+", "")
|
||||||
tests_mod_list[str] = true
|
tests_mod_list[str] = true
|
||||||
end
|
end
|
||||||
@ -61,7 +61,10 @@ test_harness.get_test_registrator = function(mod, version_string)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not is_mod then error("get_test_registrator given mod "..mod.." is not a mod.") 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)
|
set_context(mod, version_string)
|
||||||
return function(name, func, opts)
|
return function(name, func, opts)
|
||||||
register_test_template(mod, 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"))
|
minetest.settings:get("test_harness_test_players_password") or "test"))
|
||||||
end
|
end
|
||||||
|
|
||||||
print(test_harness.dump(players_tests))
|
|
||||||
|
|
||||||
-- launch test
|
-- launch test
|
||||||
test_harness.run_player_tests(players_tests, area)
|
test_harness.run_player_tests(players_tests, area)
|
||||||
end)
|
end)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user