CTest does not support iOS
Set up
add_test
with no CONFIGURATIONS
directive (should apply to all configurations)
Behavior
When configuring a test for Ctest, the generated script for RUN_TESTS target invokes ctest with the following command
/usr/local/Cellar/cmake/3.9.4_1/bin/ctest --force-new-ctest-process -C $(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
When you add_test
with no CONFIGURATIONS
, then we see the following CTestTestfile.cmake is generated:
if("${CTEST_CONFIGURATION_TYPE}" MATCHES "^([Dd][Ee][Bb][Uu][Gg])$")
add_test(ctest-effective-platform-fail_run "/projects/ctest-effective-platform-fail/Debug\${EFFECTIVE_PLATFORM_NAME}/ctest-effective-platform-fail.app/ctest-effective-platform-fail")
elseif("${CTEST_CONFIGURATION_TYPE}" MATCHES "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$")
add_test(ctest-effective-platform-fail_run "/projects/ctest-effective-platform-fail/Release\${EFFECTIVE_PLATFORM_NAME}/ctest-effective-platform-fail.app/ctest-effective-platform-fail")
elseif("${CTEST_CONFIGURATION_TYPE}" MATCHES "^([Mm][Ii][Nn][Ss][Ii][Zz][Ee][Rr][Ee][Ll])$")
add_test(ctest-effective-platform-fail_run "/projects/ctest-effective-platform-fail/MinSizeRel\${EFFECTIVE_PLATFORM_NAME}/ctest-effective-platform-fail.app/ctest-effective-platform-fail")
elseif("${CTEST_CONFIGURATION_TYPE}" MATCHES "^([Rr][Ee][Ll][Ww][Ii][Tt][Hh][Dd][Ee][Bb][Ii][Nn][Ff][Oo])$")
add_test(ctest-effective-platform-fail_run "/projects/ctest-effective-platform-fail/RelWithDebInfo\${EFFECTIVE_PLATFORM_NAME}/ctest-effective-platform-fail.app/ctest-effective-platform-fail")
else()
add_test(ctest-effective-platform-fail_run NOT_AVAILABLE)
endif()
Minimal Example
ctest-effective-platform-fail.zip
Test Scenarios
-
Mac OS:
cmake . -GXcode
results in usableRUN_TESTS
target -
iOS
cmake . -GXcode -DCMAKE_TOOLCHAIN_FILE=toolchain-iOS.cmake
results in the following output forRUN_TESTS
PhaseScriptExecution CMake\ PostBuild\ Rules /projects/ctest-effective-platform-fail/ctest-effective-platform-fail.build/Debug-iphoneos/RUN_TESTS.build/Script-49697011BD03468499B21CCA.sh
cd /projects/ctest-effective-platform-fail/ctest-effective-platform-fail
/bin/sh -c /projects/ctest-effective-platform-fail/ctest-effective-platform-fail.build/Debug-iphoneos/RUN_TESTS.build/Script-49697011BD03468499B21CCA.sh
/usr/local/Cellar/cmake/3.9.4_1/bin/ctest --force-new-ctest-process -C Debug-iphoneos
Test project /projects/ctest-effective-platform-fail
Start 1: ctest-effective-platform-fail_run
Test not available in configuration "Debug-iphoneos".
1/1 Test #1: ctest-effective-platform-fail_run ...***Not Run 0.00 sec
0% tests passed, 1 tests failed out of 1
Total Test time (real) = 0.00 sec
The following tests FAILED:
1 - ctest-effective-platform-fail_run (Not Run)
Errors while running CTest
make: *** [RUN_TESTS_buildpart_0] Error 8
Command /bin/sh failed with exit code 2
Notice we do not set CMAKE_XCODE_EFFECTIVE_PLATFORMS
, it seems to be being generated automatically since Cmake 3.4
Environment
- Mac OS X 10.12.6
- Xcode 9.2
- Cmake 3.9.4
Edited by Gregor Jasny