summaryrefslogtreecommitdiff
path: root/Tests/RunCMake/CommandLineTar
diff options
context:
space:
mode:
authorKasper Laudrup <you@example.com>2022-03-13 19:16:25 +0100
committerKasper Laudrup <you@example.com>2022-03-23 14:41:34 +0100
commitf692cba34b758f5c308c3fd659c438ce022a0a80 (patch)
tree2e6bf24a0b3e90e0d44366fe023d93e1add16ba7 /Tests/RunCMake/CommandLineTar
parent14d3f2a5c817683712ff78e0bebaa660c84ff0b3 (diff)
downloadcmake-f692cba34b758f5c308c3fd659c438ce022a0a80.tar.gz
Tests: Add test for 'cmake -E tar --mtime' option
Add a test for ensuring the `--mtime` option works as expected.
Diffstat (limited to 'Tests/RunCMake/CommandLineTar')
-rw-r--r--Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/CommandLineTar/mtime-tests.cmake9
-rw-r--r--Tests/RunCMake/CommandLineTar/set-mtime.cmake11
3 files changed, 23 insertions, 0 deletions
diff --git a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake
index a64af95247..079a535d93 100644
--- a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake
@@ -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)
diff --git a/Tests/RunCMake/CommandLineTar/mtime-tests.cmake b/Tests/RunCMake/CommandLineTar/mtime-tests.cmake
new file mode 100644
index 0000000000..8b4f09839d
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/mtime-tests.cmake
@@ -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)
diff --git a/Tests/RunCMake/CommandLineTar/set-mtime.cmake b/Tests/RunCMake/CommandLineTar/set-mtime.cmake
new file mode 100644
index 0000000000..333cc88fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/set-mtime.cmake
@@ -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()