diff --git a/.gitattributes b/.gitattributes index 7306d8c..adcbd9a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,4 +2,5 @@ * text=auto # Exclusions for release export. -* export-ignore +.* export-ignore +tests.lua export-ignore diff --git a/init.lua b/init.lua index 07ff608..ef0cf9d 100644 --- a/init.lua +++ b/init.lua @@ -32,13 +32,17 @@ end dofile(path.."/misc.lua") -if minetest.is_singleplayer() then +-- Tests are not included in releases, so check for them before registering the command. + +local tests = loadfile(path.."/tests.lua") + +if tests and minetest.is_singleplayer() then minetest.register_chatcommand("fakelib_test", { description = "Test fakelib's API.", params = "[]", func = function(_, param) local start_time = minetest.get_us_time() - local success = loadfile(path.."/tests.lua")(param == "true") + local success = tests(param == "true") local end_time = minetest.get_us_time() if success then return true, string.format("Testing completed in %i us", end_time - start_time)