Tests: Add test for 'cmake -E tar --mtime' option

Add a test for ensuring the `--mtime` option works as expected.
This commit is contained in:
Kasper Laudrup
2022-03-13 19:16:25 +01:00
parent 14d3f2a5c8
commit f692cba34b
3 changed files with 23 additions and 0 deletions

View File

@@ -34,3 +34,6 @@ run_cmake(zip)
# Extracting only selected files or directories
run_cmake(zip-filtered)
# Use the --mtime option to set the mtime when creating archive
run_cmake(set-mtime)

View File

@@ -0,0 +1,9 @@
set(OUTPUT_NAME "test.tar")
set(ARCHIVE_MTIME "1970-01-01UTC")
set(ARCHIVE_MTIME_RFC3339 "1970-01-01T00:00:00Z")
set(COMPRESSION_FLAGS cvf)
set(COMPRESSION_OPTIONS --mtime=${ARCHIVE_MTIME})
set(DECOMPRESSION_FLAGS xvf)

View File

@@ -0,0 +1,11 @@
include(${CMAKE_CURRENT_LIST_DIR}/mtime-tests.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
foreach(file ${CHECK_FILES})
file(TIMESTAMP ${FULL_DECOMPRESS_DIR}/${COMPRESS_DIR}/${file} MTIME UTC)
if(NOT MTIME STREQUAL ARCHIVE_MTIME_RFC3339)
message(FATAL_ERROR
"Extracted timestamp ${MTIME} does not match expected ${ARCHIVE_MTIME_RFC3339}")
endif()
endforeach()