diff options
-rw-r--r-- | Tests/CMakeLists.txt | 9 | ||||
-rw-r--r-- | Tests/EnforceConfig.cmake.in | 7 |
2 files changed, 10 insertions, 6 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index cc7f557..b51630d 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -13,6 +13,15 @@ MACRO(ADD_TEST_MACRO NAME COMMAND) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${NAME}") ENDMACRO(ADD_TEST_MACRO) +# Fake a user home directory to avoid polluting the real one. +IF(DEFINED ENV{HOME} AND NOT CTEST_NO_TEST_HOME) + SET(TEST_HOME "${CMake_BINARY_DIR}/Tests/CMakeFiles/TestHome") + FILE(MAKE_DIRECTORY "${TEST_HOME}") + FILE(WRITE "${TEST_HOME}/.cvspass" ":pserver:anoncvs@www.cmake.org:/cvsroot/KWSys A\n") + SET(TEST_HOME_ENV_CODE "# Fake a user home directory to avoid polluting the real one. +SET(ENV{HOME} \"${TEST_HOME}\")") +ENDIF() + # Make sure the 'testing' test gets a proper configuration. CONFIGURE_FILE(${CMake_SOURCE_DIR}/Tests/EnforceConfig.cmake.in ${CMake_BINARY_DIR}/Tests/EnforceConfig.cmake @ONLY) diff --git a/Tests/EnforceConfig.cmake.in b/Tests/EnforceConfig.cmake.in index 9a5f042..b2101f8 100644 --- a/Tests/EnforceConfig.cmake.in +++ b/Tests/EnforceConfig.cmake.in @@ -28,9 +28,4 @@ IF(NOT CTEST_CONFIGURATION_TYPE AND CONFIG_REQUIRED) MESSAGE("Guessing configuration ${CTEST_CONFIGURATION_TYPE}") ENDIF(NOT CTEST_CONFIGURATION_TYPE AND CONFIG_REQUIRED) -# Fake a user home directory to avoid polluting the real one. -IF(DEFINED ENV{HOME}) - SET(HOME "@CMake_BINARY_DIR@/Tests/CMakeFiles/TestHome") - FILE(MAKE_DIRECTORY "${HOME}") - SET(ENV{HOME} "${HOME}") -ENDIF(DEFINED ENV{HOME}) +@TEST_HOME_ENV_CODE@ |