Skip to content

Commit 5e7a8b1

Browse files
committed
Add tests only if they are built and can therefore be run
1 parent 9ecdcdd commit 5e7a8b1

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

tests/CMakeLists.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
set(TEST_DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data)
22

3+
# common CMake macro for linuxdeploy, adding tests only if they are supposed to be built
4+
# otherwise if you try to run CTest the tests aren't build and CTest can't find them
5+
if(NOT COMMAND ld_add_test)
6+
function(ld_add_test TARGET_NAME)
7+
get_target_property(${TARGET_NAME}_EFA ${TARGET_NAME} EXCLUDE_FROM_ALL)
8+
if(NOT ${${TARGET_NAME}_EXCLUDE_FROM_ALL})
9+
message(STATUS "[${PROJECT_NAME}] Adding test ${TARGET_NAME}")
10+
add_test(${TARGET_NAME} ${TARGET_NAME})
11+
else()
12+
message(STATUS "[${PROJECT_NAME}] Test ${TARGET_NAME} is excluded from ALL, not adding as test")
13+
endif()
14+
endfunction()
15+
endif()
16+
317
# build a single test binary
418
add_executable(test_desktopfile
519
test_desktopfile.cpp
@@ -16,4 +30,4 @@ set_property(TARGET test_desktopfile
1630
PROPERTY COMPILE_FLAGS "-DDESKTOP_FILE_PATH=\\\"${TEST_DATA_DIR}/simple_app.desktop\\\""
1731
)
1832

19-
add_test(test_desktopfile test_desktopfile)
33+
ld_add_test(test_desktopfile test_desktopfile)

0 commit comments

Comments
 (0)