Tests: Add --build-and-test test case

Checks that giving an invalid build directory to
ctest --build-and-test will fail.
This commit is contained in:
Craig Scott 2018-03-04 21:30:35 +11:00
parent a865f0beb2
commit e654622aee
4 changed files with 17 additions and 0 deletions

View File

@ -1,3 +1,9 @@
include(RunCTest)
run_ctest(dirNotExist)
run_ctest(buildAndTestNoBuildDir
--build-and-test
${RunCMake_BINARY_DIR}/buildAndTestNoBuildDir
${RunCMake_BINARY_DIR}/buildAndTestNoBuildDir/CMakeLists.txt # Deliberately a file
--build-generator "${RunCMake_GENERATOR}"
)

View File

@ -0,0 +1,3 @@
if(EXISTS ${RunCMake_TEST_BINARY_DIR}/CMakeCache.txt)
set(RunCMake_TEST_FAILED "Default build dir ${RunCMake_TEST_BINARY_DIR} was used, should not have been")
endif()

View File

@ -0,0 +1 @@
^[^0][0-9]*$

View File

@ -0,0 +1,7 @@
# We want a single test that always passes. We should never actually get to
# configure with this file, so we use a successful configure-build-test
# sequence to denote failure of the test case.
include(CTest)
add_test(NAME willPass
COMMAND ${CMAKE_COMMAND} -E touch someFile.txt
)