Tests: Update tests to run in symlinked tree

stage/master/nightly/2023/09/23
Kyle Edwards 2023-09-12 09:25:47 -04:00
parent 122ec98dcf
commit 59b0ae6b24
6 changed files with 40 additions and 19 deletions

View File

@ -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}")

View File

@ -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 ()

View File

@ -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")

View File

@ -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)

View File

@ -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()

View File

@ -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\"")