[Cmake-commits] CMake branch, next, updated. v3.3.0-rc1-133-g24bc47b

Domen Vrankar domen.vrankar at gmail.com
Fri Jun 5 15:19:11 EDT 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  24bc47b6ac2b29d32157d56a05c92b17af9cbbcf (commit)
       via  8b4b2ca686abfbc4f74496c2c6a17c1fe3f646c2 (commit)
       via  5aec9ec2daa282453fffd8d382876f467936a277 (commit)
      from  f6cb54884b64cac39a4a6799c3572c84997c7dc8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=24bc47b6ac2b29d32157d56a05c92b17af9cbbcf
commit 24bc47b6ac2b29d32157d56a05c92b17af9cbbcf
Merge: f6cb548 8b4b2ca
Author:     Domen Vrankar <domen.vrankar at gmail.com>
AuthorDate: Fri Jun 5 15:19:10 2015 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Fri Jun 5 15:19:10 2015 -0400

    Merge topic 'cpack-rpm-and-deb-runcmake-tests' into next
    
    8b4b2ca6 CPack RPM PARTIALLY_RELOCATABLE_WARNING test move
    5aec9ec2 CPack Deb and RPM RunCMake tests


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8b4b2ca686abfbc4f74496c2c6a17c1fe3f646c2
commit 8b4b2ca686abfbc4f74496c2c6a17c1fe3f646c2
Author:     Domen Vrankar <domen.vrankar at gmail.com>
AuthorDate: Fri Jun 5 21:12:08 2015 +0200
Commit:     Domen Vrankar <domen.vrankar at gmail.com>
CommitDate: Fri Jun 5 21:12:08 2015 +0200

    CPack RPM PARTIALLY_RELOCATABLE_WARNING test move
    
    Moved PARTIALLY_RELOCATABLE_WARNING test
    to new common CPack test script structure
    to have all tests in one place as well
    as additional benefit of having some more
    checks done during test execution.

diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 86e6009..4a4f54f 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -226,7 +226,6 @@ add_RunCMake_test(IfacePaths_SOURCES TEST_DIR IfacePaths)
 
 # CPack related tests
 if(RPMBUILD_EXECUTABLE)
-  add_RunCMake_test(CPackRPM)
   list(APPEND CPACK_TEST_GENERATORS "RPM")
 endif()
 
diff --git a/Tests/RunCMake/CPackRPM/CPackRPM_PARTIALLY_RELOCATABLE_WARNING.cmake b/Tests/RunCMake/CPack/PARTIALLY_RELOCATABLE_WARNING.cmake
similarity index 100%
rename from Tests/RunCMake/CPackRPM/CPackRPM_PARTIALLY_RELOCATABLE_WARNING.cmake
rename to Tests/RunCMake/CPack/PARTIALLY_RELOCATABLE_WARNING.cmake
diff --git a/Tests/RunCMake/CPack/RPM/PARTIALLY_RELOCATABLE_WARNING-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/PARTIALLY_RELOCATABLE_WARNING-ExpectedFiles.cmake
new file mode 100644
index 0000000..4e01f7b
--- /dev/null
+++ b/Tests/RunCMake/CPack/RPM/PARTIALLY_RELOCATABLE_WARNING-ExpectedFiles.cmake
@@ -0,0 +1,5 @@
+set(whitespaces_ "[\t\n\r ]*")
+
+set(EXPECTED_FILES_COUNT "1")
+set(EXPECTED_FILE_1 "PARTIALLY_RELOCATABLE_WARNING-0.1.1-*.rpm")
+set(EXPECTED_FILE_CONTENT_1 "^/not_relocatable${whitespaces_}/not_relocatable/CMakeLists.txt${whitespaces_}/opt$")
diff --git a/Tests/RunCMake/CPackRPM/CPackRPM_PARTIALLY_RELOCATABLE_WARNING-stderr.txt b/Tests/RunCMake/CPack/RPM/PARTIALLY_RELOCATABLE_WARNING-stderr.txt
similarity index 100%
rename from Tests/RunCMake/CPackRPM/CPackRPM_PARTIALLY_RELOCATABLE_WARNING-stderr.txt
rename to Tests/RunCMake/CPack/RPM/PARTIALLY_RELOCATABLE_WARNING-stderr.txt
diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake
index a7b6060..e4027ab 100644
--- a/Tests/RunCMake/CPack/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake
@@ -3,3 +3,4 @@ include("${RunCMake_SOURCE_DIR}/CPackTestHelpers.cmake")
 
 # args: TEST_NAME "GENERATORS" RUN_CMAKE_BUILD_STEP
 run_cpack_test(MINIMAL "RPM;DEB" false)
