diff options
author | Brad King <brad.king@kitware.com> | 2018-07-27 14:06:35 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-07-27 14:06:44 (GMT) |
commit | bccbf9a737785c34e0b23b2b456fbb4e112d42fb (patch) | |
tree | 318b97c65f19e6e6d6934ff8d9a48de328232192 /Tests/RunCMake | |
parent | 131fcf65f667ab23b3bcd31c6d82b5bd01a44683 (diff) | |
parent | 548ac51d8ea319c65abefa0a771636893c45014c (diff) | |
download | CMake-bccbf9a737785c34e0b23b2b456fbb4e112d42fb.zip CMake-bccbf9a737785c34e0b23b2b456fbb4e112d42fb.tar.gz CMake-bccbf9a737785c34e0b23b2b456fbb4e112d42fb.tar.bz2 |
Merge topic 'reproducible-tarballs'
548ac51d8e CPack/Deb: Support SOURCE_DATE_EPOCH when packaging files
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2226
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r-- | Tests/RunCMake/CPack/CPackTestHelpers.cmake | 6 | ||||
-rw-r--r-- | Tests/RunCMake/CPack/DEB/Helpers.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/CPack/RunCMakeTest.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CPack/tests/TIMESTAMPS/ExpectedFiles.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/CPack/tests/TIMESTAMPS/VerifyResult.cmake | 58 | ||||
-rw-r--r-- | Tests/RunCMake/CPack/tests/TIMESTAMPS/test.cmake | 3 |
6 files changed, 72 insertions, 2 deletions
diff --git a/Tests/RunCMake/CPack/CPackTestHelpers.cmake b/Tests/RunCMake/CPack/CPackTestHelpers.cmake index 8c9f4b4..d00ef3b 100644 --- a/Tests/RunCMake/CPack/CPackTestHelpers.cmake +++ b/Tests/RunCMake/CPack/CPackTestHelpers.cmake @@ -78,8 +78,12 @@ function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source PACK endif() # execute cpack + set(SETENV) + if(ENVIRONMENT) + set(SETENV ${CMAKE_COMMAND} -E env "${ENVIRONMENT}") + endif() execute_process( - COMMAND ${cpack_command_} + COMMAND ${SETENV} ${cpack_command_} WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}" RESULT_VARIABLE "result_" OUTPUT_FILE "${RunCMake_TEST_BINARY_DIR}/test_output.txt" diff --git a/Tests/RunCMake/CPack/DEB/Helpers.cmake b/Tests/RunCMake/CPack/DEB/Helpers.cmake index f7c5c84..e01f81d 100644 --- a/Tests/RunCMake/CPack/DEB/Helpers.cmake +++ b/Tests/RunCMake/CPack/DEB/Helpers.cmake @@ -1,7 +1,7 @@ set(ALL_FILES_GLOB "*.deb") function(getPackageContent FILE RESULT_VAR) - execute_process(COMMAND ${DPKG_EXECUTABLE} -c "${FILE}" + execute_process(COMMAND ${CMAKE_COMMAND} -E env TZ=Etc/UTC ${DPKG_EXECUTABLE} -c "${FILE}" OUTPUT_VARIABLE package_content_ ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 33ffa14..b273c1e 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -28,6 +28,9 @@ 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") +set(ENVIRONMENT "SOURCE_DATE_EPOCH=123456789") +run_cpack_test(TIMESTAMPS "DEB;TGZ" false "COMPONENT") +unset(ENVIRONMENT) 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") diff --git a/Tests/RunCMake/CPack/tests/TIMESTAMPS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/TIMESTAMPS/ExpectedFiles.cmake new file mode 100644 index 0000000..d1a3a5f --- /dev/null +++ b/Tests/RunCMake/CPack/tests/TIMESTAMPS/ExpectedFiles.cmake @@ -0,0 +1,2 @@ +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/tests/TIMESTAMPS/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/TIMESTAMPS/VerifyResult.cmake new file mode 100644 index 0000000..e7e2645 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/TIMESTAMPS/VerifyResult.cmake @@ -0,0 +1,58 @@ +macro(getFileMetadata_ FILE RESULT_VAR) + if(GENERATOR_TYPE STREQUAL "TGZ") + # getPackageContent defined for archives omit the metadata (non-verbose) + execute_process(COMMAND ${CMAKE_COMMAND} -E env TZ=Etc/UTC ${CMAKE_COMMAND} -E tar -xtvf ${FILE} + OUTPUT_VARIABLE ${RESULT_VAR} + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + else() + getPackageContent("${FILE}" ${RESULT_VAR}) + endif() +endmacro() + +function(checkContentTimestamp FILE REGEX) + getFileMetadata_("${FILE}" METADATA_) + + if(NOT METADATA_ MATCHES "${REGEX}") + string(REPLACE "\n" "\n " metadata_indented "${METADATA_}") + message(FATAL_ERROR + "Wrong timestamps in file:\n" + " ${FILE}\n" + "Expected timestamps to match:\n" + " ${REGEX}\n" + "Actual timestamps:\n" + " ${metadata_indented}") + endif() +endfunction() + +function(checkTimestamp FILE_NAME) + file(READ ${FILE_NAME} ACTUAL_TIMESTAMP OFFSET 4 LIMIT 4 HEX) + + if(NOT ACTUAL_TIMESTAMP STREQUAL "00000000") + message(FATAL_ERROR "${FILE_NAME} contains a timestamp [0x${ACTUAL_TIMESTAMP}]") + endif() +endfunction() + +# Expected timestamp is UNIX time 123456789 +if(GENERATOR_TYPE STREQUAL "TGZ") + set(EXPECTED_TIMESTAMP "29 Nov +1973") + set(EXPECTED_FILES foo/ foo/CMakeLists.txt) +else() + set(EXPECTED_TIMESTAMP "1973-11-29 21:33") + set(EXPECTED_FILES ./usr/ ./usr/foo/ ./usr/foo/CMakeLists.txt) +endif() + +set(EXPECTED_METADATA) +foreach(FILE ${EXPECTED_FILES}) + list(APPEND EXPECTED_METADATA ".* ${EXPECTED_TIMESTAMP} ${FILE}") +endforeach() +list(JOIN EXPECTED_METADATA ".*" EXPECTED_REGEX) +checkContentTimestamp("${FOUND_FILE_1}" "${EXPECTED_REGEX}") + +if(GENERATOR_TYPE STREQUAL "TGZ") + checkTimestamp("${FOUND_FILE_1}") +else() + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf "${FOUND_FILE_1}") + checkTimestamp("data.tar.gz") + checkTimestamp("control.tar.gz") +endif() diff --git a/Tests/RunCMake/CPack/tests/TIMESTAMPS/test.cmake b/Tests/RunCMake/CPack/tests/TIMESTAMPS/test.cmake new file mode 100644 index 0000000..a193852 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/TIMESTAMPS/test.cmake @@ -0,0 +1,3 @@ +install(FILES CMakeLists.txt DESTINATION foo COMPONENT test) + +set(CPACK_COMPONENTS_ALL test) |