Skip to content
Snippets Groups Projects
Commit ed079eb2 authored by jwendt's avatar jwendt
Browse files

put different parts of test suite creation into methods

#182
parent 40893b01
No related branches found
No related tags found
1 merge request!56Feature/#182 test suites
...@@ -126,37 +126,57 @@ function(ADD_TEST_CATCH) ...@@ -126,37 +126,57 @@ function(ADD_TEST_CATCH)
endforeach() endforeach()
endfunction() endfunction()
function(CREATE_TEST_SUITES) macro(EXTRACT_UNIT_AND_INTEGRATION_TEST_TARGETS)
get_property(added_tests GLOBAL PROPERTY ADDED_TESTS) get_property(added_tests GLOBAL PROPERTY ADDED_TESTS)
foreach(filename ${added_tests}) foreach(filename ${added_tests})
if(${filename} MATCHES "integration_test") if(${filename} MATCHES "integration_test")
message(STATUS "Integration Test: ${filename}") message(STATUS "Integration Test: ${filename}")
set(INTEGRATION_TESTS ${INTEGRATION_TESTS} ${filename}) set(INTEGRATION_TEST_TARGETS ${INTEGRATION_TEST_TARGETS} ${filename})
else() else()
message(STATUS "Unit Test: ${filename}") message(STATUS "Unit Test: ${filename}")
set(UNIT_TESTS ${UNIT_TESTS} ${filename}) set(UNIT_TEST_TARGETS ${UNIT_TEST_TARGETS} ${filename})
endif() endif()
endforeach() endforeach()
endmacro()
if("integration_test" MATCHES "^test") macro(ADD_TEST_SUITE)
message("JOOOOOW") set(options)
set(oneValueArgs NAME TEST_REGEX)
set(multiValueArgs DEPEND_ON_TARGETS)
cmake_parse_arguments(ADD_TEST_SUITE
"${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
#we have to escape the " for visual studio)
add_custom_target(${ADD_TEST_SUITE_NAME} COMMAND ctest --tests-regex \"${ADD_TEST_SUITE_TEST_REGEX}\" -C $<CONFIG>)
# This comment just ends the escaped signs, for VS highlighting "
if(ADD_TEST_SUITE_DEPEND_ON_TARGETS)
add_dependencies(${ADD_TEST_SUITE_NAME} ${ADD_TEST_SUITE_DEPEND_ON_TARGETS})
message("${ADD_TEST_SUITE_DEPEND_ON_TARGETS}")
endif() endif()
set_property(TARGET ${ADD_TEST_SUITE_NAME} PROPERTY FOLDER "_Test-Suites_")
endmacro()
function(CREATE_TEST_SUITES)
EXTRACT_UNIT_AND_INTEGRATION_TEST_TARGETS()
message( ${INTEGRATION_TEST_TARGETS})
#Add a Unit Test Suite (we have to escape the " for visual studio) ADD_TEST_SUITE(
add_custom_target(Unit-Test-Suite COMMAND ctest --tests-regex \"^test\" -C $<CONFIG>) NAME "Unit-Test-Suite"
add_dependencies( Unit-Test-Suite ${UNIT_TESTS}) TEST_REGEX "^test"
set_property(TARGET Unit-Test-Suite PROPERTY FOLDER "_Test-Suites_") DEPEND_ON_TARGETS ${UNIT_TEST_TARGETS})
#Add a Integration Test Suite ADD_TEST_SUITE(
add_custom_target(Integration-Test-Suite COMMAND ctest --tests-regex \"^integration\" -C $<CONFIG>) NAME "Integration-Test-Suite"
add_dependencies( Integration-Test-Suite ${INTEGRATION_TESTS}) TEST_REGEX "^integration"
set_property(TARGET Integration-Test-Suite PROPERTY FOLDER "_Test-Suites_") DEPEND_ON_TARGETS ${INTEGRATION_TEST_TARGETS})
#Add a cpplint Test Suite ADD_TEST_SUITE(
add_custom_target(Cpplint-Test-Suite COMMAND ctest --tests-regex \"cpplint\" -C $<CONFIG>) NAME "Cpplint-Test-Suite"
set_property(TARGET Cpplint-Test-Suite PROPERTY FOLDER "_Test-Suites_") TEST_REGEX "cpplint")
#Add a cppcheck Test Suite ADD_TEST_SUITE(
add_custom_target(Cppcheck-Test-Suite COMMAND ctest --tests-regex \"cppcheck\" -C $<CONFIG>) NAME "Cppcheck-Test-Suite"
set_property(TARGET Cppcheck-Test-Suite PROPERTY FOLDER "_Test-Suites_") TEST_REGEX "cppcheck")
endfunction() endfunction()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment