fix(testing): ensure mod validity in get_test_registrator
Check if the provided mod name is valid by iterating through the registered mod names before allowing test registration.
This commit is contained in:
parent
b40bbafd4c
commit
14860ab625
9
base.lua
9
base.lua
@ -44,6 +44,15 @@ local register_test = function(mod, name, func, opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
test_harness.get_test_registrator = function(mod)
|
test_harness.get_test_registrator = function(mod)
|
||||||
|
local modnames = minetest.get_modnames()
|
||||||
|
local is_mod = false
|
||||||
|
for i=1,#modnames do
|
||||||
|
if modnames[i]==mod then
|
||||||
|
is_mod=true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not is_mod then error("get_test_registrator given mod "..mod.." is not a mod.") end
|
||||||
return function(name, func, opts)
|
return function(name, func, opts)
|
||||||
register_test(mod, name, func, opts)
|
register_test(mod, name, func, opts)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user