+run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM" false)
diff --git a/Tests/RunCMake/CPackRPM/CMakeLists.txt b/Tests/RunCMake/CPackRPM/CMakeLists.txt
deleted file mode 100644
index b7d170b..0000000
--- a/Tests/RunCMake/CPackRPM/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
-
-project(${RunCMake_TEST} NONE)
-include(${RunCMake_TEST}.cmake)
-
-set(CPACK_GENERATOR "RPM")
-include(CPack)
diff --git a/Tests/RunCMake/CPackRPM/RunCMakeTest.cmake b/Tests/RunCMake/CPackRPM/RunCMakeTest.cmake
deleted file mode 100644
index 1935e32..0000000
--- a/Tests/RunCMake/CPackRPM/RunCMakeTest.cmake
+++ /dev/null
@@ -1,17 +0,0 @@
-include(RunCMake)
-
-function(run_cpack_rpm_test TEST_NAME)
-  set(RunCMake_TEST_NO_CLEAN TRUE)
-  set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${TEST_NAME}-build")
-  file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
-  file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
-  execute_process(
-    COMMAND "${CMAKE_COMMAND}" -D RunCMake_TEST=${TEST_NAME} "${RunCMake_SOURCE_DIR}"
-    WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}"
-    OUTPUT_QUIET
-    ERROR_QUIET
-    )
-  run_cmake_command(${TEST_NAME} ${CMAKE_CPACK_COMMAND})
-endfunction()
-
-run_cpack_rpm_test(CPackRPM_PARTIALLY_RELOCATABLE_WARNING)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5aec9ec2daa282453fffd8d382876f467936a277
commit 5aec9ec2daa282453fffd8d382876f467936a277
Author:     Domen Vrankar <domen.vrankar at gmail.com>
AuthorDate: Fri Jun 5 21:03:26 2015 +0200
Commit:     Domen Vrankar <domen.vrankar at gmail.com>
CommitDate: Fri Jun 5 21:03:26 2015 +0200

    CPack Deb and RPM RunCMake tests
    
    CTest script structure for easier addition
    of new CPack related tests.

diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 592b5e4..86e6009 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -26,6 +26,24 @@ macro(add_RunCMake_test test)
     )
 endmacro()
 
+function(add_RunCMake_test_group test types)
+  set(Test_Dir ${test})
+
+  foreach(type IN LISTS types)
+    add_test(NAME RunCMake.${test}_${type} COMMAND ${CMAKE_CMAKE_COMMAND}
+      -DTEST_TYPE=${type}
+      -DCMAKE_MODULE_PATH=${CMAKE_CURRENT_SOURCE_DIR}
+      -DRunCMake_GENERATOR=${CMAKE_GENERATOR}
+      -DRunCMake_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
+      -DRunCMake_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET}
+      -DRunCMake_MAKE_PROGRAM=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
+      -DRunCMake_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/${Test_Dir}
+      -DRunCMake_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/${type}/${test}
+      -P "${CMAKE_CURRENT_SOURCE_DIR}/${Test_Dir}/RunCMakeTest.cmake"
+      )
+  endforeach()
+endfunction()
+
 if(XCODE_VERSION AND "${XCODE_VERSION}" VERSION_LESS 3)
   set(GeneratorToolset_ARGS -DXCODE_BELOW_3=1)
 endif()
@@ -206,10 +224,19 @@ add_RunCMake_test(IfacePaths_INCLUDE_DIRECTORIES TEST_DIR IfacePaths)
 set(IfacePaths_SOURCES_ARGS -DTEST_PROP=SOURCES)
 add_RunCMake_test(IfacePaths_SOURCES TEST_DIR IfacePaths)
 
+# CPack related tests
 if(RPMBUILD_EXECUTABLE)
   add_RunCMake_test(CPackRPM)
