CPack test symlinks in package

This commit is contained in:
Domen Vrankar
2017-05-14 23:44:56 +02:00
parent 6949b71ff1
commit 2638406813
5 changed files with 59 additions and 0 deletions

View File

@@ -24,5 +24,6 @@ run_cpack_test_subtests(SINGLE_DEBUGINFO "no_main_component;one_component;one_co
run_cpack_test(EXTRA_SLASH_IN_PATH "RPM" true "COMPONENT")
run_cpack_source_test(SOURCE_PACKAGE "RPM")
run_cpack_test(SUGGESTS "RPM" false "MONOLITHIC")
run_cpack_test(SYMLINKS "RPM;TGZ" false "MONOLITHIC;COMPONENT")
run_cpack_test(USER_FILELIST "RPM" false "MONOLITHIC")
run_cpack_test(MD5SUMS "DEB" false "MONOLITHIC;COMPONENT")

View File

@@ -0,0 +1,13 @@
set(EXPECTED_FILES_COUNT "1")
set(EXPECTED_FILE_CONTENT_1_LIST
"/usr"
"/usr/empty_dir"
"/usr/non_empty_dir"
"/usr/non_empty_dir/CMakeLists.txt"
"/usr/symlink_to_empty_dir"
"/usr/symlink_to_non_empty_dir")
if(PACKAGING_TYPE STREQUAL "COMPONENT")
set(EXPECTED_FILE_1_COMPONENT "links")
endif()

View File

@@ -0,0 +1,5 @@
function(get_test_prerequirements found_var config_file)
if(UNIX) # limit test to platforms that support symlinks
set(${found_var} true PARENT_SCOPE)
endif()
endfunction()

View File

@@ -0,0 +1,26 @@
set(whitespaces "[\\t\\n\\r ]*")
#######################
# verify generated symbolic links
#######################
file(GLOB_RECURSE symlink_files RELATIVE "${bin_dir}" "${bin_dir}/*/symlink_*")
foreach(check_symlink IN LISTS symlink_files)
get_filename_component(symlink_name "${check_symlink}" NAME)
execute_process(COMMAND ls -la "${check_symlink}"
WORKING_DIRECTORY "${bin_dir}"
OUTPUT_VARIABLE SYMLINK_POINT_
OUTPUT_STRIP_TRAILING_WHITESPACE)
if("${symlink_name}" STREQUAL "symlink_to_empty_dir")
string(REGEX MATCH "^.*${whitespaces}->${whitespaces}empty_dir$" check_symlink "${SYMLINK_POINT_}")
elseif("${symlink_name}" STREQUAL "symlink_to_non_empty_dir")
string(REGEX MATCH "^.*${whitespaces}->${whitespaces}non_empty_dir$" check_symlink "${SYMLINK_POINT_}")
else()
message(FATAL_ERROR "error: unexpected rpm symbolic link '${check_symlink}'")
endif()
if(NOT check_symlink)
message(FATAL_ERROR "symlink points to unexpected location '${SYMLINK_POINT_}'")
endif()
endforeach()

View File

@@ -0,0 +1,14 @@
install(DIRECTORY DESTINATION empty_dir COMPONENT links)
install(FILES CMakeLists.txt DESTINATION non_empty_dir COMPONENT links)
# test symbolic link to an empty dir
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink empty_dir symlink_to_empty_dir)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/symlink_to_empty_dir DESTINATION "." COMPONENT links)
# test symbolic link to a non empty dir
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink non_empty_dir symlink_to_non_empty_dir)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/symlink_to_non_empty_dir DESTINATION "." COMPONENT links)
if(PACKAGING_TYPE STREQUAL "COMPONENT")
set(CPACK_COMPONENTS_ALL links)
endif()