11# -*- cmake -*-
2+
3+ include_guard ()
4+
5+ if ( NOT LL_TESTS )
6+ return ()
7+ endif ()
8+
29include (00-Common)
310include (LLTestCommand)
411include (bugsplat)
@@ -26,15 +33,14 @@ MACRO(LL_ADD_PROJECT_UNIT_TESTS project sources)
2633 #project(UNITTEST_PROJECT_${project})
2734 # Setup includes, paths, etc
2835 set (alltest_SOURCE_FILES
29- ${CMAKE_SOURCE_DIR} /test /test .cpp
30- ${CMAKE_SOURCE_DIR} /test /lltut.cpp
3136 )
3237 set (alltest_DEP_TARGETS
3338 # needed by the test harness itself
3439 llcommon
3540 )
3641
3742 set (alltest_LIBRARIES
43+ lltut_runner_lib
3844 llcommon
3945 )
4046 if (NOT "${project} " STREQUAL "llmath" )
@@ -137,6 +143,7 @@ MACRO(LL_ADD_PROJECT_UNIT_TESTS project sources)
137143 # test binaries always need to be signed for local development
138144 set_target_properties (PROJECT_${project} _TEST_${name}
139145 PROPERTIES
146+ OSX_ARCHITECTURES ${LL_MACOS_TEST_ARCHITECTURE}
140147 XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-" )
141148 endif ()
142149
@@ -159,24 +166,15 @@ MACRO(LL_ADD_PROJECT_UNIT_TESTS project sources)
159166 endif ()
160167
161168 # Add test
162- add_custom_command (
163- OUTPUT ${TEST_OUTPUT }
169+ add_test (
170+ NAME PROJECT_ ${project} _TEST_ ${name }
164171 COMMAND ${TEST_SCRIPT_CMD}
165- DEPENDS PROJECT_${project} _TEST_${name}
166172 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
167173 )
168- # Why not add custom target and add POST_BUILD command?
169- # Slightly less uncertain behavior
170- # (OUTPUT commands run non-deterministically AFAIK) + poppy 2009-04-19
171- # > I did not use a post build step as I could not make it notify of a
172- # > failure after the first time you build and fail a test. - daveh 2009-04-20
174+
175+ add_dependencies (BUILD_TESTS PROJECT_${project} _TEST_${name} )
173176 list (APPEND ${project} _TEST_OUTPUT ${TEST_OUTPUT} )
174177 endforeach (source )
175-
176- # Add the test runner target per-project
177- # (replaces old _test_ok targets all over the place)
178- add_custom_target (${project} _tests ALL DEPENDS ${${project} _TEST_OUTPUT})
179- add_dependencies (${project} ${project} _tests)
180178ENDMACRO (LL_ADD_PROJECT_UNIT_TESTS)
181179
182180#*****************************************************************************
@@ -204,12 +202,11 @@ FUNCTION(LL_ADD_INTEGRATION_TEST
204202
205203 set (source_files
206204 tests/${testname} _test.cpp
207- ${CMAKE_SOURCE_DIR} /test /test .cpp
208- ${CMAKE_SOURCE_DIR} /test /lltut.cpp
209205 ${additional_source_files}
210206 )
211207
212208 set (libraries
209+ lltut_runner_lib
213210 ${library_dependencies}
214211 )
215212
@@ -239,6 +236,7 @@ FUNCTION(LL_ADD_INTEGRATION_TEST
239236 # test binaries always need to be signed for local development
240237 set_target_properties (INTEGRATION_TEST_${testname}
241238 PROPERTIES
239+ OSX_ARCHITECTURES ${LL_MACOS_TEST_ARCHITECTURE}
242240 XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-"
243241 BUILD_WITH_INSTALL_RPATH 1
244242 INSTALL_RPATH "@executable_path/Resources"
@@ -286,14 +284,9 @@ FUNCTION(LL_ADD_INTEGRATION_TEST
286284 message (STATUS "TEST_SCRIPT_CMD: ${TEST_SCRIPT_CMD} " )
287285 endif ()
288286
289- add_custom_command (
290- TARGET INTEGRATION_TEST_${testname}
291- POST_BUILD
292- COMMAND ${TEST_SCRIPT_CMD}
293- )
287+ add_test (NAME INTEGRATION_TEST_RUNNER_${testname} COMMAND ${TEST_SCRIPT_CMD} )
294288
295- # Use CTEST? Not sure how to yet...
296- # ADD_TEST(INTEGRATION_TEST_RUNNER_${testname} ${TEST_SCRIPT_CMD})
289+ add_dependencies (BUILD_TESTS INTEGRATION_TEST_${testname} )
297290
298291ENDFUNCTION (LL_ADD_INTEGRATION_TEST)
299292
0 commit comments