Tests: Isolate tests from CTEST_USE_INSTRUMENTATION variable

Prevent CMake's own tests from gathering instrumentation data when
`CTEST_USE_INSTRUMENTATION` is enabled in the environment.

Fixes: #26916
This commit is contained in:
Martin Duffy
2025-08-06 17:18:20 -04:00
parent 2e05695b30
commit a97bb70bd9
2 changed files with 3 additions and 0 deletions

View File

@@ -36,6 +36,8 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/CheckSwift.cmake)
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")
set(TEST_INSTRUMENTATION_ENV_CODE "# Isolate tests from CTEST_USE_INSTRUMENTATION var
unset(ENV{CTEST_USE_INSTRUMENTATION})\n")
file(MAKE_DIRECTORY "${TEST_HOME}/.config/cmake")
# Fake a user home directory to avoid polluting the real one.

View File

@@ -45,3 +45,4 @@ set(ENV{CMAKE_MAXIMUM_RECURSION_DEPTH} 100)
@TEST_CONFIG_ENV_CODE@
@TEST_HOME_ENV_CODE@
@TEST_WARN_VS_CODE@
@TEST_INSTRUMENTATION_ENV_CODE@