Browse Source

Tests: Isolate test suite from user-wide configuration

Brad King 1 năm trước cách đây
mục cha
commit
a991a5019b
2 tập tin đã thay đổi với 7 bổ sung2 xóa
  1. 6 2
      Tests/CMakeLists.txt
  2. 1 0
      Tests/EnforceConfig.cmake.in

+ 6 - 2
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.

+ 1 - 0
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@