+  list(APPEND CPACK_TEST_GENERATORS "RPM")
 endif()
 
+if(DPKG_EXECUTABLE)
+  list(APPEND CPACK_TEST_GENERATORS "DEB")
+endif()
+
+add_RunCMake_test_group(CPack "${CPACK_TEST_GENERATORS}")
+# end of CPack related tests
+
 add_RunCMake_test(COMPILE_LANGUAGE-genex)
 
 # Matlab module related tests
diff --git a/Tests/RunCMake/CPack/CMakeLists.txt b/Tests/RunCMake/CPack/CMakeLists.txt
new file mode 100644
index 0000000..7905706
--- /dev/null
+++ b/Tests/RunCMake/CPack/CMakeLists.txt
@@ -0,0 +1,12 @@
+cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
+
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
+
+# include test generator specifics
+if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${GENERATOR_TYPE}/${RunCMake_TEST}-specifics.cmake")
+  include("${GENERATOR_TYPE}/${RunCMake_TEST}-specifics.cmake")
+endif()
+
+set(CPACK_GENERATOR "${GENERATOR_TYPE}")
+include(CPack)
diff --git a/Tests/RunCMake/CPack/CPackTestHelpers.cmake b/Tests/RunCMake/CPack/CPackTestHelpers.cmake
new file mode 100644
index 0000000..395fe22
--- /dev/null
+++ b/Tests/RunCMake/CPack/CPackTestHelpers.cmake
@@ -0,0 +1,75 @@
+cmake_policy(SET CMP0057 NEW)
+
+function(run_cpack_test TEST_NAME types build)
+  if(TEST_TYPE IN_LIST types)
+    set(RunCMake_TEST_NO_CLEAN TRUE)
+    set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${TEST_NAME}-build")
+
+     # TODO this should be executed only once per ctest run (not per generator)
+    file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+    file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+
+    # execute cmake
+    execute_process(
+      COMMAND "${CMAKE_COMMAND}" -DRunCMake_TEST=${TEST_NAME}
+          -DGENERATOR_TYPE=${TEST_TYPE} "${RunCMake_SOURCE_DIR}"
+      WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}"
+      RESULT_VARIABLE res
+      OUTPUT_FILE "${RunCMake_TEST_BINARY_DIR}/test_output.txt"
+      ERROR_FILE "${RunCMake_TEST_BINARY_DIR}/test_error.txt"
+      )
+
+    if(res)
+      run_cmake_command(
+        ${TEST_TYPE}/${TEST_NAME}
+        "${CMAKE_COMMAND}"
+          -DRunCMake_TEST_STEP=configure
+          -Dreturn_code=${res}
+          "-Dbin_dir=${RunCMake_TEST_BINARY_DIR}"
+          -P "${RunCMake_SOURCE_DIR}/PreTestError.cmake"
+        )
+      return()
+    endif()
+
+    # execute optional build step
+    if(build)
+      execute_process(
+        COMMAND "${CMAKE_COMMAND}" --build "${RunCMake_TEST_BINARY_DIR}"
+        RESULT_VARIABLE res
+        OUTPUT_FILE "${RunCMake_TEST_BINARY_DIR}/test_output.txt"
+        ERROR_FILE "${RunCMake_TEST_BINARY_DIR}/test_error.txt"
+        )
+    endif()
+
+    if(res)
+      run_cmake_command(
+        ${TEST_TYPE}/${TEST_NAME}
+        "${CMAKE_COMMAND}"
+          -DRunCMake_TEST_STEP=build
+          -Dreturn_code=${res}
+          "-Dbin_dir=${RunCMake_TEST_BINARY_DIR}"
+          -P "${RunCMake_SOURCE_DIR}/PreTestError.cmake"
+        )
+      return()
+    endif()
+
+    # execute cpack
+    execute_process(
+      COMMAND "${CMAKE_CPACK_COMMAND}"
+      WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}"
+      OUTPUT_FILE "${RunCMake_TEST_BINARY_DIR}/test_output.txt"
+      ERROR_FILE "${RunCMake_TEST_BINARY_DIR}/test_error.txt"
+      )
+
+    # verify result
+    run_cmake_command(
+      ${TEST_TYPE}/${TEST_NAME}
+      "${CMAKE_COMMAND}"
+        -DRunCMake_TEST=${TEST_NAME}
+        -DGENERATOR_TYPE=${TEST_TYPE}
+        "-Dsrc_dir=${RunCMake_SOURCE_DIR}"
+        "-Dbin_dir=${RunCMake_TEST_BINARY_DIR}"
+        -P "${RunCMake_SOURCE_DIR}/VerifyResult.cmake"
+      )
+  endif()
+endfunction()
diff --git a/Tests/RunCMake/CPack/DEB/Helpers.cmake b/Tests/RunCMake/CPack/DEB/Helpers.cmake
new file mode 100644
index 0000000..f0fa932
--- /dev/null
+++ b/Tests/RunCMake/CPack/DEB/Helpers.cmake
@@ -0,0 +1,15 @@
+set(ALL_FILES_GLOB "*.deb")
+
+find_program(DEB_EXECUTABLE dpkg)
+if(NOT DEB_EXECUTABLE)
+  message(FATAL_ERROR "error: missing dpkg executable required by the test")
+endif()
+
+function(getPackageContent FILE RESULT_VAR)
+  execute_process(COMMAND ${DEB_EXECUTABLE} -c ${FILE}
+          OUTPUT_VARIABLE package_content_
+          ERROR_QUIET
+          OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+  set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE)
+endfunction()
diff --git a/Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake
new file mode 100644
index 0000000..9e4aa7c
--- /dev/null
+++ b/Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake
@@ -0,0 +1,5 @@
+set(whitespaces_ "[\t\n\r ]*")
+
+set(EXPECTED_FILES_COUNT "1")
+set(EXPECTED_FILE_1 "minimal*.deb")
+set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/foo/${whitespaces_}.*/usr/foo/CMakeLists.txt$")
diff --git a/Tests/RunCMake/CPack/DEB/MINIMAL-specifics.cmake b/Tests/RunCMake/CPack/DEB/MINIMAL-specifics.cmake
new file mode 100644
index 0000000..8821ab9
--- /dev/null
+++ b/Tests/RunCMake/CPack/DEB/MINIMAL-specifics.cmake
@@ -0,0 +1 @@
+set(CPACK_PACKAGE_CONTACT "someone")
diff --git a/Tests/RunCMake/CPack/MINIMAL.cmake b/Tests/RunCMake/CPack/MINIMAL.cmake
new file mode 100644
index 0000000..f29ad2a
--- /dev/null
+++ b/Tests/RunCMake/CPack/MINIMAL.cmake
@@ -0,0 +1,3 @@
+install(FILES CMakeLists.txt DESTINATION foo COMPONENT test)
+
+set(CPACK_PACKAGE_NAME "minimal")
diff --git a/Tests/RunCMake/CPack/PreTestError.cmake b/Tests/RunCMake/CPack/PreTestError.cmake
new file mode 100644
index 0000000..f88f2e8
--- /dev/null
+++ b/Tests/RunCMake/CPack/PreTestError.cmake
@@ -0,0 +1,7 @@
+file(READ "${bin_dir}/test_output.txt" output)
+file(READ "${bin_dir}/test_error.txt" error)
+
+message(FATAL_ERROR "Error in pre-test phase '${RunCMake_TEST_STEP}'!\n"
+        "Return code: '${return_code}'\n"
+        "Info output: '${output}'\n"
+        "Error output: '${error}'")
diff --git a/Tests/RunCMake/CPack/README.txt b/Tests/RunCMake/CPack/README.txt
new file mode 100644
index 0000000..d00f688
--- /dev/null
+++ b/Tests/RunCMake/CPack/README.txt
@@ -0,0 +1,91 @@
+RunCMake.CPack is a test module that is intended for testing of package
+generators that can be validated from command line.
+
+-------------
+Adding a test
+-------------
+
+CPack test root directory: 'Tests/RunCMake/CPack'.
+
+All phases are executed separately for each generator that is bound to a test.
+Tests for each generator are subtests of test 'RunCMake.CPack_<generator_name>'.
+
+Each test must also be added to 'RunCMakeTest.cmake' script located in Cpack
+test root directory.
+Line that adds a test is:
+run_cpack_test(<test_name> "<generator_name>")
+
+<generator_name> may be one generator e.g. "RPM" or multiple e.g. "RPM;DEB" and
+will be run for all listed generators.
+
+Test consists of
+- CMake execution phase
+- CPack execution phase
+- verification of generated files
+
+CMake execution phase:
+----------------------
+
+To add a new CPack test we first create a <test_name>.cmake script that contains
+CMake commands that should be used as a preparation script for generation of
+different types of packages. This script is placed into CPack test root
+directory even if it will be used for only one of the generators.
+
+If test will be used for multiple generators but some of them require some
+generator speciffic commands then those commands should be added to a separate
+file that should be located in '<generator_name>/<test_name>-specifics.cmake'
+in CPack test root directory.
+
+CPack execution phase:
+----------------------
+
+Only exececutes CPack for content that was generated during CMake execution
+phase.
+
+Verification of generated files:
+--------------------------------
+
+Verification of generated files consists of two phases
+- mandatory verification phase
+- optional verification phase
+
+Mandatory verification phase checks that expected files were generated and
+contain expected files.
+Mandatory verification phase also checks that no other unexpected package files
+were generated (this is executed even if EXPECTED_FILES_COUNT contains 0 in
+order to verify that no files were generated).
+CMake script '<generator_name>/<test_name>-ExpectedFiles.cmake' is required by
+this step and must contain
+- EXPECTED_FILES_COUNT variable that contains the number of expected files that
+  will be generated (0 or more)
+- EXPECTED_FILE_<file_number_starting_with_1> that contains globbing expression
+  that uniquelly defines expected file name (will be used to find expected file)
+  and should be present once for each expected file
+- EXPECTED_FILE_CONTENT_<file_number_starting_with_1> that contains regular
+  expression of files that should be present in generated file and should be
+  present once for each expected file
+
+Optional verification phase is generator speciffic and is optionaly executed.
+This phase is executed if '<generator_name>/<test_name>-VerifyResult.cmake'
+script exists.
+In case that the script doesn't exist VerifyResult.cmake script automatically
+prints out standard outpu and standard error from CPack execution phase that
+is compared with '<generator_name>/<test_name>-stdout.txt' regular expression
+and '<generator_name>/<test_name>-stderr.txt' regular expresson respectively.
+
+----------------------
+Adding a new generator
+----------------------
+
+To add a new generator we must
+- add new generator directory (e.g. RPM for RPM generator) to CPack test root
+  directory that contains 'Helpers.cmake' script. In this script a function
+  named 'getPackageContent' must exist. This function should list files that
+  are contained in a package. Function should accept two parameters
+  + FILE variable that will contain path to file for which the content should be
+    listed
+  + RESULT_VAR that will tell the function which variable in parent scope should
+    contain the result (list of files inside package file)
+- add tests the same way as described above
+- add generator to 'add_RunCMake_test_group' function call that is located in
+  RunCMake CMakeLists.txt file
diff --git a/Tests/RunCMake/CPack/RPM/Helpers.cmake b/Tests/RunCMake/CPack/RPM/Helpers.cmake
new file mode 100644
index 0000000..0e2dca9
--- /dev/null
+++ b/Tests/RunCMake/CPack/RPM/Helpers.cmake
@@ -0,0 +1,15 @@
+set(ALL_FILES_GLOB "*.rpm")
+
+find_program(RPM_EXECUTABLE rpm)
+if(NOT RPM_EXECUTABLE)
+  message(FATAL_ERROR "error: missing rpm executable required by the test")
+endif()
+
+function(getPackageContent FILE RESULT_VAR)
+  execute_process(COMMAND ${RPM_EXECUTABLE} -pql ${FILE}
+          OUTPUT_VARIABLE package_content_
+          ERROR_QUIET
+          OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+  set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE)
+endfunction()
diff --git a/Tests/RunCMake/CPack/RPM/MINIMAL-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/MINIMAL-ExpectedFiles.cmake
new file mode 100644
index 0000000..800b78e
--- /dev/null
+++ b/Tests/RunCMake/CPack/RPM/MINIMAL-ExpectedFiles.cmake
@@ -0,0 +1,5 @@
+set(whitespaces_ "[\t\n\r ]*")
+
+set(EXPECTED_FILES_COUNT "1")
+set(EXPECTED_FILE_1 "minimal*.rpm")
+set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$")
diff --git a/Tests/RunCMake/CPack/RPM/MINIMAL-stderr.txt b/Tests/RunCMake/CPack/RPM/MINIMAL-stderr.txt
new file mode 100644
index 0000000..7c5fb46
--- /dev/null
+++ b/Tests/RunCMake/CPack/RPM/MINIMAL-stderr.txt
@@ -0,0 +1 @@
+^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/MINIMAL-build/_CPack_Packages/.*/RPM/SPECS/minimal.spec$
diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake
new file mode 100644
index 0000000..a7b6060
--- /dev/null
+++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake
@@ -0,0 +1,5 @@
+include(RunCMake)
+include("${RunCMake_SOURCE_DIR}/CPackTestHelpers.cmake")
+
+# args: TEST_NAME "GENERATORS" RUN_CMAKE_BUILD_STEP
+run_cpack_test(MINIMAL "RPM;DEB" false)
diff --git a/Tests/RunCMake/CPack/VerifyResult.cmake b/Tests/RunCMake/CPack/VerifyResult.cmake
new file mode 100644
index 0000000..d9f32c5
--- /dev/null
+++ b/Tests/RunCMake/CPack/VerifyResult.cmake
@@ -0,0 +1,81 @@
+cmake_policy(SET CMP0007 NEW)
+
+include("${src_dir}/${GENERATOR_TYPE}/Helpers.cmake")
+
+# check that expected generated files exist and contain expected content
+include("${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST}-ExpectedFiles.cmake")
+
+if(NOT EXPECTED_FILES_COUNT EQUAL 0)
+  foreach(file_no_ RANGE 1 ${EXPECTED_FILES_COUNT})
+    file(GLOB foundFile_ RELATIVE "${bin_dir}" "${EXPECTED_FILE_${file_no_}}")
+    set(foundFiles_ "${foundFiles_};${foundFile_}")
+    list(LENGTH foundFile_ foundFilesCount_)
+
+    if(foundFilesCount_ EQUAL 1)
+      unset(PACKAGE_CONTENT)
+      getPackageContent("${bin_dir}/${foundFile_}" "PACKAGE_CONTENT")
+
+      string(REGEX MATCH "${EXPECTED_FILE_CONTENT_${file_no_}}"
+          expected_content_list "${PACKAGE_CONTENT}")
+
+      if(NOT expected_content_list)
+        message(FATAL_ERROR
+          "Unexpected file content for file No. '${file_no_}'!"
+          " Content: '${PACKAGE_CONTENT}'")
+      endif()
+    else()
+      message(FATAL_ERROR
+        "Found more than one file for file No. '${file_no_}'!"
+        " Found files count '${foundFilesCount_}'."
+        " Files: '${foundFile_}'")
+    endif()
+  endforeach()
+
+  # check that there were no extra files generated
+  foreach(all_files_glob_ IN LISTS ALL_FILES_GLOB)
+    file(GLOB foundAll_ RELATIVE "${bin_dir}" "${all_files_glob_}")
+    set(allFoundFiles_ "${allFoundFiles_};${foundAll_}")
+  endforeach()
+
+  list(LENGTH foundFiles_ foundFilesCount_)
+  list(LENGTH allFoundFiles_ allFoundFilesCount_)
+
+  if(NOT foundFilesCount_ EQUAL allFoundFilesCount_)
+    message(FATAL_ERROR
+        "Found more files than expected! Found files: '${allFoundFiles_}'")
+  endif()
+
+  # sanity check that we didn't accidentaly list wrong files with our regular
+  # expressions
+  foreach(expected_ IN LISTS allFoundFiles_)
+    list(FIND foundFiles_ "${expected_}" found_)
+
+    if(found_ EQUAL -1)
+      message(FATAL_ERROR
+          "Expected files don't match found files! Found files:"
+          " '${allFoundFiles_}'")
+    endif()
+  endforeach()
+else()
+  # there should be no generated files present
+  foreach(missing_file_glob_ IN LISTS ALL_FILES_GLOB)
+    file(GLOB checkMissingFiles_ RELATIVE "${bin_dir}" "${missing_file_glob_}")
+
+    if(checkMissingFiles_)
+      message(FATAL_ERROR "Unexpected files found: '${checkMissingFiles_}'")
+    endif()
+  endforeach()
+endif()
+
+file(READ "${bin_dir}/test_output.txt" output)
+file(READ "${bin_dir}/test_error.txt" error)
+
+# handle additional result verifications
+if(EXISTS "${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST}-VerifyResult.cmake")
+  include("${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST}-VerifyResult.cmake")
+else()
+  # by default only print out output and error so that they can be compared by
+  # regex
+  message(STATUS "${output}")
+  message("${error}")
+endif()

