summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CPack
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/RunCMake/CPack')
-rw-r--r--Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake14
-rw-r--r--Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake15
-rw-r--r--Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake15
-rw-r--r--Tests/RunCMake/CPack/DEPENDENCIES.cmake18
-rw-r--r--Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake13
-rw-r--r--Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake45
-rw-r--r--Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake22
-rw-r--r--Tests/RunCMake/CPack/RunCMakeTest.cmake1
8 files changed, 143 insertions, 0 deletions
diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake
new file mode 100644
index 0000000..c56c670
--- /dev/null
+++ b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake
@@ -0,0 +1,14 @@
+set(whitespaces_ "[\t\n\r ]*")
+
+set(EXPECTED_FILES_COUNT "5")
+set(EXPECTED_FILE_1 "dependencies*-applications.deb")
+set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/test_prog$")
+set(EXPECTED_FILE_2 "dependencies*-applications_auto.deb")
+set(EXPECTED_FILE_CONTENT_2 "^.*/usr/foo_auto${whitespaces_}.*/usr/foo_auto/test_prog$")
+set(EXPECTED_FILE_3 "dependencies*-headers.deb")
+set(EXPECTED_FILE_CONTENT_3 "^.*/usr/bar${whitespaces_}.*/usr/bar/CMakeLists.txt$")
+set(EXPECTED_FILE_4 "dependencies*-libs.deb")
+# dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it
+set(EXPECTED_FILE_CONTENT_4 "^.*/usr/bas${whitespaces_}.*/usr/bas/libtest_lib\\..*$")
+set(EXPECTED_FILE_5 "dependencies*-libs_auto.deb")
+set(EXPECTED_FILE_CONTENT_5 "^.*/usr/bas_auto${whitespaces_}.*/usr/bas_auto/libtest_lib\\..*$")
diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake
new file mode 100644
index 0000000..44c862d
--- /dev/null
+++ b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake
@@ -0,0 +1,15 @@
+function(checkDepends_ FILE REGEX)
+ set(whitespaces_ "[\t\n\r ]*")
+
+ getPackageInfo("${FILE}" "FILE_INFO_")
+ if(NOT FILE_INFO_ MATCHES "${REGEX}")
+ message(FATAL_ERROR "Unexpected dependencies in '${FILE}'; file info: '${FILE_INFO_}'")
+ endif()
+endfunction()
+
+checkDepends_("${FOUND_FILE_1}" ".*Depends${whitespaces_}:${whitespaces_}depend-application, depend-application-b.*")
+# use wildcard as we are using dependency auto detection
+checkDepends_("${FOUND_FILE_2}" ".*Depends${whitespaces_}:${whitespaces_}.*depend-application, depend-application-b.*")
+checkDepends_("${FOUND_FILE_3}" ".*Depends${whitespaces_}:${whitespaces_}depend-headers.*")
+checkDepends_("${FOUND_FILE_4}" ".*Depends${whitespaces_}:${whitespaces_}depend-default, depend-default-b.*")
+checkDepends_("${FOUND_FILE_5}" ".*Depends${whitespaces_}:${whitespaces_}depend-default, depend-default-b.*")
diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake
new file mode 100644
index 0000000..9e09428
--- /dev/null
+++ b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake
@@ -0,0 +1,15 @@
+set(CPACK_PACKAGE_CONTACT "someone")
+set(CPACK_DEB_COMPONENT_INSTALL "ON")
+
+# false by default
+set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS FALSE)
+# FIXME can not be tested as libraries first have to be part of a package in order
+# to determine their dependencies and we can not be certain if there will be any
+set(CPACK_DEBIAN_APPLICATIONS_AUTO_PACKAGE_SHLIBDEPS TRUE)
+
+set(CPACK_DEBIAN_PACKAGE_DEPENDS "depend-default, depend-default-b")
+set(CPACK_DEBIAN_APPLICATIONS_PACKAGE_DEPENDS "depend-application, depend-application-b")
+set(CPACK_DEBIAN_APPLICATIONS_AUTO_PACKAGE_DEPENDS "depend-application, depend-application-b")
+set(CPACK_DEBIAN_HEADERS_PACKAGE_DEPENDS "depend-headers")
+
+# TODO add other dependency tests once CPackDeb supports them
diff --git a/Tests/RunCMake/CPack/DEPENDENCIES.cmake b/Tests/RunCMake/CPack/DEPENDENCIES.cmake
new file mode 100644
index 0000000..0aef925
--- /dev/null
+++ b/Tests/RunCMake/CPack/DEPENDENCIES.cmake
@@ -0,0 +1,18 @@
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp"
+ "int test_lib();")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp"
+ "#include \"test_lib.hpp\"\nint test_lib() {return 0;}")
+add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp")
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
+ "#include \"test_lib.hpp\"\nint main() {return test_lib();}")
+add_executable(test_prog "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
+target_link_libraries(test_prog test_lib)
+
+install(TARGETS test_prog DESTINATION foo COMPONENT applications)
+install(TARGETS test_prog DESTINATION foo_auto COMPONENT applications_auto)
+install(FILES CMakeLists.txt DESTINATION bar COMPONENT headers)
+install(TARGETS test_lib DESTINATION bas COMPONENT libs)
+install(TARGETS test_lib DESTINATION bas_auto COMPONENT libs_auto)
+
+set(CPACK_PACKAGE_NAME "dependencies")
diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake
new file mode 100644
index 0000000..cf85dab
--- /dev/null
+++ b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake
@@ -0,0 +1,13 @@
+set(whitespaces_ "[\t\n\r ]*")
+
+set(EXPECTED_FILES_COUNT "5")
+set(EXPECTED_FILE_1 "dependencies*-applications.rpm")
+set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/test_prog$")
+set(EXPECTED_FILE_2 "dependencies*-applications_auto.rpm")
+set(EXPECTED_FILE_CONTENT_2 "^/usr/foo_auto${whitespaces_}/usr/foo_auto/test_prog$")
+set(EXPECTED_FILE_3 "dependencies*-headers.rpm")
+set(EXPECTED_FILE_CONTENT_3 "^/usr/bar${whitespaces_}/usr/bar/CMakeLists.txt$")
+set(EXPECTED_FILE_4 "dependencies*-libs.rpm")
+set(EXPECTED_FILE_CONTENT_4 "^/usr/bas${whitespaces_}/usr/bas/libtest_lib.so$")
+set(EXPECTED_FILE_5 "dependencies*-libs_auto.rpm")
+set(EXPECTED_FILE_CONTENT_5 "^/usr/bas_auto${whitespaces_}/usr/bas_auto/libtest_lib.so$")
diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake
new file mode 100644
index 0000000..fec8889
--- /dev/null
+++ b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake
@@ -0,0 +1,45 @@
+function(checkDependencies_ FILE TYPE COMPARE_LIST)
+ set(whitespaces_ "[\t\n\r ]*")
+
+ execute_process(COMMAND ${RPM_EXECUTABLE} -qp --${TYPE} ${FILE}
+ WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
+ OUTPUT_VARIABLE FILE_DEPENDENCIES_
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ string(REPLACE "\n" ";" FILE_DEPENDENCIES_LIST_ "${FILE_DEPENDENCIES_}")
+
+ foreach(COMPARE_REGEX_ IN LISTS COMPARE_LIST)
+ unset(FOUND_)
+
+ foreach(COMPARE_ IN LISTS FILE_DEPENDENCIES_LIST_)
+ if(COMPARE_ MATCHES "${COMPARE_REGEX_}")
+ set(FOUND_ true)
+ break()
+ endif()
+ endforeach()
+
+ if(NOT FOUND_)
+ message(FATAL_ERROR "Missing dependencies in '${FILE}'; check type: '${TYPE}'; file info: '${FILE_DEPENDENCIES_}'; missing: '${COMPARE_REGEX_}'")
+ endif()
+ endforeach()
+endfunction()
+
+# TODO add tests for what should not be present in lists
+checkDependencies_("${FOUND_FILE_1}" "requires" "depend-application;depend-application-b")
+checkDependencies_("${FOUND_FILE_2}" "requires" "depend-application;depend-application-b;libtest_lib\\.so.*")
+checkDependencies_("${FOUND_FILE_3}" "requires" "depend-headers")
+checkDependencies_("${FOUND_FILE_4}" "requires" "depend-default;depend-default-b")
+checkDependencies_("${FOUND_FILE_5}" "requires" "depend-default;depend-default-b")
+
+checkDependencies_("${FOUND_FILE_1}" "conflicts" "conflict-application;conflict-application-b")
+checkDependencies_("${FOUND_FILE_2}" "conflicts" "conflict-application;conflict-application-b")
+checkDependencies_("${FOUND_FILE_3}" "conflicts" "conflict-headers")
+checkDependencies_("${FOUND_FILE_4}" "conflicts" "conflict-default;conflict-default-b")
+checkDependencies_("${FOUND_FILE_5}" "conflicts" "conflict-default;conflict-default-b")
+
+checkDependencies_("${FOUND_FILE_1}" "provides" "provided-default;provided-default-b")
+checkDependencies_("${FOUND_FILE_2}" "provides" "provided-default;provided-default-b")
+checkDependencies_("${FOUND_FILE_3}" "provides" "provided-default;provided-default-b")
+checkDependencies_("${FOUND_FILE_4}" "provides" "provided-lib")
+checkDependencies_("${FOUND_FILE_5}" "provides" "provided-lib_auto;provided-lib_auto-b")
diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake
new file mode 100644
index 0000000..2cdfece
--- /dev/null
+++ b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake
@@ -0,0 +1,22 @@
+set(CPACK_RPM_COMPONENT_INSTALL "ON")
+
+# FIXME auto autoprov is not tested at the moment as Ubuntu 15.04 rpmbuild
+# does not use them correctly: https://bugs.launchpad.net/rpm/+bug/1475755
+set(CPACK_RPM_PACKAGE_AUTOREQ "no")
+set(CPACK_RPM_PACKAGE_AUTOPROV "no")
+set(CPACK_RPM_applications_auto_PACKAGE_AUTOREQPROV "yes")
+set(CPACK_RPM_libs_auto_PACKAGE_AUTOREQPROV "yes")
+
+set(CPACK_RPM_PACKAGE_REQUIRES "depend-default, depend-default-b")
+set(CPACK_RPM_applications_PACKAGE_REQUIRES "depend-application, depend-application-b")
+set(CPACK_RPM_applications_auto_PACKAGE_REQUIRES "depend-application, depend-application-b")
+set(CPACK_RPM_headers_PACKAGE_REQUIRES "depend-headers")
+
+set(CPACK_RPM_PACKAGE_CONFLICTS "conflict-default, conflict-default-b")
+set(CPACK_RPM_applications_PACKAGE_CONFLICTS "conflict-application, conflict-application-b")
+set(CPACK_RPM_applications_auto_PACKAGE_CONFLICTS "conflict-application, conflict-application-b")
+set(CPACK_RPM_headers_PACKAGE_CONFLICTS "conflict-headers")
+
+set(CPACK_RPM_PACKAGE_PROVIDES "provided-default, provided-default-b")
+set(CPACK_RPM_libs_PACKAGE_PROVIDES "provided-lib")
+set(CPACK_RPM_libs_auto_PACKAGE_PROVIDES "provided-lib_auto, provided-lib_auto-b")
diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake
index 97ef238..3e5714d 100644
--- a/Tests/RunCMake/CPack/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake
@@ -7,3 +7,4 @@ include("${RunCMake_SOURCE_DIR}/CPackTestHelpers.cmake")
run_cpack_test(MINIMAL "RPM;DEB" false)
run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM" false)
run_cpack_test(DEB_EXTRA "DEB" false)
+run_cpack_test(DEPENDENCIES "RPM;DEB" true)