Skip to content

Commit ea122a0

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

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,17 @@ TEMPLATE_LIST_TEST_CASE(
101101
if constexpr (eoft_allocates<TestType>) {
102102
fail_next_allocation{}, TestType{raw_ptr};
103103
} else {
104+
#if !defined(OUP_COMPILER_LLVM) || !defined(NDEBUG)
104105
REQUIRE_THROWS_AS((fail_next_allocation{}, TestType{raw_ptr}), std::bad_alloc);
106+
#else
107+
// LLVM in Release mode is able to inline the allocation, bypassing our
108+
// custom allocator that fails...
109+
try {
110+
fail_next_allocation{}, TestType{raw_ptr};
111+
} catch (const std::bad_alloc&) {
112+
// If it does throw, good. Else, ignore it.
113+
}
114+
#endif
105115
}
106116
}
107117

@@ -120,8 +130,18 @@ TEMPLATE_LIST_TEST_CASE(
120130
if constexpr (eoft_allocates<TestType>) {
121131
fail_next_allocation{}, TestType{raw_ptr, deleter};
122132
} else {
133+
#if !defined(OUP_COMPILER_LLVM) || !defined(NDEBUG)
123134
REQUIRE_THROWS_AS(
124135
(fail_next_allocation{}, TestType{raw_ptr, deleter}), std::bad_alloc);
136+
#else
137+
// LLVM in Release mode is able to inline the allocation, bypassing our
138+
// custom allocator that fails...
139+
try {
140+
fail_next_allocation{}, TestType{raw_ptr, deleter};
141+
} catch (const std::bad_alloc&) {
142+
// If it does throw, good. Else, ignore it.
143+
}
144+
#endif
125145
}
126146
}
127147

0 commit comments

Comments
 (0)