-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cpp/ci] added skeleton code for libpsyc functional tests
- Loading branch information
Showing
5 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
function(psyc_add_test) | ||
cmake_parse_arguments( | ||
PSYC_ADD_TEST | ||
"" | ||
"TARGET" | ||
"SOURCES" | ||
${ARGN} | ||
) | ||
|
||
# Add the test executable. | ||
add_executable(${PSYC_ADD_TEST_TARGET} | ||
${PSYC_ADD_TEST_SOURCES} | ||
) | ||
# All tests link against psyc. | ||
target_link_libraries(${PSYC_ADD_TEST_TARGET} PRIVATE libpsyc) | ||
# Note: CTest only runs test executables, doesn't build them. This is of course unfathomably stupid - You have to use "fixtures" (see: https://crascit.com/2016/10/18/test-fixtures-with-cmake-ctest/) | ||
# I'm just parroting what it says to do here. | ||
# Essentially: | ||
# 1. Add a test to simply run cmake --build to build the target. | ||
# 2. Set a "fixture" property on (1). | ||
# 3. Add a test to simply run the executable, this is normal CMake stuff. | ||
# 4. Set a fixture requirement on (3) against (2), causing it to essentially depend on building itself. | ||
# (1) | ||
add_test(${PSYC_ADD_TEST_TARGET}_build | ||
"${CMAKE_COMMAND}" | ||
--build "${CMAKE_BINARY_DIR}" | ||
--config "$<CONFIG>" | ||
--target ${PSYC_ADD_TEST_TARGET} | ||
) | ||
# (2) | ||
set_tests_properties(${PSYC_ADD_TEST_TARGET}_build PROPERTIES FIXTURES_SETUP ${PSYC_ADD_TEST_TARGET}_fixture) | ||
# (3) | ||
add_test(${PSYC_ADD_TEST_TARGET} ${PSYC_ADD_TEST_TARGET}) | ||
# (4) | ||
set_tests_properties(${PSYC_ADD_TEST_TARGET} PROPERTIES FIXTURES_REQUIRED ${PSYC_ADD_TEST_TARGET}_fixture) | ||
endfunction() | ||
|
||
# When top-level psyc CMakeLists includes CTest, this `BUILD_TESTING` option is created which defaults to ON. I guess the idea is that this is a cache variable you can turn off if you really want to. | ||
# Seems a bit silly to me, but we'll respect it anyway. | ||
if(BUILD_TESTING) | ||
add_subdirectory(functional_tests) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
psyc_add_test( | ||
TARGET type_coherency | ||
SOURCES | ||
type_coherency.cpp | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
int main() | ||
{ | ||
return 0; | ||
} |