diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2023-09-11 20:50:59 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2023-09-11 20:58:14 (GMT) |
commit | 34d46acfc80eecb8c508f4fd787292fe8e68219f (patch) | |
tree | edac6cb6d4ce5b159a1414823a98679a28d99ac9 | |
parent | a273b7f5d4e68df5b1cbc20243491ff23f5d353c (diff) | |
download | CMake-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.
-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}") |