Tests: added test for ctest_empty_binary_directory()
This commit is contained in:
parent
7a616e75b8
commit
9d9f102f53
|
@ -1942,6 +1942,17 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
|
||||||
set_tests_properties(CTestTestUpload PROPERTIES
|
set_tests_properties(CTestTestUpload PROPERTIES
|
||||||
PASS_REGULAR_EXPRESSION "Upload\\.xml")
|
PASS_REGULAR_EXPRESSION "Upload\\.xml")
|
||||||
|
|
||||||
|
configure_file(
|
||||||
|
"${CMake_SOURCE_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake.in"
|
||||||
|
"${CMake_BINARY_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake"
|
||||||
|
@ONLY ESCAPE_QUOTES)
|
||||||
|
add_test(CTestTestEmptyBinaryDirectory ${CMAKE_CTEST_COMMAND}
|
||||||
|
-S "${CMake_BINARY_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake" -V
|
||||||
|
--output-log "${CMake_BINARY_DIR}/Tests/CTestTestEmptyBinaryDirectory/testOut.log"
|
||||||
|
)
|
||||||
|
set_tests_properties(CTestTestEmptyBinaryDirectory PROPERTIES
|
||||||
|
PASS_REGULAR_EXPRESSION "TEST_SUCCESS")
|
||||||
|
|
||||||
configure_file(
|
configure_file(
|
||||||
"${CMake_SOURCE_DIR}/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in"
|
"${CMake_SOURCE_DIR}/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in"
|
||||||
"${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir1/test1.cmake"
|
"${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir1/test1.cmake"
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
cmake_minimum_required(VERSION 2.8.12)
|
||||||
|
|
||||||
|
set(CTEST_RUN_CURRENT_SCRIPT 0)
|
||||||
|
|
||||||
|
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestEmptyBinaryDirectory")
|
||||||
|
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestEmptyBinaryDirectory")
|
||||||
|
|
||||||
|
# make sure ctest does not remove directories without a CMakeCache.txt in it
|
||||||
|
set(EMPTY_BINARY_DIR "${CTEST_BINARY_DIRECTORY}/empty_binary_dir")
|
||||||
|
file(MAKE_DIRECTORY "${EMPTY_BINARY_DIR}")
|
||||||
|
|
||||||
|
if(NOT EXISTS "${EMPTY_BINARY_DIR}"
|
||||||
|
OR EXISTS "${EMPTY_BINARY_DIR}/CMakeCache.txt")
|
||||||
|
message(FATAL_ERROR "empty_binary_dir precondition failed")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
ctest_empty_binary_directory("${EMPTY_BINARY_DIR}")
|
||||||
|
|
||||||
|
if(NOT EXISTS "${EMPTY_BINARY_DIR}")
|
||||||
|
message(FATAL_ERROR "empty_binary_dir should not have been removed")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# make sure ctest does remove directories with a CMakeCache.txt
|
||||||
|
set(VALID_BINARY_DIR "${CTEST_BINARY_DIRECTORY}/valid_binary_dir")
|
||||||
|
file(MAKE_DIRECTORY "${VALID_BINARY_DIR}")
|
||||||
|
file(WRITE "${VALID_BINARY_DIR}/CMakeCache.txt")
|
||||||
|
|
||||||
|
if(NOT EXISTS "${VALID_BINARY_DIR}"
|
||||||
|
OR NOT EXISTS "${VALID_BINARY_DIR}/CMakeCache.txt")
|
||||||
|
message(FATAL_ERROR "valid_binary_dir precondition failed")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
ctest_empty_binary_directory("${VALID_BINARY_DIR}")
|
||||||
|
|
||||||
|
if(EXISTS "${VALID_BINARY_DIR}")
|
||||||
|
message(FATAL_ERROR "valid_binary_dir should have been removed")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# make sure ctest removes build directories recursively
|
||||||
|
set(DEEP_BINARY_DIR "${CTEST_BINARY_DIRECTORY}/deep_binary_dir")
|
||||||
|
file(MAKE_DIRECTORY "${DEEP_BINARY_DIR}")
|
||||||
|
file(WRITE "${DEEP_BINARY_DIR}/CMakeCache.txt")
|
||||||
|
|
||||||
|
foreach(SUBDIR A Z A/A A/Z Z/A Z/Z)
|
||||||
|
set(FULL_SUBDIR "${DEEP_BINARY_DIR}/${SUBDIR}")
|
||||||
|
file(MAKE_DIRECTORY "${FULL_SUBDIR}")
|
||||||
|
|
||||||
|
foreach(SUBFILE A.cpp Z.bat)
|
||||||
|
set(FULL_SUBFILE "${FULL_SUBDIR}/${SUBFILE}")
|
||||||
|
file(WRITE "${FULL_SUBFILE}" "I am '${FULL_SUBFILE}'")
|
||||||
|
endforeach()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if(NOT EXISTS "${DEEP_BINARY_DIR}"
|
||||||
|
OR NOT EXISTS "${DEEP_BINARY_DIR}/CMakeCache.txt"
|
||||||
|
OR NOT EXISTS "${DEEP_BINARY_DIR}/Z/A/Z.bat")
|
||||||
|
message(FATAL_ERROR "deep_binary_dir precondition failed")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
ctest_empty_binary_directory("${DEEP_BINARY_DIR}")
|
||||||
|
|
||||||
|
if(EXISTS "${DEEP_BINARY_DIR}")
|
||||||
|
message(FATAL_ERROR "deep_binary_dir should have been removed")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message("TEST_SUCCESS")
|
Loading…
Reference in New Issue