Skip to content

Commit 20af8b3

Browse files
Do not show message dialog on debug assertion failures in the standalone tests on Windows CI. (#5306)
[SC-55089](https://app.shortcut.com/tiledb-inc/story/55089/do-not-show-message-dialog-on-debug-assertion-failures-in-the-standalone-tests-on-windows-ci) This PR replaces uses of the `Catch2::Catch2WithMain` CMake target with a new `tdb_Catch2WithMain`, that calls `_set_abort_behavior` to suppress showing a message dialog on debug assertion failures on Windows CI, extending what was done in #5305 for `tiledb_unit` to all other test executables. --- TYPE: NO_HISTORY
1 parent 5cee0ca commit 20af8b3

File tree

10 files changed

+69
-15
lines changed

10 files changed

+69
-15
lines changed

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,15 @@ target_include_directories(local_install INTERFACE ${CMAKE_SOURCE_DIR})
432432
# Enable testing
433433
enable_testing()
434434

435+
if(TILEDB_TESTS)
436+
# Add custom Catch2 entry point that suppresses message boxes on debug assertion
437+
# failures on Windows CI.
438+
find_package(Catch2 REQUIRED)
439+
add_library(tiledb_Catch2WithMain STATIC
440+
test/support/src/tdb_catch_main.cc)
441+
target_link_libraries(tiledb_Catch2WithMain PUBLIC Catch2::Catch2)
442+
endif()
443+
435444
# -------------------------------------------------------
436445
# Accumulators for object libraries and unit tests
437446
# -------------------------------------------------------

cmake/unit_test.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ macro(TileDB_Environment_unit_test_end)
167167
target_sources(${TileDB_Environment_unit_test_end_Unit_Test} PRIVATE ${TileDB_Environment_unit_test_end_Sources})
168168
# Catch2 is always a dependency of our unit tests
169169
find_package(Catch2 REQUIRED)
170-
target_link_libraries(${TileDB_Environment_unit_test_end_Unit_Test} PUBLIC Catch2::Catch2WithMain)
170+
target_link_libraries(${TileDB_Environment_unit_test_end_Unit_Test} PUBLIC tiledb_Catch2WithMain)
171171
foreach(Object_Library IN LISTS TileDB_Environment_unit_test_end_OL_Dependencies)
172172
target_link_libraries(${TileDB_Environment_unit_test_end_Unit_Test} PUBLIC ${Object_Library})
173173
endforeach()

experimental/tiledb/common/dag/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ macro (dag_add_header_only_unit_test TESTNAME)
6464
#
6565
# Required libraries
6666
#
67-
target_link_libraries(unit_${TESTNAME} PUBLIC Catch2::Catch2WithMain)
67+
target_link_libraries(unit_${TESTNAME} PUBLIC tiledb_Catch2WithMain)
6868
#
6969
# Define sources for test
7070
#

test/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
# THE SOFTWARE.
2727
#
2828

29-
find_package(Catch2 REQUIRED)
30-
3129
# Include TileDB core header directories
3230
set(TILEDB_CORE_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
3331
# Include the C API directory so that the C++ 'tiledb' file can directly
@@ -309,7 +307,7 @@ if (TILEDB_ARROW_TESTS)
309307
PUBLIC
310308
TILEDB_CORE_OBJECTS_ILIB
311309
TILEDB_CORE_OBJECTS
312-
Catch2::Catch2WithMain
310+
tiledb_Catch2WithMain
313311
pybind11::embed
314312
tiledb_test_support_lib
315313
configuration_definitions

test/ci/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
include(TileDBAssertions)
22

3-
find_package(Catch2 REQUIRED)
4-
53
add_executable(
64
test_assert
75
test_assert.cc
@@ -13,7 +11,7 @@ target_include_directories(test_assert
1311
Catch2::Catch2
1412
)
1513

16-
target_link_libraries(test_assert PUBLIC Catch2::Catch2WithMain)
14+
target_link_libraries(test_assert PUBLIC tiledb_Catch2WithMain)
1715

1816
if (TILEDB_ASSERTIONS)
1917
target_compile_definitions(

test/performance/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
# THE SOFTWARE.
2727
#
2828

29-
find_package(Catch2 REQUIRED)
30-
3129
# These options not exposed in bootstrap script.
3230
option(TILEDB_TESTS_AWS_S3_CONFIG "Use an S3 config appropriate for AWS in tests" OFF)
3331

@@ -74,7 +72,7 @@ target_include_directories(
7472
target_link_libraries(tiledb_explore_msys_handle_leakage
7573
PUBLIC
7674
TILEDB_CORE_OBJECTS_ILIB
77-
Catch2::Catch2WithMain
75+
tiledb_Catch2WithMain
7876
tiledb_test_support_lib
7977
)
8078

test/regression/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ endif()
7575

7676
target_link_libraries(tiledb_regression
7777
PUBLIC
78-
Catch2::Catch2WithMain
78+
tiledb_Catch2WithMain
7979
local_install
8080
tiledb
8181
)

test/support/src/tdb_catch_main.cc

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright Catch2 Authors
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// (See accompanying file LICENSE.txt or copy at
4+
// https://www.boost.org/LICENSE_1_0.txt)
5+
6+
// SPDX-License-Identifier: BSL-1.0
7+
#include <catch2/catch_session.hpp>
8+
#include <catch2/internal/catch_compiler_capabilities.hpp>
9+
#include <catch2/internal/catch_config_wchar.hpp>
10+
#include <catch2/internal/catch_leak_detector.hpp>
11+
#include <catch2/internal/catch_platform.hpp>
12+
13+
#include <cstdlib>
14+
15+
namespace Catch {
16+
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION
17+
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS
18+
static LeakDetector leakDetector;
19+
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
20+
} // namespace Catch
21+
22+
// Allow users of amalgamated .cpp file to remove our main and provide their
23+
// own.
24+
#if !defined(CATCH_AMALGAMATED_CUSTOM_MAIN)
25+
26+
#if defined(CATCH_CONFIG_WCHAR) && defined(CATCH_PLATFORM_WINDOWS) && \
27+
defined(_UNICODE) && !defined(DO_NOT_USE_WMAIN)
28+
// Standard C/C++ Win32 Unicode wmain entry point
29+
extern "C" int __cdecl wmain(int argc, wchar_t* argv[], wchar_t*[]) {
30+
#else
31+
// Standard C/C++ main entry point
32+
int main(int argc, char* argv[]) {
33+
#endif
34+
#if defined(_MSC_VER)
35+
// We disable the following events on abort in CI environments:
36+
// _WRITE_ABORT_MSG: Display message box with Abort, Retry, Ignore
37+
// _CALL_REPORTFAULT: Send an error report to Microsoft
38+
// The second parameter specifies which flags to change, and the first
39+
// the value of these flags.
40+
if (std::getenv("CI") != nullptr) {
41+
_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
42+
}
43+
#endif
44+
45+
// We want to force the linker not to discard the global variable
46+
// and its constructor, as it (optionally) registers leak detector
47+
(void)&Catch::leakDetector;
48+
49+
return Catch::Session().run(argc, argv);
50+
}
51+
52+
#endif // !defined(CATCH_AMALGAMATED_CUSTOM_MAIN

tiledb/api/c_api_support/handle/test/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
#
2626

2727
add_executable(unit_capi_handle EXCLUDE_FROM_ALL)
28-
find_package(Catch2 REQUIRED)
29-
target_link_libraries(unit_capi_handle PUBLIC Catch2::Catch2WithMain)
28+
target_link_libraries(unit_capi_handle PUBLIC tiledb_Catch2WithMain)
3029

3130
# Sources for code under test
3231
target_link_libraries(unit_capi_handle PUBLIC handle)

tiledb/common/governor/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if (FALSE AND TILEDB_TESTS) # reserved for later
3131
find_package(Catch2 REQUIRED)
3232

3333
add_executable(unit_governor EXCLUDE_FROM_ALL)
34-
target_link_libraries(unit_governor PUBLIC Catch2::Catch2WithMain)
34+
target_link_libraries(unit_governor PUBLIC tiledb_Catch2WithMain)
3535

3636
# Sources for code under test
3737
target_sources(unit_dynamic_memory PUBLIC

0 commit comments

Comments
 (0)