Skip to content

Commit faa6ecb

Browse files
committed
Merge branch 'dev'
2 parents 57d735a + fdcc896 commit faa6ecb

1 file changed

Lines changed: 54 additions & 45 deletions

File tree

tests/CMakeLists.txt

Lines changed: 54 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
cmake_minimum_required(VERSION 3.20)
22

3-
# Enable CTest
43
include(CTest)
54

65
if (BUILD_TESTING)
76
enable_testing()
87
endif()
98

10-
# Common test settings
9+
# --------------------------------------------------------------------
10+
# Target resolution
11+
# --------------------------------------------------------------------
1112
set(VIX_SYNC_TEST_TARGET vix::sync)
13+
1214
if (NOT TARGET ${VIX_SYNC_TEST_TARGET} AND TARGET vix_sync)
1315
set(VIX_SYNC_TEST_TARGET vix_sync)
1416
endif()
@@ -17,56 +19,63 @@ if (NOT TARGET ${VIX_SYNC_TEST_TARGET})
1719
message(FATAL_ERROR "[sync/tests] Missing sync target (expected vix::sync or vix_sync).")
1820
endif()
1921

20-
# Sync / Outbox smoke test
21-
add_executable(core_sync_smoke_test
22-
sync_engine_outbox_smoke_test.cpp
23-
)
24-
25-
target_link_libraries(core_sync_smoke_test PRIVATE
26-
${VIX_SYNC_TEST_TARGET}
27-
)
22+
# --------------------------------------------------------------------
23+
# Helpers
24+
# --------------------------------------------------------------------
25+
function(vix_sync_add_test test_name test_source)
26+
add_executable(${test_name}
27+
${test_source}
28+
)
2829

29-
target_compile_features(core_sync_smoke_test PRIVATE cxx_std_20)
30+
target_compile_features(${test_name}
31+
PRIVATE
32+
cxx_std_20
33+
)
3034

31-
if (BUILD_TESTING)
32-
add_test(
33-
NAME core_sync_smoke_test
34-
COMMAND core_sync_smoke_test
35+
target_link_libraries(${test_name}
36+
PRIVATE
37+
${VIX_SYNC_TEST_TARGET}
3538
)
36-
endif()
3739

38-
# Sync / Outbox permanent failure test (F1)
39-
add_executable(core_sync_permanent_fail_test
40-
sync_engine_outbox_permanent_fail_test.cpp
40+
if (TARGET vix_warnings)
41+
target_link_libraries(${test_name}
42+
PRIVATE
43+
vix_warnings
44+
)
45+
endif()
46+
47+
if (VIX_ENABLE_SANITIZERS AND NOT MSVC)
48+
target_compile_options(${test_name}
49+
PRIVATE
50+
-fno-omit-frame-pointer
51+
-fsanitize=address,undefined
52+
)
53+
54+
target_link_options(${test_name}
55+
PRIVATE
56+
-fsanitize=address,undefined
57+
)
58+
endif()
59+
60+
if (BUILD_TESTING)
61+
add_test(
62+
NAME ${test_name}
63+
COMMAND ${test_name}
64+
)
65+
endif()
66+
endfunction()
67+
68+
# --------------------------------------------------------------------
69+
# Tests
70+
# --------------------------------------------------------------------
71+
vix_sync_add_test(core_sync_smoke_test
72+
sync_engine_outbox_smoke_test.cpp
4173
)
4274

43-
target_link_libraries(core_sync_permanent_fail_test PRIVATE
44-
${VIX_SYNC_TEST_TARGET}
75+
vix_sync_add_test(core_sync_permanent_fail_test
76+
sync_engine_outbox_permanent_fail_test.cpp
4577
)
4678

47-
target_compile_features(core_sync_permanent_fail_test PRIVATE cxx_std_20)
48-
49-
if (BUILD_TESTING)
50-
add_test(
51-
NAME core_sync_permanent_fail_test
52-
COMMAND core_sync_permanent_fail_test
53-
)
54-
endif()
55-
56-
# Sync / Outbox in-flight timeout test
57-
add_executable(core_sync_inflight_timeout_test
79+
vix_sync_add_test(core_sync_inflight_timeout_test
5880
sync_engine_inflight_timeout_test.cpp
5981
)
60-
61-
target_link_libraries(core_sync_inflight_timeout_test PRIVATE
62-
${VIX_SYNC_TEST_TARGET}
63-
)
64-
65-
target_compile_features(core_sync_inflight_timeout_test PRIVATE cxx_std_20)
66-
67-
if (BUILD_TESTING)
68-
add_test(
69-
NAME core_sync_inflight_timeout_test
70-
COMMAND core_sync_inflight_timeout_test
71-
)
72-
endif()

0 commit comments

Comments
 (0)