Skip to content

Commit 0f6e99a

Browse files
committed
Fix failing tests with newer LLVM
1 parent e4ea673 commit 0f6e99a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

tests/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ function(add_platform_definitions TARGET)
33
if(CMAKE_SYSTEM_NAME MATCHES "Emscripten")
44
target_compile_definitions(${TARGET} PRIVATE OUP_PLATFORM_WASM)
55
target_compile_definitions(${TARGET} PRIVATE OUP_COMPILER_EMSCRIPTEN)
6+
target_compile_definitions(${TARGET} PRIVATE OUP_COMPILER_LLVM)
67
elseif (APPLE)
78
target_compile_definitions(${TARGET} PRIVATE OUP_PLATFORM_OSX)
89
elseif (UNIX)
@@ -22,6 +23,7 @@ function(add_platform_definitions TARGET)
2223
target_compile_options(${TARGET} PRIVATE -Wall)
2324
target_compile_options(${TARGET} PRIVATE -Wextra)
2425
target_compile_options(${TARGET} PRIVATE -Werror)
26+
target_compile_definitions(${TARGET} PRIVATE OUP_COMPILER_LLVM)
2527
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
2628
target_compile_options(${TARGET} PRIVATE /W4)
2729
target_compile_options(${TARGET} PRIVATE /WX)

tests/runtime_tests_owner_construction.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,20 @@ TEMPLATE_LIST_TEST_CASE(
120120
if constexpr (eoft_allocates<TestType>) {
121121
fail_next_allocation{}, TestType{raw_ptr, deleter};
122122
} else {
123+
#if !defined(OUP_COMPILER_LLVM) || !defined(NDEBUG)
123124
REQUIRE_THROWS_AS(
124125
(fail_next_allocation{}, TestType{raw_ptr, deleter}), std::bad_alloc);
126+
#else
127+
// LLVM in Release mode is able to inline the allocation, bypassing our
128+
// custom allocator that fails...
129+
try {
130+
fail_next_allocation{}, TestType {
131+
raw_ptr, deleter
132+
}
133+
} catch (const std::bad_alloc&) {
134+
// If it does throw, good. Else, ignore it.
135+
}
136+
#endif
125137
}
126138
}
127139

0 commit comments

Comments
 (0)