summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
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()