summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-04-10 12:33:00 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2015-04-10 12:33:00 (GMT)
commit10859b97ebbe610a829e3981958d7b4c0149f95a (patch)
tree992b9334ad833f69543702c50d1166ff1b2c06e4 /Tests/RunCMake
parent1264c5b2c485416128466510c42ab40a03eb0ca3 (diff)
parent6c4781baa9ea4cfb7b4de9ef91e58888286fab44 (diff)
downloadCMake-10859b97ebbe610a829e3981958d7b4c0149f95a.zip
CMake-10859b97ebbe610a829e3981958d7b4c0149f95a.tar.gz
CMake-10859b97ebbe610a829e3981958d7b4c0149f95a.tar.bz2
Merge topic 'tar-write-format'
6c4781ba Tests: Consolidate, refactor and extend -E tar tests fd04d873 CTestCoverageCollectGCOV: Write tar files intended for CDash in gnutar format d2cc5807 cmake: Teach "-E tar" command a "--format=" option
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/CommandLine/RunCMakeTest.cmake11
-rw-r--r--Tests/RunCMake/CommandLineTar/7zip-gz-result.txt (renamed from Tests/RunCMake/CommandLine/E_tar-end-opt1-result.txt)0
-rw-r--r--Tests/RunCMake/CommandLineTar/7zip-gz-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLineTar/7zip.cmake10
-rw-r--r--Tests/RunCMake/CommandLineTar/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake28
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-format-result.txt (renamed from Tests/RunCMake/CommandLine/E_tar-bad-opt1-result.txt)0
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-format-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-from1-result.txt (renamed from Tests/RunCMake/CommandLine/E_tar-bad-mtime1-result.txt)0
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-from1-stderr.txt (renamed from Tests/RunCMake/CommandLine/E_tar-bad-from1-stderr.txt)0
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-from2-result.txt (renamed from Tests/RunCMake/CommandLine/E_tar-bad-from5-result.txt)0
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-from2-stderr.txt (renamed from Tests/RunCMake/CommandLine/E_tar-bad-from2-stderr.txt)0
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-from3-result.txt (renamed from Tests/RunCMake/CommandLine/E_tar-bad-from4-result.txt)0
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-from3-stderr.txt (renamed from Tests/RunCMake/CommandLine/E_tar-bad-from3-stderr.txt)2
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-from3.txt (renamed from Tests/RunCMake/CommandLine/E_tar-bad-from3.txt)0
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-from4-result.txt (renamed from Tests/RunCMake/CommandLine/E_tar-bad-from3-result.txt)0
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-from4-stderr.txt (renamed from Tests/RunCMake/CommandLine/E_tar-bad-from5-stderr.txt)0
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-from4.txt (renamed from Tests/RunCMake/CommandLine/E_tar-bad-from4.txt)0
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-from5-result.txt (renamed from Tests/RunCMake/CommandLine/E_tar-bad-from2-result.txt)0
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-from5-stderr.txt (renamed from Tests/RunCMake/CommandLine/E_tar-bad-from4-stderr.txt)0
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-from5.txt (renamed from Tests/RunCMake/CommandLine/E_tar-bad-from5.txt)0
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-mtime1-result.txt (renamed from Tests/RunCMake/CommandLine/E_tar-bad-from1-result.txt)0
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-mtime1-stderr.txt (renamed from Tests/RunCMake/CommandLine/E_tar-bad-mtime1-stderr.txt)0
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-opt1-result.txt1
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-opt1-stderr.txt (renamed from Tests/RunCMake/CommandLine/E_tar-bad-opt1-stderr.txt)0
-rw-r--r--Tests/RunCMake/CommandLineTar/end-opt1-result.txt1
-rw-r--r--Tests/RunCMake/CommandLineTar/end-opt1-stderr.txt (renamed from Tests/RunCMake/CommandLine/E_tar-end-opt1-stderr.txt)0
-rw-r--r--Tests/RunCMake/CommandLineTar/gnutar-gz.cmake10
-rw-r--r--Tests/RunCMake/CommandLineTar/gnutar.cmake10
-rw-r--r--Tests/RunCMake/CommandLineTar/pax-xz.cmake10
-rw-r--r--Tests/RunCMake/CommandLineTar/pax.cmake10
-rw-r--r--Tests/RunCMake/CommandLineTar/paxr-bz2.cmake10
-rw-r--r--Tests/RunCMake/CommandLineTar/paxr.cmake10
-rw-r--r--Tests/RunCMake/CommandLineTar/roundtrip.cmake81
-rw-r--r--Tests/RunCMake/CommandLineTar/zip-bz2-result.txt1
-rw-r--r--Tests/RunCMake/CommandLineTar/zip-bz2-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLineTar/zip.cmake10
38 files changed, 200 insertions, 12 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 3709913..d7ac81d 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -200,6 +200,7 @@ add_RunCMake_test(target_link_libraries)
add_RunCMake_test(target_compile_features)
add_RunCMake_test(CheckModules)
add_RunCMake_test(CommandLine)
+add_RunCMake_test(CommandLineTar)
add_RunCMake_test(install)
add_RunCMake_test(CPackInstallProperties)
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index e8b4584..f879ee6 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -1,16 +1,5 @@
include(RunCMake)
-run_cmake_command(E_tar-bad-opt1 ${CMAKE_COMMAND} -E tar cvf bad.tar --bad)
-run_cmake_command(E_tar-bad-mtime1 ${CMAKE_COMMAND} -E tar cvf bad.tar --mtime=bad .)
-run_cmake_command(E_tar-bad-from1 ${CMAKE_COMMAND} -E tar cvf bad.tar --files-from=bad)
-run_cmake_command(E_tar-bad-from2 ${CMAKE_COMMAND} -E tar cvf bad.tar --files-from=.)
-run_cmake_command(E_tar-bad-from3 ${CMAKE_COMMAND} -E tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/E_tar-bad-from3.txt)
-run_cmake_command(E_tar-bad-from4 ${CMAKE_COMMAND} -E tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/E_tar-bad-from4.txt)
-run_cmake_command(E_tar-bad-from5 ${CMAKE_COMMAND} -E tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/E_tar-bad-from5.txt)
-run_cmake_command(E_tar-end-opt1 ${CMAKE_COMMAND} -E tar cvf bad.tar -- --bad)
-run_cmake_command(E_tar-end-opt2 ${CMAKE_COMMAND} -E tar cvf bad.tar --)
-run_cmake_command(E_tar-mtime ${CMAKE_COMMAND} -E tar cvf bad.tar "--mtime=1970-01-01 00:00:00 UTC")
-
run_cmake_command(build-no-cache
${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR})
run_cmake_command(build-no-generator
diff --git a/Tests/RunCMake/CommandLine/E_tar-end-opt1-result.txt b/Tests/RunCMake/CommandLineTar/7zip-gz-result.txt
index d00491f..d00491f 100644
--- a/Tests/RunCMake/CommandLine/E_tar-end-opt1-result.txt
+++ b/Tests/RunCMake/CommandLineTar/7zip-gz-result.txt
diff --git a/Tests/RunCMake/CommandLineTar/7zip-gz-stderr.txt b/Tests/RunCMake/CommandLineTar/7zip-gz-stderr.txt
new file mode 100644
index 0000000..2fad326
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/7zip-gz-stderr.txt
@@ -0,0 +1 @@
+CMake Error: Can not use compression flags with format: 7zip
diff --git a/Tests/RunCMake/CommandLineTar/7zip.cmake b/Tests/RunCMake/CommandLineTar/7zip.cmake
new file mode 100644
index 0000000..4bc6548
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/7zip.cmake
@@ -0,0 +1,10 @@
+set(OUTPUT_NAME "test.7z")
+
+set(COMPRESSION_FLAGS cvf)
+set(COMPRESSION_OPTIONS --format=7zip)
+
+set(DECOMPRESSION_FLAGS xvf)
+
+include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
+
+check_magic("377abcaf271c" LIMIT 6 HEX)
diff --git a/Tests/RunCMake/CommandLineTar/CMakeLists.txt b/Tests/RunCMake/CommandLineTar/CMakeLists.txt
new file mode 100644
index 0000000..2897109
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.0)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake
new file mode 100644
index 0000000..12635db
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake
@@ -0,0 +1,28 @@
+include(RunCMake)
+
+function(external_command_test NAME)
+ run_cmake_command(${NAME} ${CMAKE_COMMAND} -E ${ARGN})
+endfunction()
+
+external_command_test(bad-opt1 tar cvf bad.tar --bad)
+external_command_test(bad-mtime1 tar cvf bad.tar --mtime=bad .)
+external_command_test(bad-from1 tar cvf bad.tar --files-from=bad)
+external_command_test(bad-from2 tar cvf bad.tar --files-from=.)
+external_command_test(bad-from3 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from3.txt)
+external_command_test(bad-from4 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from4.txt)
+external_command_test(bad-from5 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from5.txt)
+external_command_test(end-opt1 tar cvf bad.tar -- --bad)
+external_command_test(end-opt2 tar cvf bad.tar --)
+external_command_test(mtime tar cvf bad.tar "--mtime=1970-01-01 00:00:00 UTC")
+external_command_test(bad-format tar cvf bad.tar "--format=bad-format")
+external_command_test(zip-bz2 tar cvjf bad.tar "--format=zip")
+external_command_test(7zip-gz tar cvzf bad.tar "--format=7zip")
+
+run_cmake(7zip)
+run_cmake(gnutar)
+run_cmake(gnutar-gz)
+run_cmake(pax)
+run_cmake(pax-xz)
+run_cmake(paxr)
+run_cmake(paxr-bz2)
+run_cmake(zip)
diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-opt1-result.txt b/Tests/RunCMake/CommandLineTar/bad-format-result.txt
index d00491f..d00491f 100644
--- a/Tests/RunCMake/CommandLine/E_tar-bad-opt1-result.txt
+++ b/Tests/RunCMake/CommandLineTar/bad-format-result.txt
diff --git a/Tests/RunCMake/CommandLineTar/bad-format-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-format-stderr.txt
new file mode 100644
index 0000000..fe9e2dc
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/bad-format-stderr.txt
@@ -0,0 +1 @@
+CMake Error: Unknown -E tar --format= argument: bad-format
diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-mtime1-result.txt b/Tests/RunCMake/CommandLineTar/bad-from1-result.txt
index d00491f..d00491f 100644
--- a/Tests/RunCMake/CommandLine/E_tar-bad-mtime1-result.txt
+++ b/Tests/RunCMake/CommandLineTar/bad-from1-result.txt
diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from1-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-from1-stderr.txt
index d67431d..d67431d 100644
--- a/Tests/RunCMake/CommandLine/E_tar-bad-from1-stderr.txt
+++ b/Tests/RunCMake/CommandLineTar/bad-from1-stderr.txt
diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from5-result.txt b/Tests/RunCMake/CommandLineTar/bad-from2-result.txt
index d00491f..d00491f 100644
--- a/Tests/RunCMake/CommandLine/E_tar-bad-from5-result.txt
+++ b/Tests/RunCMake/CommandLineTar/bad-from2-result.txt
diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from2-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-from2-stderr.txt
index d1d278c..d1d278c 100644
--- a/Tests/RunCMake/CommandLine/E_tar-bad-from2-stderr.txt
+++ b/Tests/RunCMake/CommandLineTar/bad-from2-stderr.txt
diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from4-result.txt b/Tests/RunCMake/CommandLineTar/bad-from3-result.txt
index d00491f..d00491f 100644
--- a/Tests/RunCMake/CommandLine/E_tar-bad-from4-result.txt
+++ b/Tests/RunCMake/CommandLineTar/bad-from3-result.txt
diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from3-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-from3-stderr.txt
index 147bd80..da32ad9 100644
--- a/Tests/RunCMake/CommandLine/E_tar-bad-from3-stderr.txt
+++ b/Tests/RunCMake/CommandLineTar/bad-from3-stderr.txt
@@ -1,2 +1,2 @@
-^CMake Error: -E tar --files-from='.*/Tests/RunCMake/CommandLine/E_tar-bad-from3.txt' file invalid line:
+^CMake Error: -E tar --files-from='.*/Tests/RunCMake/CommandLineTar/bad-from3.txt' file invalid line:
-add-file=option-typo$
diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from3.txt b/Tests/RunCMake/CommandLineTar/bad-from3.txt
index 5bad1c3..5bad1c3 100644
--- a/Tests/RunCMake/CommandLine/E_tar-bad-from3.txt
+++ b/Tests/RunCMake/CommandLineTar/bad-from3.txt
diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from3-result.txt b/Tests/RunCMake/CommandLineTar/bad-from4-result.txt
index d00491f..d00491f 100644
--- a/Tests/RunCMake/CommandLine/E_tar-bad-from3-result.txt
+++ b/Tests/RunCMake/CommandLineTar/bad-from4-result.txt
diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from5-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-from4-stderr.txt
index 1417d4d..1417d4d 100644
--- a/Tests/RunCMake/CommandLine/E_tar-bad-from5-stderr.txt
+++ b/Tests/RunCMake/CommandLineTar/bad-from4-stderr.txt
diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from4.txt b/Tests/RunCMake/CommandLineTar/bad-from4.txt
index 4b97f79..4b97f79 100644
--- a/Tests/RunCMake/CommandLine/E_tar-bad-from4.txt
+++ b/Tests/RunCMake/CommandLineTar/bad-from4.txt
diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from2-result.txt b/Tests/RunCMake/CommandLineTar/bad-from5-result.txt
index d00491f..d00491f 100644
--- a/Tests/RunCMake/CommandLine/E_tar-bad-from2-result.txt
+++ b/Tests/RunCMake/CommandLineTar/bad-from5-result.txt
diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from4-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-from5-stderr.txt
index 1417d4d..1417d4d 100644
--- a/Tests/RunCMake/CommandLine/E_tar-bad-from4-stderr.txt
+++ b/Tests/RunCMake/CommandLineTar/bad-from5-stderr.txt
diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from5.txt b/Tests/RunCMake/CommandLineTar/bad-from5.txt
index 9ea755b..9ea755b 100644
--- a/Tests/RunCMake/CommandLine/E_tar-bad-from5.txt
+++ b/Tests/RunCMake/CommandLineTar/bad-from5.txt
diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-from1-result.txt b/Tests/RunCMake/CommandLineTar/bad-mtime1-result.txt
index d00491f..d00491f 100644
--- a/Tests/RunCMake/CommandLine/E_tar-bad-from1-result.txt
+++ b/Tests/RunCMake/CommandLineTar/bad-mtime1-result.txt
diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-mtime1-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-mtime1-stderr.txt
index ca925f1..ca925f1 100644
--- a/Tests/RunCMake/CommandLine/E_tar-bad-mtime1-stderr.txt
+++ b/Tests/RunCMake/CommandLineTar/bad-mtime1-stderr.txt
diff --git a/Tests/RunCMake/CommandLineTar/bad-opt1-result.txt b/Tests/RunCMake/CommandLineTar/bad-opt1-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/bad-opt1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-opt1-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-opt1-stderr.txt
index 35133c8..35133c8 100644
--- a/Tests/RunCMake/CommandLine/E_tar-bad-opt1-stderr.txt
+++ b/Tests/RunCMake/CommandLineTar/bad-opt1-stderr.txt
diff --git a/Tests/RunCMake/CommandLineTar/end-opt1-result.txt b/Tests/RunCMake/CommandLineTar/end-opt1-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/end-opt1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_tar-end-opt1-stderr.txt b/Tests/RunCMake/CommandLineTar/end-opt1-stderr.txt
index 1fddf6d..1fddf6d 100644
--- a/Tests/RunCMake/CommandLine/E_tar-end-opt1-stderr.txt
+++ b/Tests/RunCMake/CommandLineTar/end-opt1-stderr.txt
diff --git a/Tests/RunCMake/CommandLineTar/gnutar-gz.cmake b/Tests/RunCMake/CommandLineTar/gnutar-gz.cmake
new file mode 100644
index 0000000..5f2674a
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/gnutar-gz.cmake
@@ -0,0 +1,10 @@
+set(OUTPUT_NAME "test.tar.gz")
+
+set(COMPRESSION_FLAGS cvzf)
+set(COMPRESSION_OPTIONS --format=gnutar)
+
+set(DECOMPRESSION_FLAGS xvzf)
+
+include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
+
+check_magic("1f8b" LIMIT 2 HEX)
diff --git a/Tests/RunCMake/CommandLineTar/gnutar.cmake b/Tests/RunCMake/CommandLineTar/gnutar.cmake
new file mode 100644
index 0000000..aaca596
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/gnutar.cmake
@@ -0,0 +1,10 @@
+set(OUTPUT_NAME "test.tar")
+
+set(COMPRESSION_FLAGS cvf)
+set(COMPRESSION_OPTIONS --format=gnutar)
+
+set(DECOMPRESSION_FLAGS xvf)
+
+include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
+
+check_magic("7573746172202000" OFFSET 257 LIMIT 8 HEX)
diff --git a/Tests/RunCMake/CommandLineTar/pax-xz.cmake b/Tests/RunCMake/CommandLineTar/pax-xz.cmake
new file mode 100644
index 0000000..baf63d5
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/pax-xz.cmake
@@ -0,0 +1,10 @@
+set(OUTPUT_NAME "test.tar.xz")
+
+set(COMPRESSION_FLAGS cvJf)
+set(COMPRESSION_OPTIONS --format=pax)
+
+set(DECOMPRESSION_FLAGS xvJf)
+
+include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
+
+check_magic("fd377a585a00" LIMIT 6 HEX)
diff --git a/Tests/RunCMake/CommandLineTar/pax.cmake b/Tests/RunCMake/CommandLineTar/pax.cmake
new file mode 100644
index 0000000..60ed238
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/pax.cmake
@@ -0,0 +1,10 @@
+set(OUTPUT_NAME "test.tar")
+
+set(COMPRESSION_FLAGS cvf)
+set(COMPRESSION_OPTIONS --format=pax)
+
+set(DECOMPRESSION_FLAGS xvf)
+
+include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
+
+check_magic("7573746172003030" OFFSET 257 LIMIT 8 HEX)
diff --git a/Tests/RunCMake/CommandLineTar/paxr-bz2.cmake b/Tests/RunCMake/CommandLineTar/paxr-bz2.cmake
new file mode 100644
index 0000000..881a0af
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/paxr-bz2.cmake
@@ -0,0 +1,10 @@
+set(OUTPUT_NAME "test.tar.bz2")
+
+set(COMPRESSION_FLAGS cvjf)
+set(COMPRESSION_OPTIONS --format=paxr)
+
+set(DECOMPRESSION_FLAGS xvjf)
+
+include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
+
+check_magic("425a68" LIMIT 3 HEX)
diff --git a/Tests/RunCMake/CommandLineTar/paxr.cmake b/Tests/RunCMake/CommandLineTar/paxr.cmake
new file mode 100644
index 0000000..968a103
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/paxr.cmake
@@ -0,0 +1,10 @@
+set(OUTPUT_NAME "test.tar")
+
+set(COMPRESSION_FLAGS cvf)
+set(COMPRESSION_OPTIONS --format=paxr)
+
+set(DECOMPRESSION_FLAGS xvf)
+
+include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
+
+check_magic("7573746172003030" OFFSET 257 LIMIT 8 HEX)
diff --git a/Tests/RunCMake/CommandLineTar/roundtrip.cmake b/Tests/RunCMake/CommandLineTar/roundtrip.cmake
new file mode 100644
index 0000000..dc1c885
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/roundtrip.cmake
@@ -0,0 +1,81 @@
+foreach(parameter OUTPUT_NAME COMPRESSION_FLAGS DECOMPRESSION_FLAGS)
+ if(NOT DEFINED ${parameter})
+ message(FATAL_ERROR "missing required parameter ${parameter}")
+ endif()
+endforeach()
+
+function(run_tar WORKING_DIRECTORY)
+ execute_process(COMMAND ${CMAKE_COMMAND} -E tar ${ARGN}
+ WORKING_DIRECTORY ${WORKING_DIRECTORY}
+ RESULT_VARIABLE result
+ )
+
+ if(NOT result STREQUAL "0")
+ message(FATAL_ERROR "tar failed with arguments [${ARGN}] result [${result}]")
+ endif()
+endfunction()
+
+set(COMPRESS_DIR compress_dir)
+set(FULL_COMPRESS_DIR ${CMAKE_CURRENT_BINARY_DIR}/${COMPRESS_DIR})
+
+set(DECOMPRESS_DIR decompress_dir)
+set(FULL_DECOMPRESS_DIR ${CMAKE_CURRENT_BINARY_DIR}/${DECOMPRESS_DIR})
+
+set(FULL_OUTPUT_NAME ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME})
+
+set(CHECK_FILES
+ "f1.txt"
+ "d1/f1.txt"
+ "d 2/f1.txt"
+ "d + 3/f1.txt"
+ "d_4/f1.txt"
+ "d-4/f1.txt"
+ "My Special Directory/f1.txt"
+)
+
+foreach(file ${CHECK_FILES})
+ configure_file(${CMAKE_CURRENT_LIST_FILE} ${FULL_COMPRESS_DIR}/${file} COPYONLY)
+endforeach()
+
+if(UNIX)
+ execute_process(COMMAND ln -sf f1.txt ${FULL_COMPRESS_DIR}/d1/f2.txt)
+ list(APPEND CHECK_FILES "d1/f2.txt")
+endif()
+
+file(REMOVE ${FULL_OUTPUT_NAME})
+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})
+
+foreach(file ${CHECK_FILES})
+ set(input ${FULL_COMPRESS_DIR}/${file})
+ set(output ${FULL_DECOMPRESS_DIR}/${COMPRESS_DIR}/${file})
+
+ if(NOT EXISTS ${input})
+ message(SEND_ERROR "Cannot find input file ${output}")
+ endif()
+
+ if(NOT EXISTS ${output})
+ message(SEND_ERROR "Cannot find output file ${output}")
+ endif()
+
+ file(MD5 ${input} input_md5)
+ file(MD5 ${output} output_md5)
+
+ if(NOT input_md5 STREQUAL output_md5)
+ message(SEND_ERROR "Files \"${input}\" and \"${output}\" are different")
+ endif()
+endforeach()
+
+function(check_magic EXPECTED)
+ file(READ ${FULL_OUTPUT_NAME} ACTUAL
+ ${ARGN}
+ )
+
+ if(NOT ACTUAL STREQUAL EXPECTED)
+ message(FATAL_ERROR
+ "Actual [${ACTUAL}] does not match expected [${EXPECTED}]")
+ endif()
+endfunction()
diff --git a/Tests/RunCMake/CommandLineTar/zip-bz2-result.txt b/Tests/RunCMake/CommandLineTar/zip-bz2-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/zip-bz2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLineTar/zip-bz2-stderr.txt b/Tests/RunCMake/CommandLineTar/zip-bz2-stderr.txt
new file mode 100644
index 0000000..1134b4f
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/zip-bz2-stderr.txt
@@ -0,0 +1 @@
+CMake Error: Can not use compression flags with format: zip
diff --git a/Tests/RunCMake/CommandLineTar/zip.cmake b/Tests/RunCMake/CommandLineTar/zip.cmake
new file mode 100644
index 0000000..08e2fdb
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/zip.cmake
@@ -0,0 +1,10 @@
+set(OUTPUT_NAME "test.zip")
+
+set(COMPRESSION_FLAGS cvf)
+set(COMPRESSION_OPTIONS --format=zip)
+
+set(DECOMPRESSION_FLAGS xvf)
+
+include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
+
+check_magic("504b0304" LIMIT 4 HEX)