summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-09-20 12:40:52 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2016-09-20 12:40:52 (GMT)
commit9dc5bd961146332644880e2b949854e13dbd0b8c (patch)
tree092bbd1d8d1c7c4f0f8caf28bb2f9704ecb2afab /Tests/RunCMake
parent8d83c9d100b8952ec0793e4cb0e30d5b3ec8f164 (diff)
parent1c63aa4d43f101a0d58b5b88d3119c72cadf5517 (diff)
downloadCMake-9dc5bd961146332644880e2b949854e13dbd0b8c.zip
CMake-9dc5bd961146332644880e2b949854e13dbd0b8c.tar.gz
CMake-9dc5bd961146332644880e2b949854e13dbd0b8c.tar.bz2
Merge topic 'cpack.hash_computing'
1c63aa4d CPack: Add option to generate a checksum file next to each package file 4682b42b Tests: Add subtest support to RunCMake/CPack infrastructure
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/CPack/CMakeLists.txt6
-rw-r--r--Tests/RunCMake/CPack/CPackTestHelpers.cmake40
-rw-r--r--Tests/RunCMake/CPack/PACKAGE_CHECKSUM.cmake4
-rw-r--r--Tests/RunCMake/CPack/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-ExpectedFiles.cmake9
-rw-r--r--Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-VerifyResult.cmake14
-rw-r--r--Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-invalid-stderr.txt2
-rw-r--r--Tests/RunCMake/CPack/VerifyResult.cmake6
8 files changed, 70 insertions, 12 deletions
diff --git a/Tests/RunCMake/CPack/CMakeLists.txt b/Tests/RunCMake/CPack/CMakeLists.txt
index 46f1367..e42e971 100644
--- a/Tests/RunCMake/CPack/CMakeLists.txt
+++ b/Tests/RunCMake/CPack/CMakeLists.txt
@@ -1,11 +1,11 @@
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(${RunCMake_TEST} CXX)
-include(${RunCMake_TEST}.cmake)
+include(${RunCMake_TEST_FILE_PREFIX}.cmake)
# include test generator specifics
-if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${GENERATOR_TYPE}/${RunCMake_TEST}-specifics.cmake")
- include("${GENERATOR_TYPE}/${RunCMake_TEST}-specifics.cmake")
+if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${GENERATOR_TYPE}/${RunCMake_TEST_FILE_PREFIX}-specifics.cmake")
+ include("${GENERATOR_TYPE}/${RunCMake_TEST_FILE_PREFIX}-specifics.cmake")
endif()
set(CPACK_GENERATOR "${GENERATOR_TYPE}")
diff --git a/Tests/RunCMake/CPack/CPackTestHelpers.cmake b/Tests/RunCMake/CPack/CPackTestHelpers.cmake
index 7bf42f9..5a35acd 100644
--- a/Tests/RunCMake/CPack/CPackTestHelpers.cmake
+++ b/Tests/RunCMake/CPack/CPackTestHelpers.cmake
@@ -1,9 +1,15 @@
cmake_policy(SET CMP0057 NEW)
-function(run_cpack_test TEST_NAME types build)
+function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX)
if(TEST_TYPE IN_LIST types)
set(RunCMake_TEST_NO_CLEAN TRUE)
set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${TEST_NAME}-build")
+ set(full_test_name_ "${TEST_NAME}")
+
+ if(SUBTEST_SUFFIX)
+ set(RunCMake_TEST_BINARY_DIR "${RunCMake_TEST_BINARY_DIR}-${SUBTEST_SUFFIX}-subtest")
+ set(full_test_name_ "${full_test_name_}-${SUBTEST_SUFFIX}-subtest")
+ endif()
# TODO this should be executed only once per ctest run (not per generator)
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
@@ -24,12 +30,14 @@ function(run_cpack_test TEST_NAME types build)
endif()
# execute cmake
- set(RunCMake_TEST_OPTIONS "-DGENERATOR_TYPE=${TEST_TYPE}")
- run_cmake(${TEST_NAME})
+ set(RunCMake_TEST_OPTIONS "-DGENERATOR_TYPE=${TEST_TYPE}"
+ "-DRunCMake_TEST_FILE_PREFIX=${TEST_NAME}"
+ "-DRunCMake_SUBTEST_SUFFIX=${SUBTEST_SUFFIX}")
+ run_cmake(${full_test_name_})
# execute optional build step
if(build)
- run_cmake_command(${TEST_NAME}-Build "${CMAKE_COMMAND}" --build "${RunCMake_TEST_BINARY_DIR}")
+ run_cmake_command(${full_test_name_}-Build "${CMAKE_COMMAND}" --build "${RunCMake_TEST_BINARY_DIR}")
endif()
# execute cpack
@@ -40,11 +48,21 @@ function(run_cpack_test TEST_NAME types build)
ERROR_FILE "${RunCMake_TEST_BINARY_DIR}/test_error.txt"
)
+ foreach(o out err)
+ if(SUBTEST_SUFFIX AND EXISTS ${RunCMake_SOURCE_DIR}/${TEST_TYPE}/${TEST_NAME}-${SUBTEST_SUFFIX}-std${o}.txt)
+ set(RunCMake-std${o}-file "${TEST_TYPE}/${TEST_NAME}-${SUBTEST_SUFFIX}-std${o}.txt")
+ elseif(EXISTS ${RunCMake_SOURCE_DIR}/${TEST_TYPE}/${TEST_NAME}-std${o}.txt)
+ set(RunCMake-std${o}-file "${TEST_TYPE}/${TEST_NAME}-std${o}.txt")
+ endif()
+ endforeach()
+
# verify result
run_cmake_command(
- ${TEST_TYPE}/${TEST_NAME}
+ ${TEST_TYPE}/${full_test_name_}
"${CMAKE_COMMAND}"
- -DRunCMake_TEST=${TEST_NAME}
+ -DRunCMake_TEST=${full_test_name_}
+ -DRunCMake_TEST_FILE_PREFIX=${TEST_NAME}
+ -DRunCMake_SUBTEST_SUFFIX=${SUBTEST_SUFFIX}
-DGENERATOR_TYPE=${TEST_TYPE}
"-Dsrc_dir=${RunCMake_SOURCE_DIR}"
"-Dbin_dir=${RunCMake_TEST_BINARY_DIR}"
@@ -53,3 +71,13 @@ function(run_cpack_test TEST_NAME types build)
)
endif()
endfunction()
+
+function(run_cpack_test TEST_NAME types build)
+ run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "")
+endfunction()
+
+function(run_cpack_test_subtests TEST_NAME SUBTEST_SUFFIXES types build)
+ foreach(suffix_ IN LISTS SUBTEST_SUFFIXES)
+ run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "${suffix_}")
+ endforeach()
+endfunction()
diff --git a/Tests/RunCMake/CPack/PACKAGE_CHECKSUM.cmake b/Tests/RunCMake/CPack/PACKAGE_CHECKSUM.cmake
new file mode 100644
index 0000000..5ca288c
--- /dev/null
+++ b/Tests/RunCMake/CPack/PACKAGE_CHECKSUM.cmake
@@ -0,0 +1,4 @@
+install(FILES CMakeLists.txt DESTINATION foo)
+
+set(CPACK_PACKAGE_NAME "package_checksum")
+set(CPACK_PACKAGE_CHECKSUM ${RunCMake_SUBTEST_SUFFIX})
diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake
index a3029cf..abad58b 100644
--- a/Tests/RunCMake/CPack/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake
@@ -18,3 +18,4 @@ run_cpack_test(DEB_GENERATE_SHLIBS "DEB" true)
run_cpack_test(DEB_GENERATE_SHLIBS_LDCONFIG "DEB" true)
run_cpack_test(DEBUGINFO "RPM" true)
run_cpack_test(LONG_FILENAMES "DEB" false)
+run_cpack_test_subtests(PACKAGE_CHECKSUM "invalid;MD5;SHA1;SHA224;SHA256;SHA384;SHA512" "TGZ" false)
diff --git a/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-ExpectedFiles.cmake b/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-ExpectedFiles.cmake
new file mode 100644
index 0000000..205dcd8
--- /dev/null
+++ b/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-ExpectedFiles.cmake
@@ -0,0 +1,9 @@
+set(whitespaces_ "[\t\n\r ]*")
+
+set(EXPECTED_FILES_COUNT "0")
+
+if (NOT ${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid")
+ set(EXPECTED_FILES_COUNT "1")
+ set(EXPECTED_FILE_1 "package_checksum*.tar.gz")
+ set(EXPECTED_FILE_CONTENT_1 "^[^\n]*package_checksum*-[^\n]*/foo/\n[^\n]*package_checksum-[^\n]*/foo/CMakeLists.txt$")
+endif()
diff --git a/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-VerifyResult.cmake b/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-VerifyResult.cmake
new file mode 100644
index 0000000..e9e65d6
--- /dev/null
+++ b/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-VerifyResult.cmake
@@ -0,0 +1,14 @@
+if(NOT ${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid")
+ string(TOLOWER ${RunCMake_SUBTEST_SUFFIX} EXTENSION)
+ file(GLOB PACKAGE RELATIVE ${bin_dir} "*.tar.gz")
+ file(GLOB CSUMFILE RELATIVE ${bin_dir} "*.${EXTENSION}")
+ file(STRINGS ${CSUMFILE} CHSUM_VALUE)
+ file(${RunCMake_SUBTEST_SUFFIX} ${PACKAGE} expected_value )
+ set(expected_value "${expected_value} ${PACKAGE}")
+
+ if(NOT expected_value STREQUAL CHSUM_VALUE)
+ message(FATAL_ERROR "Generated checksum is not valid! Expected [${expected_value}] Got [${CHSUM_VALUE}]")
+ endif()
+else()
+ message(${error})
+endif()
diff --git a/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-invalid-stderr.txt b/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-invalid-stderr.txt
new file mode 100644
index 0000000..abf6d8c
--- /dev/null
+++ b/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-invalid-stderr.txt
@@ -0,0 +1,2 @@
+^CPack Error: Cannot recognize algorithm: invalid
+CPack Error: Error when generating package: package_checksum$
diff --git a/Tests/RunCMake/CPack/VerifyResult.cmake b/Tests/RunCMake/CPack/VerifyResult.cmake
index 074890f..238cbfd 100644
--- a/Tests/RunCMake/CPack/VerifyResult.cmake
+++ b/Tests/RunCMake/CPack/VerifyResult.cmake
@@ -11,7 +11,7 @@ set(output_error_message
"\nCPack output: '${output}'\nCPack error: '${error}';\nconfig file: '${config_file_content}'")
# check that expected generated files exist and contain expected content
-include("${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST}-ExpectedFiles.cmake")
+include("${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST_FILE_PREFIX}-ExpectedFiles.cmake")
if(NOT EXPECTED_FILES_COUNT EQUAL 0)
foreach(file_no_ RANGE 1 ${EXPECTED_FILES_COUNT})
@@ -82,8 +82,8 @@ else()
endif()
# handle additional result verifications
-if(EXISTS "${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST}-VerifyResult.cmake")
- include("${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST}-VerifyResult.cmake")
+if(EXISTS "${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST_FILE_PREFIX}-VerifyResult.cmake")
+ include("${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST_FILE_PREFIX}-VerifyResult.cmake")
else()
# by default only print out output and error so that they can be compared by
# regex