summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBartosz Kosiorek <gang65@poczta.onet.pl>2019-05-22 19:29:08 (GMT)
committerBrad King <brad.king@kitware.com>2019-05-23 14:08:22 (GMT)
commitc8e217e0a70f8f445e2c593f44e1105c959fb9d7 (patch)
treeb02a243d33320167c75705eb7f332bb419352eb4 /Tests
parentf03a80aefd4073bc1502c2e486fedfdbd8addfb6 (diff)
downloadCMake-c8e217e0a70f8f445e2c593f44e1105c959fb9d7.zip
CMake-c8e217e0a70f8f445e2c593f44e1105c959fb9d7.tar.gz
CMake-c8e217e0a70f8f445e2c593f44e1105c959fb9d7.tar.bz2
cmake: tar: Allow selective extracting and listing of archives
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/CommandLineTar/roundtrip.cmake14
-rw-r--r--Tests/RunCMake/CommandLineTar/zip-filtered.cmake28
3 files changed, 44 insertions, 1 deletions
diff --git a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake
index 5deb110..4d1b396 100644
--- a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake
@@ -30,3 +30,6 @@ run_cmake(pax-xz)
run_cmake(paxr)
run_cmake(paxr-bz2)
run_cmake(zip)
+
+# Extracting only selected files or directories
+run_cmake(zip-filtered)
diff --git a/Tests/RunCMake/CommandLineTar/roundtrip.cmake b/Tests/RunCMake/CommandLineTar/roundtrip.cmake
index dc1c885..fa63d12 100644
--- a/Tests/RunCMake/CommandLineTar/roundtrip.cmake
+++ b/Tests/RunCMake/CommandLineTar/roundtrip.cmake
@@ -47,7 +47,11 @@ file(REMOVE_RECURSE ${FULL_DECOMPRESS_DIR})
file(MAKE_DIRECTORY ${FULL_DECOMPRESS_DIR})
run_tar(${CMAKE_CURRENT_BINARY_DIR} ${COMPRESSION_FLAGS} ${FULL_OUTPUT_NAME} ${COMPRESSION_OPTIONS} ${COMPRESS_DIR})
-run_tar(${FULL_DECOMPRESS_DIR} ${DECOMPRESSION_FLAGS} ${FULL_OUTPUT_NAME} ${DECOMPRESSION_OPTIONS})
+run_tar(${FULL_DECOMPRESS_DIR} ${DECOMPRESSION_FLAGS} ${FULL_OUTPUT_NAME} ${DECOMPRESSION_OPTIONS} -- ${DECOMPRESSION_PATHNAMES})
+
+if(CUSTOM_CHECK_FILES)
+ set(CHECK_FILES ${CUSTOM_CHECK_FILES})
+endif()
foreach(file ${CHECK_FILES})
set(input ${FULL_COMPRESS_DIR}/${file})
@@ -69,6 +73,14 @@ foreach(file ${CHECK_FILES})
endif()
endforeach()
+foreach(file ${NOT_EXISTING_FILES_CHECK})
+ set(output ${FULL_DECOMPRESS_DIR}/${COMPRESS_DIR}/${file})
+
+ if(EXISTS ${output})
+ message(SEND_ERROR "File ${output} exists but it shouldn't")
+ endif()
+endforeach()
+
function(check_magic EXPECTED)
file(READ ${FULL_OUTPUT_NAME} ACTUAL
${ARGN}
diff --git a/Tests/RunCMake/CommandLineTar/zip-filtered.cmake b/Tests/RunCMake/CommandLineTar/zip-filtered.cmake
new file mode 100644
index 0000000..c13210e
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/zip-filtered.cmake
@@ -0,0 +1,28 @@
+set(OUTPUT_NAME "test.zip")
+
+set(COMPRESSION_FLAGS cvf)
+set(COMPRESSION_OPTIONS --format=zip)
+
+set(DECOMPRESSION_FLAGS xvf)
+set(LIST_ARCHIVE TRUE)
+set(DECOMPRESSION_PATHNAMES
+ compress_dir/f1.txt # Decompress only file
+ compress_dir/d1 # and whole directory
+)
+
+set(CUSTOM_CHECK_FILES
+ "f1.txt"
+ "d1/f1.txt"
+)
+
+# This files shouldn't exists
+set(NOT_EXISTING_FILES_CHECK
+ "d 2/f1.txt"
+ "d + 3/f1.txt"
+ "d_4/f1.txt"
+ "d-4/f1.txt"
+)
+
+include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
+
+check_magic("504b0304" LIMIT 4 HEX)