From: Travis Wrightsman Date: Fri, 18 Apr 2025 13:58:33 +0200 Subject: Add CMake flag to ignore Lua destructor test failure Forwarded: https://github.com/luanti-org/luanti/pull/16040 --- src/CMakeLists.txt | 6 ++++++ src/unittest/test_lua.cpp | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0813a11..c903232 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -492,6 +492,12 @@ if(ANDROID) list(APPEND common_SRCS porting_android.cpp) endif() +option(IGNORE_LUA_DESTRUCTOR_TEST_FAILURE "Ignore failures in Lua destructor test" FALSE) + +if(IGNORE_LUA_DESTRUCTOR_TEST_FAILURE) + add_compile_definitions(IGNORE_LUA_DESTRUCTOR_TEST_FAILURE) +endif() + if(BUILD_UNITTESTS) add_subdirectory(unittest) list(APPEND common_SRCS ${UNITTEST_SRCS}) diff --git a/src/unittest/test_lua.cpp b/src/unittest/test_lua.cpp index e32b66e..096224d 100644 --- a/src/unittest/test_lua.cpp +++ b/src/unittest/test_lua.cpp @@ -5,6 +5,7 @@ #include "test.h" #include "config.h" +#include "log.h" #include @@ -82,7 +83,13 @@ void TestLua::testLuaDestructors() }, &did_destruct); lua_close(L); +#ifdef IGNORE_LUA_DESTRUCTOR_TEST_FAILURE + if (!did_destruct) { + warningstream << "The Lua destructor test has failed and you have elected to ignore it. You should know what you're doing. Memory leaks, deadlocks, and other nasty things are possible." << std::endl; + } +#else UASSERT(did_destruct); +#endif } namespace {