diff options
author | Brad King <brad.king@kitware.com> | 2022-02-23 22:03:42 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-02-24 18:47:43 (GMT) |
commit | 6c971b5e936281cb3d9565332a07c116b183bbc6 (patch) | |
tree | b8b48dcdd24b51cc8a57403f98830d4536a18dc3 /Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake | |
parent | 0443bdb8d4c0734cfba7f2da51bece22678143ef (diff) | |
download | CMake-6c971b5e936281cb3d9565332a07c116b183bbc6.zip CMake-6c971b5e936281cb3d9565332a07c116b183bbc6.tar.gz CMake-6c971b5e936281cb3d9565332a07c116b183bbc6.tar.bz2 |
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`.
Diffstat (limited to 'Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake')
-rw-r--r-- | Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake b/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake index 3c3bc53..8c2ee04 100644 --- a/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake +++ b/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake @@ -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") |