summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-08-22 13:55:36 (GMT)
committerBrad King <brad.king@kitware.com>2024-08-22 13:59:35 (GMT)
commita991a5019b87ab7119b2e7b92434c8f006404519 (patch)
treed70697535febeee6eb7aec31b38b4a4c97316abf
parent320b81847d8b2cde41227deff68eb35448d7020f (diff)
downloadCMake-a991a5019b87ab7119b2e7b92434c8f006404519.zip
CMake-a991a5019b87ab7119b2e7b92434c8f006404519.tar.gz
CMake-a991a5019b87ab7119b2e7b92434c8f006404519.tar.bz2
Tests: Isolate test suite from user-wide configuration
-rw-r--r--Tests/CMakeLists.txt8
-rw-r--r--Tests/EnforceConfig.cmake.in1
2 files changed, 7 insertions, 2 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 8c459f0..a3a7589 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -32,10 +32,14 @@ endmacro()
include(${CMAKE_CURRENT_SOURCE_DIR}/CheckFortran.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/CheckSwift.cmake)
+# Isolate tests from user-wide configuration.
+set(TEST_HOME "${CMake_BINARY_DIR}/Tests/CMakeFiles/TestHome")
+set(TEST_CONFIG_ENV_CODE "# Isolate tests from user-wide configuration.
+set(ENV{CMAKE_CONFIG_DIR} \"${TEST_HOME}/.config/cmake\")\n")
+file(MAKE_DIRECTORY "${TEST_HOME}/.config/cmake")
+
# Fake a user home directory to avoid polluting the real one.
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}")
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.
diff --git a/Tests/EnforceConfig.cmake.in b/Tests/EnforceConfig.cmake.in
index a652efc..f151dfd 100644
--- a/Tests/EnforceConfig.cmake.in
+++ b/Tests/EnforceConfig.cmake.in
@@ -38,5 +38,6 @@ unset(ENV{CMAKE_EXPORT_COMPILE_COMMANDS})
# Verify that our module implementations do not recurse too much.
set(ENV{CMAKE_MAXIMUM_RECURSION_DEPTH} 100)
+@TEST_CONFIG_ENV_CODE@
@TEST_HOME_ENV_CODE@
@TEST_WARN_VS_CODE@