diff options
author | Johnny Jazeix <jazeix@gmail.com> | 2019-11-13 21:24:12 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2019-11-13 23:02:18 (GMT) |
commit | 5239fc5c753502e91a1ea6859842d7fc24a36253 (patch) | |
tree | cd4aceba4c5bcccce2d7f5fe298f21134e5fda77 /Tests | |
parent | 449fceeb1fd9619d9b01f8aed0e9e5784e10dacb (diff) | |
download | CMake-5239fc5c753502e91a1ea6859842d7fc24a36253.zip CMake-5239fc5c753502e91a1ea6859842d7fc24a36253.tar.gz CMake-5239fc5c753502e91a1ea6859842d7fc24a36253.tar.bz2 |
cmake -E: Add rm with improved semantics over remove and remove_directory
Diffstat (limited to 'Tests')
37 files changed, 134 insertions, 1 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 0a090a8..d4813b7 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -443,7 +443,7 @@ add_RunCMake_test(target_include_directories) add_RunCMake_test(target_sources) add_RunCMake_test(CheckModules) add_RunCMake_test(CheckIPOSupported) -add_RunCMake_test(CommandLine -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}) +add_RunCMake_test(CommandLine -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DCYGWIN=${CYGWIN}) add_RunCMake_test(CommandLineTar) if(CMAKE_PLATFORM_NO_VERSIONED_SONAME OR (NOT CMAKE_SHARED_LIBRARY_SONAME_FLAG AND NOT CMAKE_SHARED_LIBRARY_SONAME_C_FLAG)) diff --git a/Tests/RunCMake/CommandLine/E_rm_bad_argument-result.txt b/Tests/RunCMake/CommandLine/E_rm_bad_argument-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_bad_argument-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_rm_bad_argument-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_bad_argument-stderr.txt new file mode 100644 index 0000000..62b963a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_bad_argument-stderr.txt @@ -0,0 +1 @@ +^CMake Error: Unknown -E rm argument: -rd$ diff --git a/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-check.cmake new file mode 100644 index 0000000..b1a29a2 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-check.cmake @@ -0,0 +1,3 @@ +if(NOT EXISTS ${out}/dir/existing.txt) + set(RunCMake_TEST_FAILED "${out}/dir/existing.txt should exist (we only removed the link to dir folder)") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_empty_file_specified-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_empty_file_specified-stderr.txt new file mode 100644 index 0000000..1ac7dba --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_empty_file_specified-stderr.txt @@ -0,0 +1 @@ +^CMake Error: Missing file/directory to remove$ diff --git a/Tests/RunCMake/CommandLine/E_rm_empty_file_specified.cmake b/Tests/RunCMake/CommandLine/E_rm_empty_file_specified.cmake new file mode 100644 index 0000000..6cd4edd --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_empty_file_specified.cmake @@ -0,0 +1,8 @@ +execute_process( + COMMAND ${CMAKE_COMMAND} -E rm "" + RESULT_VARIABLE actual_result + ) + +if(NOT "${actual_result}" EQUAL "1") + message(SEND_ERROR "cmake -E rm \"\" should have returned 1, got ${actual_result}") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_file_force_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_file_force_existing-check.cmake new file mode 100644 index 0000000..e28b160 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_force_existing-check.cmake @@ -0,0 +1,3 @@ +if(EXISTS ${out}/existing.txt) + set(RunCMake_TEST_FAILED "${out}/existing.txt not removed") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_file_force_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_force_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_force_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_file_force_non_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_force_non_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_force_non_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_file_link_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_file_link_existing-check.cmake new file mode 100644 index 0000000..a0a9b20 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_link_existing-check.cmake @@ -0,0 +1,3 @@ +if(NOT EXISTS ${out}/existing.txt) + set(RunCMake_TEST_FAILED "${out}/existing.txt should exist (we only removed the link)") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_file_link_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_link_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_link_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_file_link_non_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_link_non_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_link_non_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-check.cmake new file mode 100644 index 0000000..e28b160 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-check.cmake @@ -0,0 +1,3 @@ +if(EXISTS ${out}/existing.txt) + set(RunCMake_TEST_FAILED "${out}/existing.txt not removed") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-stderr.txt new file mode 100644 index 0000000..05df88a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-stderr.txt @@ -0,0 +1 @@ +^CMake Error: File to remove does not exist and force is not set: .*/rm_tests/not_existing.txt diff --git a/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-check.cmake new file mode 100644 index 0000000..e28b160 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-check.cmake @@ -0,0 +1,3 @@ +if(EXISTS ${out}/existing.txt) + set(RunCMake_TEST_FAILED "${out}/existing.txt not removed") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-stderr.txt new file mode 100644 index 0000000..05df88a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-stderr.txt @@ -0,0 +1 @@ +^CMake Error: File to remove does not exist and force is not set: .*/rm_tests/not_existing.txt diff --git a/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-check.cmake b/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-check.cmake new file mode 100644 index 0000000..1a976cb --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-check.cmake @@ -0,0 +1,3 @@ +if(EXISTS ${out}) + set(RunCMake_TEST_FAILED "${out} not removed") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-result.txt b/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_force_recursive_non_existing_file-result.txt b/Tests/RunCMake/CommandLine/E_rm_force_recursive_non_existing_file-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_force_recursive_non_existing_file-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_no_file_specified-result.txt b/Tests/RunCMake/CommandLine/E_rm_no_file_specified-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_no_file_specified-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_rm_no_file_specified-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_no_file_specified-stderr.txt new file mode 100644 index 0000000..1ac7dba --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_no_file_specified-stderr.txt @@ -0,0 +1 @@ +^CMake Error: Missing file/directory to remove$ diff --git a/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-check.cmake b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-check.cmake new file mode 100644 index 0000000..609271e --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-check.cmake @@ -0,0 +1,3 @@ +if(NOT EXISTS ${out}/d1 OR NOT EXISTS ${out}/d2) + set(RunCMake_TEST_FAILED "${out}/d1 or ${out}/d2 is removed but should not") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-result.txt b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-stderr.txt new file mode 100644 index 0000000..33ea2e3 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-stderr.txt @@ -0,0 +1,2 @@ +^Error removing directory ".*/rm_tests/d1" without recursive option\. +Error removing directory ".*/rm_tests/d2" without recursive option\.$ diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-check.cmake b/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-check.cmake new file mode 100644 index 0000000..5282da7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-check.cmake @@ -0,0 +1,3 @@ +if(EXISTS ${out}/d1 OR EXISTS ${out}/d2) + set(RunCMake_TEST_FAILED "${out}/d1 or ${out}/d2 should be removed") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-result.txt b/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-check.cmake new file mode 100644 index 0000000..b1a29a2 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-check.cmake @@ -0,0 +1,3 @@ +if(NOT EXISTS ${out}/dir/existing.txt) + set(RunCMake_TEST_FAILED "${out}/dir/existing.txt should exist (we only removed the link to dir folder)") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-check.cmake new file mode 100644 index 0000000..a0a9b20 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-check.cmake @@ -0,0 +1,3 @@ +if(NOT EXISTS ${out}/existing.txt) + set(RunCMake_TEST_FAILED "${out}/existing.txt should exist (we only removed the link)") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_non_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_non_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_non_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index f903c3d..bd368cb 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -388,6 +388,76 @@ endif() unset(out) unset(outfile) +set(out ${RunCMake_BINARY_DIR}/rm_tests) +file(REMOVE_RECURSE "${out}") +file(MAKE_DIRECTORY ${out}) +file(TOUCH ${out}/existing.txt) +run_cmake_command(E_rm_file_force_existing + ${CMAKE_COMMAND} -E rm -f ${out}/existing.txt) +file(TOUCH ${out}/existing.txt) +run_cmake_command(E_rm_file_non_force_existing + ${CMAKE_COMMAND} -E rm ${out}/existing.txt) +run_cmake_command(E_rm_file_force_non_existing + ${CMAKE_COMMAND} -E rm -f ${out}/not_existing.txt) +run_cmake_command(E_rm_file_non_force_non_existing + ${CMAKE_COMMAND} -E rm ${out}/not_existing.txt) + +file(TOUCH ${out}/existing.txt) +run_cmake_command(E_rm_file_recursive_existing + ${CMAKE_COMMAND} -E rm -r ${out}/existing.txt) +run_cmake_command(E_rm_file_recursive_non_existing + ${CMAKE_COMMAND} -E rm -r ${out}/not_existing.txt) + +file(MAKE_DIRECTORY ${out}/d1 ${out}/d2) +run_cmake_command(E_rm_non_recursive_directory-two-directories + ${CMAKE_COMMAND} -E rm ${out}/d1 ${out}/d2) + +run_cmake_command(E_rm_recursive_directory-two-directories + ${CMAKE_COMMAND} -E rm -R ${out}/d1 ${out}/d2) + +run_cmake_command(E_rm_no_file_specified + ${CMAKE_COMMAND} -E rm -rf) + +run_cmake_command(E_rm_empty_file_specified + ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/E_rm_empty_file_specified.cmake) + +run_cmake_command(E_rm_bad_argument + ${CMAKE_COMMAND} -E rm -rd ${out}/d1 ${out}/d2) + +file(MAKE_DIRECTORY ${out}/d1 ${out}/d2) +file(WRITE ${out}/test.txt "") +run_cmake_command(E_rm_force_recursive_directory_with_files + ${CMAKE_COMMAND} -E rm -rf ${out}/) + +run_cmake_command(E_rm_force_recursive_non_existing_file + ${CMAKE_COMMAND} -E rm -Rf ${out}/test.txt) + +if(NOT WIN32 AND NOT CYGWIN) + file(MAKE_DIRECTORY ${out}) + file(TOUCH ${out}/existing.txt) + file(MAKE_DIRECTORY ${out}/dir) + file(TOUCH ${out}/dir/existing.txt) # add a file in the folder + file(CREATE_LINK ${out}/dir ${out}/link_dir SYMBOLIC) + file(CREATE_LINK ${out}/existing.txt ${out}/existing_file_link.txt SYMBOLIC) + file(CREATE_LINK ${out}/non_existing.txt ${out}/non_existing_file_link.txt SYMBOLIC) + run_cmake_command(E_rm_file_link_existing + ${CMAKE_COMMAND} -E rm ${out}/existing_file_link.txt) + run_cmake_command(E_rm_directory_link_existing + ${CMAKE_COMMAND} -E rm ${out}/link_dir) + run_cmake_command(E_rm_file_link_non_existing + ${CMAKE_COMMAND} -E rm ${out}/non_existing_file_link.txt) + + file(CREATE_LINK ${out}/dir ${out}/link_dir SYMBOLIC) + file(CREATE_LINK ${out}/existing.txt ${out}/existing_file_link.txt SYMBOLIC) + file(CREATE_LINK ${out}/non_existing.txt ${out}/non_existing_file_link.txt SYMBOLIC) + run_cmake_command(E_rm_recursive_file_link_existing + ${CMAKE_COMMAND} -E rm -R ${out}/existing_file_link.txt) + run_cmake_command(E_rm_recursive_directory_link_existing + ${CMAKE_COMMAND} -E rm -r ${out}/link_dir) + run_cmake_command(E_rm_recursive_file_link_non_existing + ${CMAKE_COMMAND} -E rm -r ${out}/non_existing_file_link.txt) +endif() +unset(out) run_cmake_command(E_env-no-command0 ${CMAKE_COMMAND} -E env) run_cmake_command(E_env-no-command1 ${CMAKE_COMMAND} -E env TEST_ENV=1) |