summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/RunCMake.cmake
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2023-09-11 20:50:59 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2023-09-11 20:58:14 (GMT)
commit34d46acfc80eecb8c508f4fd787292fe8e68219f (patch)
treeedac6cb6d4ce5b159a1414823a98679a28d99ac9 /Tests/RunCMake/RunCMake.cmake
parenta273b7f5d4e68df5b1cbc20243491ff23f5d353c (diff)
downloadCMake-34d46acfc80eecb8c508f4fd787292fe8e68219f.zip
CMake-34d46acfc80eecb8c508f4fd787292fe8e68219f.tar.gz
CMake-34d46acfc80eecb8c508f4fd787292fe8e68219f.tar.bz2
Tests/RunCMake: Set $ENV{PWD} before each test
This will more accurately emulate how a shell would run CMake. Also, don't set $ENV{PWD} in Tests/RunCMake/SymlinkTrees, since RunCMake is now already doing this.
Diffstat (limited to 'Tests/RunCMake/RunCMake.cmake')
-rw-r--r--Tests/RunCMake/RunCMake.cmake12
1 files changed, 12 insertions, 0 deletions
diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake
index bc4a330..3e5ddc5 100644
--- a/Tests/RunCMake/RunCMake.cmake
+++ b/Tests/RunCMake/RunCMake.cmake
@@ -145,7 +145,19 @@ function(run_cmake test)
${maybe_timeout}
${maybe_input_file}
)]])
+ if(DEFINED ENV{PWD})
+ set(old_pwd "$ENV{PWD}")
+ else()
+ set(old_pwd)
+ endif()
+ # Emulate a shell using this directory.
+ set(ENV{PWD} "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}")
cmake_language(EVAL CODE "${_code}")
+ if(DEFINED old_pwd)
+ set(ENV{PWD} "${old_pwd}")
+ else()
+ set(ENV{PWD})
+ endif()
set(msg "")
if(NOT "${actual_result}" MATCHES "${expect_result}")
string(APPEND msg "Result is [${actual_result}], not [${expect_result}].\n")