From d97e252372bf7d542a6aea74506ec9dd1c21effc Mon Sep 17 00:00:00 2001 From: Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com> Date: Sun, 6 Oct 2024 10:31:07 +0200 Subject: [PATCH] chore(base): refactor variable names for clarity Refactored loops to correctly count the number of mods in `tests_mod_list`. --- base.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/base.lua b/base.lua index a94c7a7..7322fa4 100644 --- a/base.lua +++ b/base.lua @@ -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)