Tests: Avoid cross-device links in CREATE_LINK test
Add a test for COPY_ON_ERROR to cover that scenario.
This commit is contained in:
parent
9a3d85cfc5
commit
593d986470
11
Tests/RunCMake/file/CREATE_LINK-COPY_ON_ERROR.cmake
Normal file
11
Tests/RunCMake/file/CREATE_LINK-COPY_ON_ERROR.cmake
Normal file
@ -0,0 +1,11 @@
|
||||
# Use COPY_ON_ERROR to handle the case where the source and destination
|
||||
# directory are on different devices. Cross-device links are not permitted
|
||||
# and the following command falls back to copying the file if link fails.
|
||||
file(CREATE_LINK
|
||||
${CMAKE_CURRENT_LIST_FILE} TestCreateLink.cmake
|
||||
RESULT result
|
||||
COPY_ON_ERROR
|
||||
)
|
||||
if(NOT result STREQUAL "0")
|
||||
message(SEND_ERROR "COPY_ON_ERROR failed: '${result}'")
|
||||
endif()
|
@ -1,4 +1,11 @@
|
||||
file(CREATE_LINK ${CMAKE_CURRENT_LIST_FILE} TestLink.cmake RESULT result)
|
||||
# start with a file in the same directory to avoid cross-device links
|
||||
set(test_file ${CMAKE_CURRENT_BINARY_DIR}/CreateLinkTest.txt)
|
||||
file(TOUCH ${test_file})
|
||||
|
||||
file(CREATE_LINK
|
||||
${test_file} ${CMAKE_CURRENT_BINARY_DIR}/TestCreateLink.txt
|
||||
RESULT result
|
||||
)
|
||||
if(NOT result STREQUAL "0")
|
||||
message(SEND_ERROR "Hard link result='${result}'")
|
||||
endif()
|
||||
|
@ -1,6 +1,7 @@
|
||||
include(RunCMake)
|
||||
|
||||
run_cmake(CREATE_LINK)
|
||||
run_cmake(CREATE_LINK-COPY_ON_ERROR)
|
||||
run_cmake(CREATE_LINK-noarg)
|
||||
run_cmake(CREATE_LINK-noexist)
|
||||
run_cmake(DOWNLOAD-hash-mismatch)
|
||||
|
Loading…
Reference in New Issue
Block a user