extended the cmake testing infrastructure to invoke the xml reporter as well - for N tests now we will have 2xN tests - N with the console reporter and the same N with the xml reporter (currently commented out)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index baa13a9..3970824 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -47,7 +47,6 @@
################################################################################
if(${DOCTEST_WITH_MAIN_IN_STATIC_LIB})
- include(scripts/cmake/common.cmake)
add_library(${PROJECT_NAME}_with_main STATIC EXCLUDE_FROM_ALL doctest/parts/doctest.cpp)
target_compile_definitions(${PROJECT_NAME}_with_main PRIVATE
DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN)
@@ -59,6 +58,7 @@
add_subdirectory(examples/all_features)
+ # for code coverage we want exactly one binary to be produced and exercised
if(NOT DEFINED ENV{CODE_COVERAGE})
add_subdirectory(examples/exe_with_static_libs)
add_subdirectory(examples/executable_dll_and_plugin)
diff --git a/examples/all_features/doctest_proxy.h b/examples/all_features/doctest_proxy.h
index 16ff0ff..dccaf4b 100644
--- a/examples/all_features/doctest_proxy.h
+++ b/examples/all_features/doctest_proxy.h
@@ -9,6 +9,7 @@
#define MY_PROXY_MACROS
#define my_testcase DOCTEST_TEST_CASE
+#define my_testcase_class DOCTEST_TEST_CASE_CLASS
#define my_testcase_fixture DOCTEST_TEST_CASE_FIXTURE
#define my_subcase DOCTEST_SUBCASE
#define my_testsuite DOCTEST_TEST_SUITE
diff --git a/scripts/cmake/common.cmake b/scripts/cmake/common.cmake
index 914b878..fa5205c 100644
--- a/scripts/cmake/common.cmake
+++ b/scripts/cmake/common.cmake
@@ -1,8 +1,3 @@
-if(doctest_common_included)
- return()
-endif()
-set(doctest_common_included true)
-
include(CMakeParseArguments)
# cache this for use inside of the function
@@ -17,9 +12,8 @@
set(DOCTEST_TEST_MODE "COMPARE" CACHE STRING "Test mode - normal/run through valgrind/collect output/compare with output")
set_property(CACHE DOCTEST_TEST_MODE PROPERTY STRINGS "NORMAL;VALGRIND;COLLECT;COMPARE")
-# a custom version of add_test() to suite my needs
-function(doctest_add_test)
- cmake_parse_arguments(ARG "NO_VALGRIND;NO_OUTPUT" "NAME" "COMMAND" ${ARGN})
+function(doctest_add_test_impl)
+ cmake_parse_arguments(ARG "NO_VALGRIND;NO_OUTPUT;XML_OUTPUT" "NAME" "COMMAND" ${ARGN})
if(NOT "${ARG_UNPARSED_ARGUMENTS}" STREQUAL "" OR "${ARG_NAME}" STREQUAL "" OR "${ARG_COMMAND}" STREQUAL "")
message(FATAL_ERROR "doctest_add_test() called with wrong options!")
endif()
@@ -35,6 +29,10 @@
foreach(cur ${ARG_COMMAND})
set(the_command "${the_command} ${cur}")
endforeach()
+ if(ARG_XML_OUTPUT)
+ set(the_command "${the_command} --reporter=xml")
+ set(ARG_NAME ${ARG_NAME}_xml)
+ endif()
# append the argument for removing paths from filenames in the output so tests give the same output everywhere
set(the_command "${the_command} --dt-no-path-filenames=1")
# append the argument for substituting source line numbers with 0 in the output so tests give the same output when lines change a bit
@@ -60,6 +58,12 @@
add_test(NAME ${ARG_NAME} COMMAND ${CMAKE_COMMAND} -DCOMMAND=${the_command} ${ADDITIONAL_FLAGS} -P ${CURRENT_LIST_DIR_CACHED}/exec_test.cmake)
endfunction()
+# a custom version of add_test() to suite my needs
+function(doctest_add_test)
+ doctest_add_test_impl(${ARGN})
+ #doctest_add_test_impl(${ARGN} XML_OUTPUT)
+endfunction()
+
macro(add_compiler_flags)
foreach(flag ${ARGV})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")