diff options
author | Jon Chronopoulos <patches@crondog.com> | 2018-06-11 07:28:09 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-09-18 15:24:08 (GMT) |
commit | afb7f6e4ff8a0c1a68c8d8cf2d6cf72401cfb8ff (patch) | |
tree | f79c1b7cf4d0e408d3e0b98b06503b2e1cc7e5f8 /Tests | |
parent | 49cb2a504d1e00e51774a23bf1b91c982fa69e5d (diff) | |
download | CMake-afb7f6e4ff8a0c1a68c8d8cf2d6cf72401cfb8ff.zip CMake-afb7f6e4ff8a0c1a68c8d8cf2d6cf72401cfb8ff.tar.gz CMake-afb7f6e4ff8a0c1a68c8d8cf2d6cf72401cfb8ff.tar.bz2 |
cmake: Add '-E create_symlink' support on Windows
The allows `-E create_symlink` to work on Windows. It utilizes
`uv_fs_symlink`. I am still unsure exactly which Windows platforms will
work without requiring Administrator privileges or needing a user/group
with the "Create Symbolic Links" User Rights. It does work with my
Windows 10 Pro with Developer Mode turned on. In the test suite check
that the symlink either worked or failed with a permissions error.
Use recent changes in cmSystemTools::FileExists to check that a symlink
is broken.
Diffstat (limited to 'Tests')
3 files changed, 42 insertions, 31 deletions
diff --git a/Tests/RunCMake/CommandLine/E_create_symlink-broken-create-check.cmake b/Tests/RunCMake/CommandLine/E_create_symlink-broken-create-check.cmake index d7e652d..5df5f2f 100644 --- a/Tests/RunCMake/CommandLine/E_create_symlink-broken-create-check.cmake +++ b/Tests/RunCMake/CommandLine/E_create_symlink-broken-create-check.cmake @@ -1,6 +1,10 @@ -if(NOT IS_SYMLINK ${RunCMake_TEST_BINARY_DIR}/L) - set(RunCMake_TEST_FAILED "Symlink 'L' incorrectly not created!") -endif() -if(EXISTS ${RunCMake_TEST_BINARY_DIR}/L) - set(RunCMake_TEST_FAILED "Symlink 'L' not broken!") +if(${actual_stderr_var} MATCHES "operation not permitted") + unset(msg) +else() + if(NOT IS_SYMLINK ${RunCMake_TEST_BINARY_DIR}/L) + set(RunCMake_TEST_FAILED "Symlink 'L' incorrectly not created!") + endif() + if(EXISTS ${RunCMake_TEST_BINARY_DIR}/L) + set(RunCMake_TEST_FAILED "Symlink 'L' not broken!") + endif() endif() diff --git a/Tests/RunCMake/CommandLine/E_create_symlink-broken-replace-check.cmake b/Tests/RunCMake/CommandLine/E_create_symlink-broken-replace-check.cmake index c078ae8..d37df01 100644 --- a/Tests/RunCMake/CommandLine/E_create_symlink-broken-replace-check.cmake +++ b/Tests/RunCMake/CommandLine/E_create_symlink-broken-replace-check.cmake @@ -1,3 +1,7 @@ -if(NOT IS_DIRECTORY ${RunCMake_TEST_BINARY_DIR}/L) - set(RunCMake_TEST_FAILED "Symlink 'L' not replaced correctly!") +if(${actual_stderr_var} MATCHES "operation not permitted") + unset(msg) +else() + if(NOT IS_DIRECTORY ${RunCMake_TEST_BINARY_DIR}/L) + set(RunCMake_TEST_FAILED "Symlink 'L' not replaced correctly!") + endif() endif() diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index cef2b9b..5c80281 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -102,32 +102,35 @@ if(RunCMake_GENERATOR STREQUAL "Ninja") unset(RunCMake_TEST_NO_CLEAN) endif() -if(UNIX) - run_cmake_command(E_create_symlink-no-arg - ${CMAKE_COMMAND} -E create_symlink - ) - run_cmake_command(E_create_symlink-missing-dir - ${CMAKE_COMMAND} -E create_symlink T missing-dir/L - ) +run_cmake_command(E_create_symlink-no-arg + ${CMAKE_COMMAND} -E create_symlink + ) +run_cmake_command(E_create_symlink-missing-dir + ${CMAKE_COMMAND} -E create_symlink T missing-dir/L + ) - # Use a single build tree for a few tests without cleaning. - set(RunCMake_TEST_BINARY_DIR - ${RunCMake_BINARY_DIR}/E_create_symlink-broken-build) - set(RunCMake_TEST_NO_CLEAN 1) - file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") - run_cmake_command(E_create_symlink-broken-create - ${CMAKE_COMMAND} -E create_symlink T L - ) - run_cmake_command(E_create_symlink-broken-replace - ${CMAKE_COMMAND} -E create_symlink . L - ) - unset(RunCMake_TEST_BINARY_DIR) - unset(RunCMake_TEST_NO_CLEAN) +# Use a single build tree for a few tests without cleaning. +# These tests are special on Windows since it will only fail if the user +# running the test does not have the priveldge to create symlinks. If this +# happens we clear the msg in the -check.cmake and say that the test passes +set(RunCMake_DEFAULT_stderr "(operation not permitted)?") +set(RunCMake_TEST_BINARY_DIR + ${RunCMake_BINARY_DIR}/E_create_symlink-broken-build) +set(RunCMake_TEST_NO_CLEAN 1) +file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") +run_cmake_command(E_create_symlink-broken-create + ${CMAKE_COMMAND} -E create_symlink T L + ) +run_cmake_command(E_create_symlink-broken-replace + ${CMAKE_COMMAND} -E create_symlink . L + ) +unset(RunCMake_TEST_BINARY_DIR) +unset(RunCMake_TEST_NO_CLEAN) +unset(RunCMake_DEFAULT_stderr) - run_cmake_command(E_create_symlink-no-replace-dir - ${CMAKE_COMMAND} -E create_symlink T . - ) -endif() +run_cmake_command(E_create_symlink-no-replace-dir + ${CMAKE_COMMAND} -E create_symlink T . + ) set(in ${RunCMake_SOURCE_DIR}/copy_input) set(out ${RunCMake_BINARY_DIR}/copy_output) |