diff options
author | Domen Vrankar <domen.vrankar@gmail.com> | 2016-11-27 14:30:46 (GMT) |
---|---|---|
committer | Domen Vrankar <domen.vrankar@gmail.com> | 2016-11-27 22:20:35 (GMT) |
commit | b687d2ba093b1b79e9faf09e45d11567b0ec9ac1 (patch) | |
tree | e71ea1d488d0e1130fa2f211bdabff0a322fc86b /Tests/RunCMake/CPack/TGZ/Helpers.cmake | |
parent | ed8858edb7c5100e1928c5a94f85485f0e322aa7 (diff) | |
download | CMake-b687d2ba093b1b79e9faf09e45d11567b0ec9ac1.zip CMake-b687d2ba093b1b79e9faf09e45d11567b0ec9ac1.tar.gz CMake-b687d2ba093b1b79e9faf09e45d11567b0ec9ac1.tar.bz2 |
Tests: CPack test use same content list
Content list for a certain test
should be the same between different
generators so whenever possible use
a single expected files list per
file for all generators.
Diffstat (limited to 'Tests/RunCMake/CPack/TGZ/Helpers.cmake')
-rw-r--r-- | Tests/RunCMake/CPack/TGZ/Helpers.cmake | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Tests/RunCMake/CPack/TGZ/Helpers.cmake b/Tests/RunCMake/CPack/TGZ/Helpers.cmake index 50fda9e..8715258 100644 --- a/Tests/RunCMake/CPack/TGZ/Helpers.cmake +++ b/Tests/RunCMake/CPack/TGZ/Helpers.cmake @@ -16,3 +16,41 @@ function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_V set(${RESULT_VAR} "${NAME}-${VERSION}-*${COMPONENT}.tar.gz" PARENT_SCOPE) endfunction() + +function(getPackageContentList FILE RESULT_VAR) + execute_process(COMMAND ${CMAKE_COMMAND} -E tar -ztf ${FILE} + OUTPUT_VARIABLE package_content_ + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + + string(REPLACE "\n" ";" package_content_ "${package_content_}") + foreach(i_ IN LISTS package_content_) + string(REGEX REPLACE "/$" "" result_ "${i_}") + list(APPEND items_ "${result_}") + endforeach() + + set(${RESULT_VAR} "${items_}" PARENT_SCOPE) +endfunction() + +function(toExpectedContentList FILE_NO CONTENT_VAR) + findExpectedFile("${FILE_NO}" "file_") + + get_filename_component(prefix_ "${file_}" NAME) + # NAME_WE removes everything after the dot and dot is in version so use this instead + string(REPLACE ".tar.gz" "" prefix_ "${prefix_}") + + if(NOT DEFINED TEST_MAIN_INSTALL_PREFIX_PATH) + set(TEST_MAIN_INSTALL_PREFIX_PATH "/usr") + endif() + + unset(filtered_) + foreach(part_ IN LISTS ${CONTENT_VAR}) + string(REPLACE "${TEST_MAIN_INSTALL_PREFIX_PATH}" "" part_ "${part_}") + + if(part_) + list(APPEND filtered_ "${prefix_}${part_}") + endif() + endforeach() + + set(${CONTENT_VAR} "${filtered_}" PARENT_SCOPE) +endfunction() |