diff options
author | Domen Vrankar <domen.vrankar@gmail.com> | 2016-09-13 21:32:48 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-09-19 14:20:13 (GMT) |
commit | 4682b42bdb5a9b7ca9f6ef5f65c019eec4f92a62 (patch) | |
tree | 7a8e9a3bfd012cd3362f402bd7623169e2fdb3d5 /Tests/RunCMake/CPack/CPackTestHelpers.cmake | |
parent | 5c87b92b1b7888ee032e3c2a75f35f1f94f4dfa5 (diff) | |
download | CMake-4682b42bdb5a9b7ca9f6ef5f65c019eec4f92a62.zip CMake-4682b42bdb5a9b7ca9f6ef5f65c019eec4f92a62.tar.gz CMake-4682b42bdb5a9b7ca9f6ef5f65c019eec4f92a62.tar.bz2 |
Tests: Add subtest support to RunCMake/CPack infrastructure
Diffstat (limited to 'Tests/RunCMake/CPack/CPackTestHelpers.cmake')
-rw-r--r-- | Tests/RunCMake/CPack/CPackTestHelpers.cmake | 40 |
1 files changed, 34 insertions, 6 deletions
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() |