mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 21:31:08 -06:00
Tests: Fake home directory even if not set
In some cases ENV{HOME} might not be set, e.g. when run through a systemd
service without User set.
We should still to fake HOME in such cases as some tests (e.g. FindPackageTest)
rely on it. We need only avoid setting ENV{CTEST_REAL_HOME} in such cases. Its
possible absence seems to already be handled by tests.
This commit is contained in:
@@ -25,14 +25,14 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/CheckFortran.cmake)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/CheckSwift.cmake)
|
||||
|
||||
# Fake a user home directory to avoid polluting the real one.
|
||||
if(DEFINED ENV{HOME} AND NOT CTEST_NO_TEST_HOME)
|
||||
if(NOT CTEST_NO_TEST_HOME AND (NOT WIN32 OR DEFINED ENV{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.
|
||||
# But provide original ENV{HOME} value in ENV{CTEST_REAL_HOME} for tests that
|
||||
# need access to the real HOME directory.
|
||||
if(NOT DEFINED ENV{CTEST_REAL_HOME})
|
||||
if(DEFINED ENV{HOME} AND NOT DEFINED ENV{CTEST_REAL_HOME})
|
||||
set(ENV{CTEST_REAL_HOME} \"\$ENV{HOME}\")
|
||||
endif()
|
||||
set(ENV{HOME} \"${TEST_HOME}\")
|
||||
|
||||
Reference in New Issue
Block a user