summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorTushar Maheshwari <tushar27192@gmail.com>2019-01-13 15:35:58 (GMT)
committerBrad King <brad.king@kitware.com>2019-01-16 15:03:35 (GMT)
commit593d986470ce1938436da312e0c93e3c9c07017e (patch)
treef78599c68b48b99f1e2397a6062e500d2aabc64d /Tests
parent9a3d85cfc501fe3c1655e4a6ae9fd08fd9a1fbb7 (diff)
downloadCMake-593d986470ce1938436da312e0c93e3c9c07017e.zip
CMake-593d986470ce1938436da312e0c93e3c9c07017e.tar.gz
CMake-593d986470ce1938436da312e0c93e3c9c07017e.tar.bz2
Tests: Avoid cross-device links in CREATE_LINK test
Add a test for COPY_ON_ERROR to cover that scenario.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/file/CREATE_LINK-COPY_ON_ERROR.cmake11
-rw-r--r--Tests/RunCMake/file/CREATE_LINK.cmake9
-rw-r--r--Tests/RunCMake/file/RunCMakeTest.cmake1
3 files changed, 20 insertions, 1 deletions
diff --git a/Tests/RunCMake/file/CREATE_LINK-COPY_ON_ERROR.cmake b/Tests/RunCMake/file/CREATE_LINK-COPY_ON_ERROR.cmake
new file mode 100644
index 0000000..777ef4e
--- /dev/null
+++ b/Tests/RunCMake/file/CREATE_LINK-COPY_ON_ERROR.cmake
@@ -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()
diff --git a/Tests/RunCMake/file/CREATE_LINK.cmake b/Tests/RunCMake/file/CREATE_LINK.cmake
index b7c090e..ca61646 100644
--- a/Tests/RunCMake/file/CREATE_LINK.cmake
+++ b/Tests/RunCMake/file/CREATE_LINK.cmake
@@ -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()
diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake
index bbabddd..128e8f3 100644
--- a/Tests/RunCMake/file/RunCMakeTest.cmake
+++ b/Tests/RunCMake/file/RunCMakeTest.cmake
@@ -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)