Skip to content

Commit 0ee4a14

Browse files
committed
CMake: carry over some nuances from autotools test config
Port more capabilities from Makefile.am: 1. test-specific compilation flags 2. support for lenient deadlines when running in the Swift CI 3. extended test suite (tests we disable because they occasionally fail) 4. list of not ported tests (Darwin-only functionality)
1 parent 698d085 commit 0ee4a14

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/CMakeLists.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ function(add_unit_test name)
7474
${CMAKE_CURRENT_BINARY_DIR}
7575
${CMAKE_CURRENT_SOURCE_DIR}
7676
${CMAKE_SOURCE_DIR})
77+
if(CMAKE_SWIFT_COMPILER)
78+
# For testing in swift.org CI system; make deadlines lenient by default
79+
# to reduce probability of test failures due to machine load.
80+
target_compile_options(${name} PRIVATE -DLENIENT_DEADLINES=1)
81+
endif()
7782
if(WITH_BLOCKS_RUNTIME)
7883
target_include_directories(${name}
7984
SYSTEM BEFORE PRIVATE
@@ -141,6 +146,34 @@ set(DISPATCH_C_TESTS
141146
set(DISPATCH_CPP_TESTS
142147
plusplus)
143148

149+
# Tests that usually pass, but occasionally fail
150+
# and are therefore not suitable for general CI usage.
151+
if(EXTENDED_TEST_SUITE)
152+
list(APPEND DISPATCH_C_TESTS
153+
priority
154+
concur
155+
read
156+
read2
157+
suspend_timer
158+
pingpong
159+
drift
160+
readsync
161+
cascade
162+
io)
163+
# an oddball; dispatch_priority.c compiled with -DUSE_SET_TARGET_QUEUE=1
164+
add_unit_test(dispatch_priority2 SOURCES dispatch_priority.c)
165+
target_compile_options(dispatch_priority2 PRIVATE -DUSE_SET_TARGET_QUEUE=1)
166+
endif()
167+
168+
# Tests for platform-specific functionality
169+
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
170+
list(APPEND DISPATCH_C_TESTS
171+
deadname
172+
proc
173+
vm
174+
vnode)
175+
endif()
176+
144177
foreach(test ${DISPATCH_C_TESTS})
145178
add_unit_test(dispatch_${test}
146179
SOURCES
@@ -151,6 +184,10 @@ foreach(test ${DISPATCH_CPP_TESTS})
151184
SOURCES
152185
dispatch_${test}.cpp)
153186
endforeach()
187+
188+
# test-specific link options
154189
target_link_libraries(dispatch_group PRIVATE m)
155190
target_link_libraries(dispatch_timer_short PRIVATE m)
156191

192+
# test-specific compile options
193+
target_compile_options(dispatch_c99 PRIVATE -std=c99)

0 commit comments

Comments
 (0)