mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-02 11:49:55 -06:00
Testing: Add test for CPack External generator
This test case ensures that the CPack External generator produces the proper .json file, and also ensures that the version negotation with CPACK_EXT_REQUESTED_VERSIONS works properly.
This commit is contained in:
@@ -422,7 +422,7 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja")
|
||||
add_RunCMake_test(ctest_labels_for_subprojects)
|
||||
endif()
|
||||
|
||||
add_RunCMake_test_group(CPack "DEB;RPM;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ")
|
||||
add_RunCMake_test_group(CPack "DEB;RPM;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ;Ext")
|
||||
# add a test to make sure symbols are exported from a shared library
|
||||
# for MSVC compilers CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS property is used
|
||||
add_RunCMake_test(AutoExportDll)
|
||||
|
||||
31
Tests/RunCMake/CPack/Ext/Helpers.cmake
Normal file
31
Tests/RunCMake/CPack/Ext/Helpers.cmake
Normal file
@@ -0,0 +1,31 @@
|
||||
function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_VAR)
|
||||
set(${RESULT_VAR} "${NAME}-${VERSION}-*.json" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(getPackageContentList FILE RESULT_VAR)
|
||||
set("${RESULT_VAR}" "" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(toExpectedContentList FILE_NO CONTENT_VAR)
|
||||
set("${CONTENT_VAR}" "" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
set(ALL_FILES_GLOB "*.json")
|
||||
|
||||
function(check_ext_json EXPECTED_FILE ACTUAL_FILE)
|
||||
file(READ "${EXPECTED_FILE}" _expected_regex)
|
||||
file(READ "${ACTUAL_FILE}" _actual_contents)
|
||||
|
||||
string(REGEX REPLACE "\n+$" "" _expected_regex "${_expected_regex}")
|
||||
string(REGEX REPLACE "\n+$" "" _actual_contents "${_actual_contents}")
|
||||
|
||||
if(NOT "${_actual_contents}" MATCHES "${_expected_regex}")
|
||||
message(FATAL_ERROR
|
||||
"Output JSON does not match expected regex.\n"
|
||||
"Expected regex:\n"
|
||||
"${_expected_regex}\n"
|
||||
"Actual output:\n"
|
||||
"${_actual_contents}\n"
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
0
Tests/RunCMake/CPack/Ext/Prerequirements.cmake
Normal file
0
Tests/RunCMake/CPack/Ext/Prerequirements.cmake
Normal file
@@ -18,7 +18,7 @@ run_cpack_test(GENERATE_SHLIBS_LDCONFIG "DEB" true "COMPONENT")
|
||||
run_cpack_test(INSTALL_SCRIPTS "RPM" false "COMPONENT")
|
||||
run_cpack_test(LONG_FILENAMES "DEB" false "MONOLITHIC")
|
||||
run_cpack_test_subtests(MAIN_COMPONENT "invalid;found" "RPM" false "COMPONENT")
|
||||
run_cpack_test(MINIMAL "RPM;DEB;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ" false "MONOLITHIC;COMPONENT")
|
||||
run_cpack_test(MINIMAL "RPM;DEB;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ;Ext" false "MONOLITHIC;COMPONENT")
|
||||
run_cpack_test_subtests(PACKAGE_CHECKSUM "invalid;MD5;SHA1;SHA224;SHA256;SHA384;SHA512" "TGZ" false "MONOLITHIC")
|
||||
run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM" false "COMPONENT")
|
||||
run_cpack_test(PER_COMPONENT_FIELDS "RPM;DEB" false "COMPONENT")
|
||||
@@ -31,3 +31,4 @@ run_cpack_test(USER_FILELIST "RPM" false "MONOLITHIC")
|
||||
run_cpack_test(MD5SUMS "DEB" false "MONOLITHIC;COMPONENT")
|
||||
run_cpack_test(CPACK_INSTALL_SCRIPT "ZIP" false "MONOLITHIC")
|
||||
run_cpack_test(DEB_PACKAGE_VERSION_BACK_COMPATIBILITY "DEB" false "MONOLITHIC;COMPONENT")
|
||||
run_cpack_test_subtests(EXT "none;good;good_multi;bad_major;bad_minor;invalid_good;invalid_bad" "Ext" false "MONOLITHIC;COMPONENT")
|
||||
|
||||
@@ -56,8 +56,12 @@ if(NOT EXPECTED_FILES_COUNT EQUAL 0)
|
||||
set(EXPECTED_FILE_CONTENT_${file_no_} "${EXPECTED_FILE_CONTENT_${file_no_}_LIST}")
|
||||
toExpectedContentList("${file_no_}" "EXPECTED_FILE_CONTENT_${file_no_}")
|
||||
|
||||
list(SORT PACKAGE_CONTENT)
|
||||
list(SORT EXPECTED_FILE_CONTENT_${file_no_})
|
||||
if(NOT PACKAGE_CONTENT STREQUAL "")
|
||||
list(SORT PACKAGE_CONTENT)
|
||||
endif()
|
||||
if(NOT EXPECTED_FILE_CONTENT_${file_no_} STREQUAL "")
|
||||
list(SORT EXPECTED_FILE_CONTENT_${file_no_})
|
||||
endif()
|
||||
|
||||
if(PACKAGE_CONTENT STREQUAL EXPECTED_FILE_CONTENT_${file_no_})
|
||||
set(expected_content_list TRUE)
|
||||
|
||||
6
Tests/RunCMake/CPack/tests/EXT/ExpectedFiles.cmake
Normal file
6
Tests/RunCMake/CPack/tests/EXT/ExpectedFiles.cmake
Normal file
@@ -0,0 +1,6 @@
|
||||
if(RunCMake_SUBTEST_SUFFIX MATCHES "^(none|good(_multi)?|invalid_good)$")
|
||||
set(EXPECTED_FILES_COUNT "1")
|
||||
set(EXPECTED_FILE_CONTENT_1_LIST "/share;/share/cpack-test;/share/cpack-test/f1.txt;/share/cpack-test/f2.txt;/share/cpack-test/f3.txt;/share/cpack-test/f4.txt")
|
||||
else()
|
||||
set(EXPECTED_FILES_COUNT "0")
|
||||
endif()
|
||||
3
Tests/RunCMake/CPack/tests/EXT/VerifyResult.cmake
Normal file
3
Tests/RunCMake/CPack/tests/EXT/VerifyResult.cmake
Normal file
@@ -0,0 +1,3 @@
|
||||
if(RunCMake_SUBTEST_SUFFIX MATCHES "^(none|good(_multi)?|invalid_good)")
|
||||
check_ext_json("${src_dir}/tests/EXT/expected-json-1.0.txt" "${FOUND_FILE_1}")
|
||||
endif()
|
||||
6
Tests/RunCMake/CPack/tests/EXT/bad_major-stderr.txt
Normal file
6
Tests/RunCMake/CPack/tests/EXT/bad_major-stderr.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
CMake Error at .*/Modules/Internal/CPack/CPackExt\.cmake:[0-9]+ \(message\):
|
||||
Could not find a suitable version in CPACK_EXT_REQUESTED_VERSIONS
|
||||
|
||||
|
||||
CPack Error: Error while executing CPackExt\.cmake
|
||||
CPack Error: Cannot initialize the generator Ext
|
||||
6
Tests/RunCMake/CPack/tests/EXT/bad_minor-stderr.txt
Normal file
6
Tests/RunCMake/CPack/tests/EXT/bad_minor-stderr.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
CMake Error at .*/Modules/Internal/CPack/CPackExt\.cmake:[0-9]+ \(message\):
|
||||
Could not find a suitable version in CPACK_EXT_REQUESTED_VERSIONS
|
||||
|
||||
|
||||
CPack Error: Error while executing CPackExt\.cmake
|
||||
CPack Error: Cannot initialize the generator Ext
|
||||
176
Tests/RunCMake/CPack/tests/EXT/expected-json-1.0.txt
Normal file
176
Tests/RunCMake/CPack/tests/EXT/expected-json-1.0.txt
Normal file
@@ -0,0 +1,176 @@
|
||||
^\{
|
||||
"componentGroups" :[ ]
|
||||
\{
|
||||
"f12" :[ ]
|
||||
\{
|
||||
"components" :[ ]
|
||||
\[
|
||||
"f1",
|
||||
"f2"
|
||||
\],
|
||||
"description" : "Component group for files 1 and 2",
|
||||
"displayName" : "Files 1 and 2",
|
||||
"isBold" : false,
|
||||
"isExpandedByDefault" : false,
|
||||
"name" : "f12",
|
||||
"parentGroup" : "f1234",
|
||||
"subgroups" : \[\]
|
||||
\},
|
||||
"f1234" :[ ]
|
||||
\{
|
||||
"components" : \[\],
|
||||
"description" : "Component group for all files",
|
||||
"displayName" : "Files 1-4",
|
||||
"isBold" : false,
|
||||
"isExpandedByDefault" : false,
|
||||
"name" : "f1234",
|
||||
"subgroups" :[ ]
|
||||
\[
|
||||
"f12",
|
||||
"f34"
|
||||
\]
|
||||
\},
|
||||
"f34" :[ ]
|
||||
\{
|
||||
"components" :[ ]
|
||||
\[
|
||||
"f3",
|
||||
"f4"
|
||||
\],
|
||||
"description" : "Component group for files 3 and 4",
|
||||
"displayName" : "Files 3 and 4",
|
||||
"isBold" : false,
|
||||
"isExpandedByDefault" : false,
|
||||
"name" : "f34",
|
||||
"parentGroup" : "f1234",
|
||||
"subgroups" : \[\]
|
||||
\}
|
||||
\},
|
||||
"components" :[ ]
|
||||
\{
|
||||
"f1" :[ ]
|
||||
\{
|
||||
"archiveFile" : "",
|
||||
"dependencies" : \[\],
|
||||
"description" : "Component for file 1",
|
||||
"displayName" : "File 1",
|
||||
"group" : "f12",
|
||||
"installationTypes" :[ ]
|
||||
\[
|
||||
"full",
|
||||
"f12"
|
||||
\],
|
||||
"isDisabledByDefault" : false,
|
||||
"isDownloaded" : false,
|
||||
"isHidden" : false,
|
||||
"isRequired" : false,
|
||||
"name" : "f1"
|
||||
\},
|
||||
"f2" :[ ]
|
||||
\{
|
||||
"archiveFile" : "",
|
||||
"dependencies" :[ ]
|
||||
\[
|
||||
"f1"
|
||||
\],
|
||||
"description" : "Component for file 2",
|
||||
"displayName" : "File 2",
|
||||
"group" : "f12",
|
||||
"installationTypes" :[ ]
|
||||
\[
|
||||
"full",
|
||||
"f12"
|
||||
\],
|
||||
"isDisabledByDefault" : false,
|
||||
"isDownloaded" : false,
|
||||
"isHidden" : false,
|
||||
"isRequired" : false,
|
||||
"name" : "f2"
|
||||
\},
|
||||
"f3" :[ ]
|
||||
\{
|
||||
"archiveFile" : "",
|
||||
"dependencies" :[ ]
|
||||
\[
|
||||
"f1",
|
||||
"f2"
|
||||
\],
|
||||
"description" : "Component for file 3",
|
||||
"displayName" : "File 3",
|
||||
"group" : "f34",
|
||||
"installationTypes" :[ ]
|
||||
\[
|
||||
"full"
|
||||
\],
|
||||
"isDisabledByDefault" : false,
|
||||
"isDownloaded" : false,
|
||||
"isHidden" : false,
|
||||
"isRequired" : false,
|
||||
"name" : "f3"
|
||||
\},
|
||||
"f4" :[ ]
|
||||
\{
|
||||
"archiveFile" : "",
|
||||
"dependencies" :[ ]
|
||||
\[
|
||||
"f2",
|
||||
"f3",
|
||||
"f1"
|
||||
\],
|
||||
"description" : "Component for file 4",
|
||||
"displayName" : "File 4",
|
||||
"group" : "f34",
|
||||
"installationTypes" :[ ]
|
||||
\[
|
||||
"full"
|
||||
\],
|
||||
"isDisabledByDefault" : false,
|
||||
"isDownloaded" : false,
|
||||
"isHidden" : false,
|
||||
"isRequired" : false,
|
||||
"name" : "f4"
|
||||
\}
|
||||
\},
|
||||
"errorOnAbsoluteInstallDestination" : false,
|
||||
"formatVersionMajor" : 1,
|
||||
"formatVersionMinor" : 0,
|
||||
"installationTypes" :[ ]
|
||||
\{
|
||||
"f12" :[ ]
|
||||
\{
|
||||
"displayName" : "Only files 1 and 2",
|
||||
"index" : 2,
|
||||
"name" : "f12"
|
||||
\},
|
||||
"full" :[ ]
|
||||
\{
|
||||
"displayName" : "Full installation",
|
||||
"index" : 1,
|
||||
"name" : "full"
|
||||
\}
|
||||
\},
|
||||
"packageDescriptionFile" : ".*/Templates/CPack\.GenericDescription\.txt",
|
||||
"packageDescriptionSummary" : "EXT-(none|good(_multi)?|invalid_good)-subtest-(MONOLITHIC|COMPONENT)-type built using CMake",
|
||||
"packageName" : "ext",
|
||||
"packageVersion" : "0\.1\.1",
|
||||
"projects" :[ ]
|
||||
\[
|
||||
\{
|
||||
"component" : "ALL",
|
||||
"components" :[ ]
|
||||
\[
|
||||
"f1",
|
||||
"f2",
|
||||
"f3",
|
||||
"f4"
|
||||
\],
|
||||
"directory" : ".*/Tests/RunCMake/Ext/CPack/EXT-build-(none|good(_multi)?|invalid_good)-subtest",
|
||||
"installationTypes" : \[\],
|
||||
"projectName" : "EXT-(none|good(_multi)?|invalid_good)-subtest-(MONOLITHIC|COMPONENT)-type",
|
||||
"subDirectory" : "/"
|
||||
\}
|
||||
\],
|
||||
"setDestdir" : false,
|
||||
"stripFiles" : false,
|
||||
"warnOnAbsoluteInstallDestination" : false
|
||||
\}$
|
||||
6
Tests/RunCMake/CPack/tests/EXT/invalid_bad-stderr.txt
Normal file
6
Tests/RunCMake/CPack/tests/EXT/invalid_bad-stderr.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
CMake Error at .*/Modules/Internal/CPack/CPackExt\.cmake:[0-9]+ \(message\):
|
||||
Could not find a suitable version in CPACK_EXT_REQUESTED_VERSIONS
|
||||
|
||||
|
||||
CPack Error: Error while executing CPackExt\.cmake
|
||||
CPack Error: Cannot initialize the generator Ext
|
||||
83
Tests/RunCMake/CPack/tests/EXT/test.cmake
Normal file
83
Tests/RunCMake/CPack/tests/EXT/test.cmake
Normal file
@@ -0,0 +1,83 @@
|
||||
include(CPackComponent)
|
||||
|
||||
if(RunCMake_SUBTEST_SUFFIX STREQUAL "none")
|
||||
unset(CPACK_EXT_REQUESTED_VERSIONS)
|
||||
elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "good")
|
||||
set(CPACK_EXT_REQUESTED_VERSIONS "1.0")
|
||||
elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "good_multi")
|
||||
set(CPACK_EXT_REQUESTED_VERSIONS "1.0;2.0")
|
||||
elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "bad_major")
|
||||
set(CPACK_EXT_REQUESTED_VERSIONS "2.0")
|
||||
elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "bad_minor")
|
||||
set(CPACK_EXT_REQUESTED_VERSIONS "1.1")
|
||||
elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "invalid_good")
|
||||
set(CPACK_EXT_REQUESTED_VERSIONS "1;1.0")
|
||||
elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "invalid_bad")
|
||||
set(CPACK_EXT_REQUESTED_VERSIONS "1")
|
||||
endif()
|
||||
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/f1.txt" test1)
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/f2.txt" test2)
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/f3.txt" test3)
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/f4.txt" test4)
|
||||
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/f1.txt" DESTINATION share/cpack-test COMPONENT f1)
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/f2.txt" DESTINATION share/cpack-test COMPONENT f2)
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/f3.txt" DESTINATION share/cpack-test COMPONENT f3)
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/f4.txt" DESTINATION share/cpack-test COMPONENT f4)
|
||||
|
||||
cpack_add_component(f1
|
||||
DISPLAY_NAME "File 1"
|
||||
DESCRIPTION "Component for file 1"
|
||||
GROUP f12
|
||||
INSTALL_TYPES full f12
|
||||
)
|
||||
|
||||
cpack_add_component(f2
|
||||
DISPLAY_NAME "File 2"
|
||||
DESCRIPTION "Component for file 2"
|
||||
GROUP f12
|
||||
DEPENDS f1
|
||||
INSTALL_TYPES full f12
|
||||
)
|
||||
|
||||
cpack_add_component(f3
|
||||
DISPLAY_NAME "File 3"
|
||||
DESCRIPTION "Component for file 3"
|
||||
GROUP f34
|
||||
DEPENDS f1 f2
|
||||
INSTALL_TYPES full
|
||||
)
|
||||
|
||||
cpack_add_component(f4
|
||||
DISPLAY_NAME "File 4"
|
||||
DESCRIPTION "Component for file 4"
|
||||
GROUP f34
|
||||
DEPENDS f2 f3 f1
|
||||
INSTALL_TYPES full
|
||||
)
|
||||
|
||||
cpack_add_component_group(f12
|
||||
DISPLAY_NAME "Files 1 and 2"
|
||||
DESCRIPTION "Component group for files 1 and 2"
|
||||
PARENT_GROUP f1234
|
||||
)
|
||||
|
||||
cpack_add_component_group(f34
|
||||
DISPLAY_NAME "Files 3 and 4"
|
||||
DESCRIPTION "Component group for files 3 and 4"
|
||||
PARENT_GROUP f1234
|
||||
)
|
||||
|
||||
cpack_add_component_group(f1234
|
||||
DISPLAY_NAME "Files 1-4"
|
||||
DESCRIPTION "Component group for all files"
|
||||
)
|
||||
|
||||
cpack_add_install_type(full
|
||||
DISPLAY_NAME "Full installation"
|
||||
)
|
||||
|
||||
cpack_add_install_type(f12
|
||||
DISPLAY_NAME "Only files 1 and 2"
|
||||
)
|
||||
Reference in New Issue
Block a user