File: Add-CMake-flag-to-ignore-Lua-destructor-test-failure.patch

package info (click to toggle)
luanti 5.10.0%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 44,212 kB
  • sloc: cpp: 235,338; java: 4,662; sh: 854; ansic: 450; xml: 335; python: 304; makefile: 39
file content (54 lines) | stat: -rw-r--r-- 1,551 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
From: Travis Wrightsman <travis@wrightsman.org>
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 c53c85f..98864dd 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -471,6 +471,12 @@ if(ANDROID)
 	set(common_SRCS ${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)
 	set(common_SRCS ${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 <stdexcept>
 
@@ -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 {