2015-06-05 22:03:26 +03:00
|
|
|
cmake_policy(SET CMP0057 NEW)
|
2016-09-20 00:44:06 +03:00
|
|
|
|
2016-09-20 22:08:36 +03:00
|
|
|
function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source)
|
2015-06-05 22:03:26 +03:00
|
|
|
if(TEST_TYPE IN_LIST types)
|
|
|
|
set(RunCMake_TEST_NO_CLEAN TRUE)
|
|
|
|
set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${TEST_NAME}-build")
|
2016-09-14 00:32:48 +03:00
|
|
|
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()
|
2015-06-05 22:03:26 +03:00
|
|
|
|
|
|
|
# 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}")
|
|
|
|
|
2016-05-10 16:40:48 +03:00
|
|
|
if(EXISTS "${RunCMake_SOURCE_DIR}/${TEST_TYPE}/${TEST_NAME}-Prerequirements.cmake")
|
|
|
|
include("${RunCMake_SOURCE_DIR}/${TEST_TYPE}/${TEST_NAME}-Prerequirements.cmake")
|
|
|
|
|
|
|
|
set(FOUND_PREREQUIREMENTS false)
|
|
|
|
get_test_prerequirements("FOUND_PREREQUIREMENTS"
|
|
|
|
"${TEST_CONFIG_DIR}/${type}_config.cmake")
|
|
|
|
|
|
|
|
# skip the test if prerequirements are not met
|
|
|
|
if(NOT FOUND_PREREQUIREMENTS)
|
|
|
|
message(STATUS "${TEST_NAME} - SKIPPED")
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2015-06-05 22:03:26 +03:00
|
|
|
# execute cmake
|
2016-09-14 00:32:48 +03:00
|
|
|
set(RunCMake_TEST_OPTIONS "-DGENERATOR_TYPE=${TEST_TYPE}"
|
|
|
|
"-DRunCMake_TEST_FILE_PREFIX=${TEST_NAME}"
|
|
|
|
"-DRunCMake_SUBTEST_SUFFIX=${SUBTEST_SUFFIX}")
|
|
|
|
run_cmake(${full_test_name_})
|
2015-06-05 22:03:26 +03:00
|
|
|
|
|
|
|
# execute optional build step
|
|
|
|
if(build)
|
2016-09-14 00:32:48 +03:00
|
|
|
run_cmake_command(${full_test_name_}-Build "${CMAKE_COMMAND}" --build "${RunCMake_TEST_BINARY_DIR}")
|
2015-06-05 22:03:26 +03:00
|
|
|
endif()
|
|
|
|
|
2016-09-20 22:08:36 +03:00
|
|
|
if(source)
|
|
|
|
set(pack_params_ -G ${TEST_TYPE} --config ./CPackSourceConfig.cmake)
|
|
|
|
FILE(APPEND ${RunCMake_TEST_BINARY_DIR}/CPackSourceConfig.cmake
|
|
|
|
"\nset(CPACK_RPM_SOURCE_PKG_BUILD_PARAMS \"-DRunCMake_TEST:STRING=${full_test_name_}\ -DRunCMake_TEST_FILE_PREFIX:STRING=${TEST_NAME}\")")
|
|
|
|
else()
|
|
|
|
unset(pack_params_)
|
|
|
|
endif()
|
|
|
|
|
2015-06-05 22:03:26 +03:00
|
|
|
# execute cpack
|
|
|
|
execute_process(
|
2016-09-20 22:08:36 +03:00
|
|
|
COMMAND ${CMAKE_CPACK_COMMAND} ${pack_params_}
|
2015-06-05 22:03:26 +03:00
|
|
|
WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}"
|
2016-09-20 22:08:36 +03:00
|
|
|
RESULT_VARIABLE "result_"
|
2015-06-05 22:03:26 +03:00
|
|
|
OUTPUT_FILE "${RunCMake_TEST_BINARY_DIR}/test_output.txt"
|
|
|
|
ERROR_FILE "${RunCMake_TEST_BINARY_DIR}/test_error.txt"
|
|
|
|
)
|
|
|
|
|
2016-09-14 00:32:48 +03:00
|
|
|
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()
|
|
|
|
|
2015-06-05 22:03:26 +03:00
|
|
|
# verify result
|
|
|
|
run_cmake_command(
|
2016-09-14 00:32:48 +03:00
|
|
|
${TEST_TYPE}/${full_test_name_}
|
2015-06-05 22:03:26 +03:00
|
|
|
"${CMAKE_COMMAND}"
|
2016-09-14 00:32:48 +03:00
|
|
|
-DRunCMake_TEST=${full_test_name_}
|
|
|
|
-DRunCMake_TEST_FILE_PREFIX=${TEST_NAME}
|
|
|
|
-DRunCMake_SUBTEST_SUFFIX=${SUBTEST_SUFFIX}
|
2015-06-05 22:03:26 +03:00
|
|
|
-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()
|
2016-09-14 00:32:48 +03:00
|
|
|
|
|
|
|
function(run_cpack_test TEST_NAME types build)
|
2016-09-20 22:08:36 +03:00
|
|
|
run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "" false)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(run_cpack_source_test TEST_NAME types build)
|
|
|
|
run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "" true)
|
2016-09-14 00:32:48 +03:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(run_cpack_test_subtests TEST_NAME SUBTEST_SUFFIXES types build)
|
|
|
|
foreach(suffix_ IN LISTS SUBTEST_SUFFIXES)
|
2016-09-20 22:08:36 +03:00
|
|
|
run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "${suffix_}" false)
|
2016-09-14 00:32:48 +03:00
|
|
|
endforeach()
|
|
|
|
endfunction()
|