diff options
author | Brad King <brad.king@kitware.com> | 2023-09-12 12:03:45 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-09-12 12:03:42 (GMT) |
commit | 3a1f2b2051e4b298259f016acea59673502dcad5 (patch) | |
tree | 0612c9dd3670460aebc7f6f3bb4c9a785295bc8e | |
parent | bb3bdf45489125ddfc1be14b169607955ea8d798 (diff) | |
parent | 34d46acfc80eecb8c508f4fd787292fe8e68219f (diff) | |
download | CMake-3a1f2b2051e4b298259f016acea59673502dcad5.zip CMake-3a1f2b2051e4b298259f016acea59673502dcad5.tar.gz CMake-3a1f2b2051e4b298259f016acea59673502dcad5.tar.bz2 |
Merge topic 'runcmake-pwd'
34d46acfc8 Tests/RunCMake: Set $ENV{PWD} before each test
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !8795
-rw-r--r-- | Tests/RunCMake/RunCMake.cmake | 12 | ||||
-rw-r--r-- | Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake | 6 |
2 files changed, 12 insertions, 6 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") diff --git a/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake b/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake index 58a111a..12f004b 100644 --- a/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake +++ b/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake @@ -29,8 +29,6 @@ function (run_symlink_test case src bin src_from_bin bin_from_src) # Test running in binary directory. set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") - # Emulate a shell using this directory. - set(ENV{PWD} "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}") # Pass absolute path to the source tree, plain. set(RunCMake_TEST_VARIANT_DESCRIPTION " $abs/${name}/${src}") @@ -50,8 +48,6 @@ function (run_symlink_test case src bin src_from_bin bin_from_src) # Test running in source directory. set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_TEST_SOURCE_DIR}") - # Emulate a shell using this directory. - set(ENV{PWD} "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}") # Pass absolute path to the binary tree with -B. set(RunCMake_TEST_VARIANT_DESCRIPTION " -B $abs/${name}/${bin}") @@ -63,8 +59,6 @@ function (run_symlink_test case src bin src_from_bin bin_from_src) # Test running in another directory. set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_BINARY_DIR}/${name}") - # Emulate a shell using this directory. - set(ENV{PWD} "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}") # Pass absolute paths to the source and binary trees. set(RunCMake_TEST_VARIANT_DESCRIPTION " -S $abs/${name}/${src} -B $abs/${name}/${bin}") |