-----------------------------------------------------------------------

Summary of changes:
 Tests/RunCMake/CMakeLists.txt                      |   28 +++++-
 Tests/RunCMake/CPack/CMakeLists.txt                |   12 +++
 Tests/RunCMake/CPack/CPackTestHelpers.cmake        |   75 ++++++++++++++++
 Tests/RunCMake/CPack/DEB/Helpers.cmake             |   15 ++++
 .../RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake |    5 ++
 Tests/RunCMake/CPack/DEB/MINIMAL-specifics.cmake   |    1 +
 Tests/RunCMake/CPack/MINIMAL.cmake                 |    3 +
 .../PARTIALLY_RELOCATABLE_WARNING.cmake}           |    0
 Tests/RunCMake/CPack/PreTestError.cmake            |    7 ++
 Tests/RunCMake/CPack/README.txt                    |   91 ++++++++++++++++++++
 Tests/RunCMake/CPack/RPM/Helpers.cmake             |   15 ++++
 .../RunCMake/CPack/RPM/MINIMAL-ExpectedFiles.cmake |    5 ++
 Tests/RunCMake/CPack/RPM/MINIMAL-stderr.txt        |    1 +
 ...RTIALLY_RELOCATABLE_WARNING-ExpectedFiles.cmake |    5 ++
 .../RPM/PARTIALLY_RELOCATABLE_WARNING-stderr.txt}  |    0
 Tests/RunCMake/CPack/RunCMakeTest.cmake            |    6 ++
 Tests/RunCMake/CPack/VerifyResult.cmake            |   81 +++++++++++++++++
 Tests/RunCMake/CPackRPM/CMakeLists.txt             |    7 --
 Tests/RunCMake/CPackRPM/RunCMakeTest.cmake         |   17 ----
 19 files changed, 349 insertions(+), 25 deletions(-)
 create mode 100644 Tests/RunCMake/CPack/CMakeLists.txt
 create mode 100644 Tests/RunCMake/CPack/CPackTestHelpers.cmake
 create mode 100644 Tests/RunCMake/CPack/DEB/Helpers.cmake
 create mode 100644 Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake
 create mode 100644 Tests/RunCMake/CPack/DEB/MINIMAL-specifics.cmake
 create mode 100644 Tests/RunCMake/CPack/MINIMAL.cmake
 rename Tests/RunCMake/{CPackRPM/CPackRPM_PARTIALLY_RELOCATABLE_WARNING.cmake => CPack/PARTIALLY_RELOCATABLE_WARNING.cmake} (100%)
 create mode 100644 Tests/RunCMake/CPack/PreTestError.cmake
 create mode 100644 Tests/RunCMake/CPack/README.txt
 create mode 100644 Tests/RunCMake/CPack/RPM/Helpers.cmake
 create mode 100644 Tests/RunCMake/CPack/RPM/MINIMAL-ExpectedFiles.cmake
 create mode 100644 Tests/RunCMake/CPack/RPM/MINIMAL-stderr.txt
 create mode 100644 Tests/RunCMake/CPack/RPM/PARTIALLY_RELOCATABLE_WARNING-ExpectedFiles.cmake
 rename Tests/RunCMake/{CPackRPM/CPackRPM_PARTIALLY_RELOCATABLE_WARNING-stderr.txt => CPack/RPM/PARTIALLY_RELOCATABLE_WARNING-stderr.txt} (100%)
 create mode 100644 Tests/RunCMake/CPack/RunCMakeTest.cmake
 create mode 100644 Tests/RunCMake/CPack/VerifyResult.cmake
 delete mode 100644 Tests/RunCMake/CPackRPM/CMakeLists.txt
 delete mode 100644 Tests/RunCMake/CPackRPM/RunCMakeTest.cmake


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list