Improve fake $HOME test isolation code
The commit "Fake $HOME to isolate tests from user" started setting $HOME in the CTest script environment. On some platforms tests depend on some local configuration in the home directory, such as the "cvs login" for KWSys in CTestTest3. In this commit we now construct a fake home dir during CMake config step and populate it with a .cvspass file needed by the test. We also check CTEST_NO_TEST_HOME to optionally disable the test home. See issue #9949.
This commit is contained in:
parent
0ae0780055
commit
1d6e7ed71f
|
@ -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)
|
||||
|
|
|
@ -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@
|
||||
|
|
Loading…
Reference in New Issue