diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2023-09-12 13:25:47 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2023-09-22 13:30:52 (GMT) |
commit | 59b0ae6b244d2def6a3cdd8bb96868b3b2c74ccb (patch) | |
tree | 4822bcc1a732097be7d761b45786aae205abb63c | |
parent | 122ec98dcfa273d17c2ae7ccacbaf3a47d14152c (diff) | |
download | CMake-59b0ae6b244d2def6a3cdd8bb96868b3b2c74ccb.zip CMake-59b0ae6b244d2def6a3cdd8bb96868b3b2c74ccb.tar.gz CMake-59b0ae6b244d2def6a3cdd8bb96868b3b2c74ccb.tar.bz2 |
Tests: Update tests to run in symlinked tree
-rw-r--r-- | Tests/CMakeGUI/CMakeGUITest.cmake | 11 | ||||
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/CMakePresets/GoodNoSCache.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake | 6 | ||||
-rw-r--r-- | Tests/RunCMake/XcFramework/find-library.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/file/REAL_PATH.cmake | 36 |
6 files changed, 40 insertions, 19 deletions
diff --git a/Tests/CMakeGUI/CMakeGUITest.cmake b/Tests/CMakeGUI/CMakeGUITest.cmake index 2c6baf3..9e2c8cc 100644 --- a/Tests/CMakeGUI/CMakeGUITest.cmake +++ b/Tests/CMakeGUI/CMakeGUITest.cmake @@ -59,6 +59,12 @@ function(run_cmake_gui_test name) set(ENV{CMake_GUI_TEST_NAME} "${name}") set(ENV{CMake_GUI_CONFIG_DIR} "${_workdir}/config") + if(DEFINED ENV{PWD}) + set(_old_pwd "$ENV{PWD}") + else() + set(_old_pwd) + endif() + set(ENV{PWD} "${_workdir}") execute_process( COMMAND "${CMakeGUITest_COMMAND}" ${_rcgt_ARGS} WORKING_DIRECTORY "${_workdir}" @@ -66,6 +72,11 @@ function(run_cmake_gui_test name) OUTPUT_VARIABLE _output ERROR_VARIABLE _error ) + if(DEFINED _old_pwd) + set(ENV{PWD} "${_old_pwd}") + else() + set(ENV{PWD}) + endif() if(_result) set(_fail 1) string(REPLACE "\n" "\n " _formatted_output "${_output}") diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 2eccb2a..56952e2 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -643,8 +643,10 @@ else() message(STATUS "Could not find ctresalloc") endif() +get_filename_component(real_binary_dir "${CMake_BINARY_DIR}" REALPATH) if(NOT WIN32 AND NOT MSYS # FIXME: This works on CYGWIN but not on MSYS + AND real_binary_dir STREQUAL CMake_BINARY_DIR ) add_RunCMake_test(SymlinkTrees) endif () diff --git a/Tests/RunCMake/CMakePresets/GoodNoSCache.cmake b/Tests/RunCMake/CMakePresets/GoodNoSCache.cmake index d9e399f..df58e72 100644 --- a/Tests/RunCMake/CMakePresets/GoodNoSCache.cmake +++ b/Tests/RunCMake/CMakePresets/GoodNoSCache.cmake @@ -1,5 +1,4 @@ include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) get_filename_component(_parent "${CMAKE_SOURCE_DIR}" DIRECTORY) -file(REAL_PATH "${_parent}" _parent) test_variable(CMAKE_BINARY_DIR "" "${_parent}/GoodNoSCachePrep-build") diff --git a/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake b/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake index 6847a23..f7959dc 100644 --- a/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake +++ b/Tests/RunCMake/DependencyGraph/RunCMakeTest.cmake @@ -1,7 +1,11 @@ include(RunCMake) function(check_files dir) - set(expected ${ARGN}) + set(expected) + foreach(i IN LISTS ARGN) + get_filename_component(real_path ${i} REALPATH) + list(APPEND expected ${real_path}) + endforeach() list(FILTER expected EXCLUDE REGEX "^$") list(REMOVE_DUPLICATES expected) list(SORT expected) diff --git a/Tests/RunCMake/XcFramework/find-library.cmake b/Tests/RunCMake/XcFramework/find-library.cmake index c5fe8db..1bc7672 100644 --- a/Tests/RunCMake/XcFramework/find-library.cmake +++ b/Tests/RunCMake/XcFramework/find-library.cmake @@ -1,5 +1,6 @@ find_library(MYLIB_XCFRAMEWORK mylib NO_DEFAULT_PATH PATHS "${CMAKE_BINARY_DIR}/../create-xcframework-framework-build") -file(REAL_PATH "${CMAKE_BINARY_DIR}/../create-xcframework-framework-build/mylib.xcframework" expected_path) +get_filename_component(bin_parent "${CMAKE_BINARY_DIR}" PATH) +set(expected_path "${bin_parent}/create-xcframework-framework-build/mylib.xcframework") if(NOT MYLIB_XCFRAMEWORK STREQUAL expected_path) message(FATAL_ERROR "Expected value of MYLIB_XCFRAMEWORK:\n ${expected_path}\nActual value:\n ${MYLIB_XCFRAMEWORK}") endif() diff --git a/Tests/RunCMake/file/REAL_PATH.cmake b/Tests/RunCMake/file/REAL_PATH.cmake index 08d400d..0485655 100644 --- a/Tests/RunCMake/file/REAL_PATH.cmake +++ b/Tests/RunCMake/file/REAL_PATH.cmake @@ -1,17 +1,19 @@ if (NOT WIN32 OR CYGWIN) + file(REAL_PATH "${CMAKE_CURRENT_BINARY_DIR}" real_binary_dir) + file(TOUCH "${CMAKE_CURRENT_BINARY_DIR}/test.txt") file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/test.sym") file(CREATE_LINK "test.txt" "${CMAKE_CURRENT_BINARY_DIR}/test.sym" SYMBOLIC) file(REAL_PATH "${CMAKE_CURRENT_BINARY_DIR}/test.sym" real_path) - if (NOT real_path STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/test.txt") - message(SEND_ERROR "real path is \"${real_path}\", should be \"${CMAKE_CURRENT_BINARY_DIR}/test.txt\"") + if (NOT real_path STREQUAL "${real_binary_dir}/test.txt") + message(SEND_ERROR "real path is \"${real_path}\", should be \"${real_binary_dir}/test.txt\"") endif() file(REAL_PATH "test.sym" real_path BASE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - if (NOT real_path STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/test.txt") - message(SEND_ERROR "real path is \"${real_path}\", should be \"${CMAKE_CURRENT_BINARY_DIR}/test.txt\"") + if (NOT real_path STREQUAL "${real_binary_dir}/test.txt") + message(SEND_ERROR "real path is \"${real_path}\", should be \"${real_binary_dir}/test.txt\"") endif() file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/dir/") @@ -21,33 +23,33 @@ if (NOT WIN32 OR CYGWIN) cmake_policy(SET CMP0152 NEW) file(REAL_PATH "${CMAKE_CURRENT_BINARY_DIR}/dir/bin/../" real_path) - if (NOT real_path STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/dir/nested") - message(SEND_ERROR "real path is \"${real_path}\", should be \"${CMAKE_CURRENT_BINARY_DIR}/dir/nested\"") + if (NOT real_path STREQUAL "${real_binary_dir}/dir/nested") + message(SEND_ERROR "real path is \"${real_path}\", should be \"${real_binary_dir}/dir/nested\"") endif() file(REAL_PATH "${CMAKE_CURRENT_BINARY_DIR}/dir/bin/../bin" real_path) - if (NOT real_path STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/dir/nested/bin") - message(SEND_ERROR "real path is \"${real_path}\", should be \"${CMAKE_CURRENT_BINARY_DIR}/dir/nested/bin\"") + if (NOT real_path STREQUAL "${real_binary_dir}/dir/nested/bin") + message(SEND_ERROR "real path is \"${real_path}\", should be \"${real_binary_dir}/dir/nested/bin\"") endif() file(REAL_PATH "dir/bin/../bin" real_path BASE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - if (NOT real_path STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/dir/nested/bin") - message(SEND_ERROR "real path is \"${real_path}\", should be \"${CMAKE_CURRENT_BINARY_DIR}/dir/nested/bin\"") + if (NOT real_path STREQUAL "${real_binary_dir}/dir/nested/bin") + message(SEND_ERROR "real path is \"${real_path}\", should be \"${real_binary_dir}/dir/nested/bin\"") endif() file(REAL_PATH "../bin" real_path BASE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/dir/bin/" ) - if (NOT real_path STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/dir/nested/bin") - message(SEND_ERROR "real path is \"${real_path}\", should be \"${CMAKE_CURRENT_BINARY_DIR}/dir/nested/bin\"") + if (NOT real_path STREQUAL "${real_binary_dir}/dir/nested/bin") + message(SEND_ERROR "real path is \"${real_path}\", should be \"${real_binary_dir}/dir/nested/bin\"") endif() cmake_policy(SET CMP0152 OLD) file(REAL_PATH "${CMAKE_CURRENT_BINARY_DIR}/dir/bin/../" real_path) - if (NOT real_path STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/dir") - message(SEND_ERROR "real path is \"${real_path}\", should be \"${CMAKE_CURRENT_BINARY_DIR}/dir/nested\"") + if (NOT real_path STREQUAL "${real_binary_dir}/dir") + message(SEND_ERROR "real path is \"${real_path}\", should be \"${real_binary_dir}/dir/nested\"") endif() file(REAL_PATH "../" real_path BASE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/dir/bin/") - if (NOT real_path STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/dir") - message(SEND_ERROR "real path is \"${real_path}\", should be \"${CMAKE_CURRENT_BINARY_DIR}/dir\"") + if (NOT real_path STREQUAL "${real_binary_dir}/dir") + message(SEND_ERROR "real path is \"${real_path}\", should be \"${real_binary_dir}/dir\"") endif() endif() @@ -61,12 +63,14 @@ If (WIN32) else() set(HOME_DIR "$ENV{HOME}") endif() +file(REAL_PATH "${HOME_DIR}" HOME_DIR) file(REAL_PATH "~" real_path EXPAND_TILDE) if (NOT real_path STREQUAL "${HOME_DIR}") message(SEND_ERROR "real path is \"${real_path}\", should be \"${HOME_DIR}\"") endif() +file(TOUCH "${HOME_DIR}/test.txt") file(REAL_PATH "~/test.txt" real_path EXPAND_TILDE) if (NOT real_path STREQUAL "${HOME_DIR}/test.txt") message(SEND_ERROR "real path is \"${real_path}\", should be \"${HOME_DIR}/test.txt\"") |