integration test
This commit is contained in:
parent
624c6919b0
commit
b7a6cd29d6
8
init.lua
8
init.lua
@ -15,3 +15,11 @@ end
|
||||
if minetest.get_modpath("travelnet") then
|
||||
dofile(MP.."/travelnet.lua")
|
||||
end
|
||||
|
||||
|
||||
if minetest.settings:get_bool("enable_integration_test") then
|
||||
dofile(MP.."/integration_test.lua")
|
||||
end
|
||||
|
||||
dofile(MP.."/stats.lua")
|
||||
|
||||
|
28
integration_test.lua
Normal file
28
integration_test.lua
Normal file
@ -0,0 +1,28 @@
|
||||
|
||||
minetest.log("warning", "[damocles_custom] integration-test enabled!")
|
||||
|
||||
minetest.register_on_mods_loaded(function()
|
||||
minetest.log("warning", "[damocles_custom] all mods loaded, starting delayed test-function")
|
||||
|
||||
minetest.after(1, function()
|
||||
minetest.log("warning", "[damocle_custom] starting integration test")
|
||||
|
||||
local data = minetest.write_json({ success = true }, true);
|
||||
local file = io.open(minetest.get_worldpath().."/integration_test.json", "w" );
|
||||
if file then
|
||||
file:write(data)
|
||||
file:close()
|
||||
end
|
||||
|
||||
file = io.open(minetest.get_worldpath().."/registered_nodes.txt", "w" );
|
||||
if file then
|
||||
for name in pairs(minetest.registered_nodes) do
|
||||
file:write(name .. '\n')
|
||||
end
|
||||
file:close()
|
||||
end
|
||||
|
||||
minetest.log("warning", "[damocles_custom] integration tests done!")
|
||||
minetest.request_shutdown("success")
|
||||
end)
|
||||
end)
|
14
stats.lua
Normal file
14
stats.lua
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
|
||||
-- https://stackoverflow.com/questions/2705793/how-to-get-number-of-entries-in-a-lua-table
|
||||
local function tablelength(T)
|
||||
local count = 0
|
||||
for _ in pairs(T) do count = count + 1 end
|
||||
return count
|
||||
end
|
||||
|
||||
minetest.after(5, function()
|
||||
print("Registered nodes: " .. tablelength(minetest.registered_nodes))
|
||||
print("Registered items: " .. tablelength(minetest.registered_items))
|
||||
print("Registered entities: " .. tablelength(minetest.registered_entities))
|
||||
end)
|
Loading…
x
Reference in New Issue
Block a user