mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-18 22:08:28 -05:00
Tests: Generalize RunCMake.SymlinkTrees implementation
Accept paths to the source and binary directories as arguments. Prepare to support more ways of passing the source and binary directories to `cmake`.
This commit is contained in:
@@ -1,19 +1,37 @@
|
||||
include(RunCMake)
|
||||
|
||||
function(run_symlink_test_case)
|
||||
file(REMOVE_RECURSE
|
||||
"${RunCMake_TEST_BINARY_DIR}/CMakeCache.txt"
|
||||
"${RunCMake_TEST_BINARY_DIR}/CMakeFiles"
|
||||
)
|
||||
run_cmake_with_options(${ARGN})
|
||||
endfunction()
|
||||
|
||||
# This function assumes that ``${RunCMake_BINARY_DIR}/${name}/source`` and
|
||||
# ``${RunCMake_BINARY_DIR}/${name}/binary`` are set up properly prior to
|
||||
# calling it.
|
||||
function (run_symlink_test name)
|
||||
function (run_symlink_test case src bin)
|
||||
string(REGEX REPLACE "-.*" "" name "${case}")
|
||||
set(RunCMake_TEST_NO_CLEAN TRUE)
|
||||
set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/${name}/${src}")
|
||||
set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${name}/${bin}")
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt"
|
||||
"${RunCMake_BINARY_DIR}/${name}/source/CMakeLists.txt"
|
||||
"${RunCMake_TEST_SOURCE_DIR}/CMakeLists.txt"
|
||||
COPYONLY)
|
||||
set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/${name}/source")
|
||||
set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${name}/binary")
|
||||
|
||||
# We explicitly pass the source directory argument for each case.
|
||||
set(RunCMake_TEST_NO_SOURCE_DIR 1)
|
||||
|
||||
# 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_BINARY_DIR}")
|
||||
run_cmake("${name}_symlinks")
|
||||
set(ENV{PWD} "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}")
|
||||
|
||||
# Pass absolute path to the source tree, plain.
|
||||
set(RunCMake_TEST_VARIANT_DESCRIPTION " $abs/${name}/${src}")
|
||||
run_symlink_test_case("${case}" "${RunCMake_TEST_SOURCE_DIR}")
|
||||
endfunction ()
|
||||
|
||||
# Create the following structure:
|
||||
@@ -21,12 +39,9 @@ endfunction ()
|
||||
# .../common_real/source
|
||||
# .../common_real/binary
|
||||
# .../common -> common_real
|
||||
#
|
||||
# In this case, CMake should act as if .../common *is* .../common_real for all
|
||||
# computations except ``REALPATH``. This supports the case where a system has
|
||||
# a stable *symlink*, but not a stable target for that symlink.
|
||||
file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/common_real")
|
||||
file(REMOVE "${RunCMake_BINARY_DIR}/common")
|
||||
file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/common_real/source")
|
||||
file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/common_real/binary")
|
||||
file(CREATE_LINK "common_real" "${RunCMake_BINARY_DIR}/common" SYMBOLIC)
|
||||
run_symlink_test(common)
|
||||
run_symlink_test(common-separate "source" "binary")
|
||||
|
||||
Reference in New Issue
Block a user