summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CPack/CPackTestHelpers.cmake
diff options
context:
space:
mode:
authorDomen Vrankar <domen.vrankar@gmail.com>2015-06-05 19:03:26 (GMT)
committerBrad King <brad.king@kitware.com>2015-06-15 19:09:07 (GMT)
commite726fc025a3543c0be8a4eb217b0a80f9c16051c (patch)
tree2ed4f4114caff68ff16d06fc2e0e518ff6f5a771 /Tests/RunCMake/CPack/CPackTestHelpers.cmake
parent092f1539af99e031c99a74d5a0f24731f58bf10a (diff)
downloadCMake-e726fc025a3543c0be8a4eb217b0a80f9c16051c.zip
CMake-e726fc025a3543c0be8a4eb217b0a80f9c16051c.tar.gz
CMake-e726fc025a3543c0be8a4eb217b0a80f9c16051c.tar.bz2
Tests: Add RunCMake tests for CPack{Deb,RPM}
Add script structure for easier addition of new CPack related tests.
Diffstat (limited to 'Tests/RunCMake/CPack/CPackTestHelpers.cmake')
-rw-r--r--Tests/RunCMake/CPack/CPackTestHelpers.cmake76
1 files changed, 76 insertions, 0 deletions
diff --git a/Tests/RunCMake/CPack/CPackTestHelpers.cmake b/Tests/RunCMake/CPack/CPackTestHelpers.cmake
new file mode 100644
index 0000000..7ea2a24
--- /dev/null
+++ b/Tests/RunCMake/CPack/CPackTestHelpers.cmake
@@ -0,0 +1,76 @@
+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}"
+ "-Dconfig_file=${config_file}"
+ -P "${RunCMake_SOURCE_DIR}/VerifyResult.cmake"
+ )
+ endif()
+endfunction()