From d0540c3a1c3b57194f9b6fc8ee151b57b0163840 Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 14 Dec 2021 00:21:34 +0100 Subject: [PATCH] add a setting to opt-in for selftests --- mods/MISC/mcl_selftests/init.lua | 7 ++++--- settingtypes.txt | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/mods/MISC/mcl_selftests/init.lua b/mods/MISC/mcl_selftests/init.lua index 9e0adae0..553ef3ae 100644 --- a/mods/MISC/mcl_selftests/init.lua +++ b/mods/MISC/mcl_selftests/init.lua @@ -85,8 +85,6 @@ local test_minetest_find_nodes_in_area_can_count = function(dtime) assert ( 0 == nodes_difference ) end -minetest.after( 0, test_minetest_find_nodes_in_area_can_count ) - local test_minetest_find_nodes_in_area_crash = function(dtime) -- And now for our feature presentation, where we call the -- function “minetest.find_nodes_in_area()” with a position @@ -110,4 +108,7 @@ local test_minetest_find_nodes_in_area_crash = function(dtime) -- That's all, folks! end -minetest.after( 0, test_minetest_find_nodes_in_area_crash ) +if minetest.settings:get_bool("mclRunSelftests") then + minetest.after( 0, test_minetest_find_nodes_in_area_can_count ) + minetest.after( 0, test_minetest_find_nodes_in_area_crash ) +end diff --git a/settingtypes.txt b/settingtypes.txt index 3f90c986..41327ab4 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -146,3 +146,6 @@ basic_pseudobiome_villages (Enables very basic, and experimental "pseudobiome-ba # If enabled, will run an LBM to fix the top 1/2 of double plants in mcimported worlds; defaults to true. fix_doubleplants (Mcimport double plant fixes) bool true + +# Run tests on startup, crash if they fail. Particularly useful for development. +mclRunSelftests (Run Selftests on Startup) bool false