summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-03-25 13:05:33 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-03-25 13:05:41 (GMT)
commitb11d789ef7341ca717949a4e47f14e75fe41a4c2 (patch)
treeeed3dd9d6d5635624f218326d460a9e0e7bfad5e /Tests
parent232884345078a89d7f29fea2900be34c178bc10c (diff)
parent0b7fd783f82639ba129e62edeac0de6594542708 (diff)
downloadCMake-b11d789ef7341ca717949a4e47f14e75fe41a4c2.zip
CMake-b11d789ef7341ca717949a4e47f14e75fe41a4c2.tar.gz
CMake-b11d789ef7341ca717949a4e47f14e75fe41a4c2.tar.bz2
Merge topic 'cmake-E-tar-touch'
0b7fd783f8 cmake -E tar: Add --touch option f692cba34b Tests: Add test for 'cmake -E tar --mtime' option Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !7061
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake6
-rw-r--r--Tests/RunCMake/CommandLineTar/mtime-tests.cmake9
-rw-r--r--Tests/RunCMake/CommandLineTar/set-mtime.cmake11
-rw-r--r--Tests/RunCMake/CommandLineTar/touch-mtime.cmake13
4 files changed, 39 insertions, 0 deletions
diff --git a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake
index a64af95..a487f37 100644
--- a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake
@@ -34,3 +34,9 @@ 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)
+
+# Use the --touch option to avoid extracting the mtime
+run_cmake(touch-mtime)
diff --git a/Tests/RunCMake/CommandLineTar/mtime-tests.cmake b/Tests/RunCMake/CommandLineTar/mtime-tests.cmake
new file mode 100644
index 0000000..8b4f098
--- /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 0000000..333cc88
--- /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()
diff --git a/Tests/RunCMake/CommandLineTar/touch-mtime.cmake b/Tests/RunCMake/CommandLineTar/touch-mtime.cmake
new file mode 100644
index 0000000..c9e3524
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/touch-mtime.cmake
@@ -0,0 +1,13 @@
+include(${CMAKE_CURRENT_LIST_DIR}/mtime-tests.cmake)
+
+set(DECOMPRESSION_OPTIONS --touch)
+
+include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
+
+foreach(file ${CHECK_FILES})
+ file(TIMESTAMP ${FULL_DECOMPRESS_DIR}/${COMPRESS_DIR}/${file} MTIME UTC)
+ if(MTIME STREQUAL ARCHIVE_MTIME_RFC3339)
+ message(FATAL_ERROR
+ "File has unexpected timestamp ${MTIME}")
+ endif()
+endforeach()