onqtam | 7cc0e96 | 2017-04-17 23:30:36 +0300 | [diff] [blame] | 1 | ################################################################################ |
| 2 | ## BUILD ALL EXAMPLE SOURCES INTO A SINGLE BINARY AND EXECUTE TESTS ON EACH FILE |
| 3 | ################################################################################ |
| 4 | |
onqtam | c9b4e1f | 2018-08-17 14:20:59 +0300 | [diff] [blame] | 5 | set(files_with_output |
onqtam | 98e12af | 2017-04-16 22:11:21 +0300 | [diff] [blame] | 6 | main.cpp |
onqtam | 12d5598 | 2017-04-16 22:35:27 +0300 | [diff] [blame] | 7 | doctest_proxy.h |
onqtam | 7cc0e96 | 2017-04-17 23:30:36 +0300 | [diff] [blame] | 8 | header.h |
onqtam | 98e12af | 2017-04-16 22:11:21 +0300 | [diff] [blame] | 9 | alternative_macros.cpp |
| 10 | assertion_macros.cpp |
| 11 | stringification.cpp |
Stefan | 4e11100 | 2022-04-30 18:22:49 +0200 | [diff] [blame] | 12 | double_stringification.cpp |
onqtam | a1a38de | 2019-03-16 19:11:36 +0200 | [diff] [blame] | 13 | reporters_and_listeners.cpp |
onqtam | 98e12af | 2017-04-16 22:11:21 +0300 | [diff] [blame] | 14 | subcases.cpp |
onqtam | 119cfb6 | 2017-04-17 10:46:55 +0300 | [diff] [blame] | 15 | logging.cpp |
| 16 | templated_test_cases.cpp |
onqtam | 378d670 | 2017-04-19 11:30:03 +0300 | [diff] [blame] | 17 | test_cases_and_suites.cpp |
onqtam | 8171c48 | 2018-07-03 20:31:18 +0300 | [diff] [blame] | 18 | asserts_used_outside_of_tests.cpp |
jkriegshauser | 961a542 | 2020-11-04 08:13:29 -0800 | [diff] [blame] | 19 | enums.cpp |
Stefan | ce13bc4 | 2022-04-18 17:45:33 +0200 | [diff] [blame] | 20 | decomposition.cpp |
onqtam | 98e12af | 2017-04-16 22:11:21 +0300 | [diff] [blame] | 21 | ) |
| 22 | |
onqtam | c9b4e1f | 2018-08-17 14:20:59 +0300 | [diff] [blame] | 23 | set(files_all |
| 24 | ${files_with_output} |
| 25 | concurrency.cpp |
Stefan | db758e0 | 2022-06-06 03:42:02 +0200 | [diff] [blame^] | 26 | coverage_maxout.cpp |
Navin P | 318e1df | 2021-03-21 19:15:46 +0530 | [diff] [blame] | 27 | namespace1.cpp |
| 28 | namespace2.cpp |
| 29 | namespace3.cpp |
| 30 | namespace4.cpp |
| 31 | namespace5.cpp |
| 32 | namespace6.cpp |
| 33 | namespace7.cpp |
| 34 | namespace8.cpp |
| 35 | namespace9.cpp |
Stefan | 8f63ba4 | 2021-12-09 16:01:47 +0100 | [diff] [blame] | 36 | no_failures.cpp |
onqtam | c9b4e1f | 2018-08-17 14:20:59 +0300 | [diff] [blame] | 37 | ) |
| 38 | |
onqtam | 3ac4c3f | 2018-06-01 15:31:06 +0300 | [diff] [blame] | 39 | # add the executable |
onqtam | 36e3745 | 2019-03-02 20:10:05 +0200 | [diff] [blame] | 40 | add_executable(all_features ${files_all}) |
| 41 | target_link_libraries(all_features doctest ${CMAKE_THREAD_LIBS_INIT}) |
onqtam | 3ac4c3f | 2018-06-01 15:31:06 +0300 | [diff] [blame] | 42 | |
onqtam | f0f899b | 2017-05-02 21:40:41 +0300 | [diff] [blame] | 43 | # easy way to fix test coverage - disable colors and crash handling |
onqtam | 36e3745 | 2019-03-02 20:10:05 +0200 | [diff] [blame] | 44 | target_compile_definitions(all_features PRIVATE |
onqtam | f0f899b | 2017-05-02 21:40:41 +0300 | [diff] [blame] | 45 | DOCTEST_CONFIG_COLORS_NONE |
| 46 | DOCTEST_CONFIG_NO_POSIX_SIGNALS |
| 47 | DOCTEST_CONFIG_NO_WINDOWS_SEH) |
onqtam | 98e12af | 2017-04-16 22:11:21 +0300 | [diff] [blame] | 48 | |
onqtam | 3ac4c3f | 2018-06-01 15:31:06 +0300 | [diff] [blame] | 49 | # omit the version and the num test cases skipped from the summary - this way the output will change less often |
onqtam | 585bb71 | 2019-03-16 17:46:58 +0200 | [diff] [blame] | 50 | set(common_args COMMAND $<TARGET_FILE:all_features> --no-skipped-summary --no-version) |
onqtam | 7630535 | 2017-05-01 20:25:09 +0300 | [diff] [blame] | 51 | |
onqtam | 98e12af | 2017-04-16 22:11:21 +0300 | [diff] [blame] | 52 | # add per-file tests |
onqtam | c9b4e1f | 2018-08-17 14:20:59 +0300 | [diff] [blame] | 53 | foreach(f ${files_with_output}) |
onqtam | 5dbcb1e | 2017-05-02 23:07:56 +0300 | [diff] [blame] | 54 | doctest_add_test(NAME ${f} ${common_args} -sf=*${f}) |
onqtam | 98e12af | 2017-04-16 22:11:21 +0300 | [diff] [blame] | 55 | endforeach() |
| 56 | |
onqtam | c9b4e1f | 2018-08-17 14:20:59 +0300 | [diff] [blame] | 57 | # add this separately since it shouldn't have output compared to reference output - due to concurrency |
onqtam | 7b7bb8a | 2018-08-17 16:20:16 +0300 | [diff] [blame] | 58 | # not adding it for MinGW since it crashes when using mingw-w64-x86_64-8.1.0-release-posix-seh-rt_v6-rev0 |
onqtam | 443c707 | 2022-01-10 14:40:50 +0200 | [diff] [blame] | 59 | # (also disabled for old XCode builds where there is no thread_local support and this is defined in the build matrix) |
onqtam | eb89a02 | 2019-01-14 00:16:11 +0200 | [diff] [blame] | 60 | if(NOT MINGW AND NOT DEFINED DOCTEST_THREAD_LOCAL) |
onqtam | acbcd12 | 2019-03-02 21:24:18 +0200 | [diff] [blame] | 61 | doctest_add_test(NO_OUTPUT NAME concurrency.cpp ${common_args} -sf=*concurrency.cpp -d) # duration: there is no output anyway |
onqtam | 7b7bb8a | 2018-08-17 16:20:16 +0300 | [diff] [blame] | 62 | endif() |
onqtam | c9b4e1f | 2018-08-17 14:20:59 +0300 | [diff] [blame] | 63 | |
Navin P | 318e1df | 2021-03-21 19:15:46 +0530 | [diff] [blame] | 64 | doctest_add_test(NO_OUTPUT NAME namespace1.cpp ${common_args} -sf=*namespace1.cpp ) |
| 65 | doctest_add_test(NO_OUTPUT NAME namespace2.cpp ${common_args} -sf=*namespace2.cpp ) |
| 66 | doctest_add_test(NO_OUTPUT NAME namespace3.cpp ${common_args} -sf=*namespace3.cpp ) |
| 67 | doctest_add_test(NO_OUTPUT NAME namespace4.cpp ${common_args} -sf=*namespace4.cpp ) |
| 68 | doctest_add_test(NO_OUTPUT NAME namespace5.cpp ${common_args} -sf=*namespace5.cpp ) |
| 69 | doctest_add_test(NO_OUTPUT NAME namespace6.cpp ${common_args} -sf=*namespace6.cpp ) |
| 70 | doctest_add_test(NO_OUTPUT NAME namespace7.cpp ${common_args} -sf=*namespace7.cpp ) |
| 71 | doctest_add_test(NO_OUTPUT NAME namespace8.cpp ${common_args} -sf=*namespace8.cpp ) |
| 72 | doctest_add_test(NO_OUTPUT NAME namespace9.cpp ${common_args} -sf=*namespace9.cpp ) |
| 73 | |
onqtam | 3ac4c3f | 2018-06-01 15:31:06 +0300 | [diff] [blame] | 74 | # add this separately since the file has a non-straightforward path |
| 75 | doctest_add_test(NAME coverage_maxout.cpp ${common_args} -sf=*coverage_maxout.cpp) |
| 76 | |
onqtam | 7630535 | 2017-05-01 20:25:09 +0300 | [diff] [blame] | 77 | # queries |
onqtam | 36e3745 | 2019-03-02 20:10:05 +0200 | [diff] [blame] | 78 | doctest_add_test(NAME version COMMAND $<TARGET_FILE:all_features> -v) |
onqtam | 5dbcb1e | 2017-05-02 23:07:56 +0300 | [diff] [blame] | 79 | doctest_add_test(NAME help ${common_args} -h) |
onqtam | 2377a0c | 2019-03-20 21:04:24 +0200 | [diff] [blame] | 80 | doctest_add_test(NO_OUTPUT NAME outfile ${common_args} -c -out=temp) # just to exercise the output option |
onqtam | 5dbcb1e | 2017-05-02 23:07:56 +0300 | [diff] [blame] | 81 | doctest_add_test(NAME count ${common_args} -c -sf=*coverage*) |
| 82 | doctest_add_test(NAME list_test_cases ${common_args} -ltc -sf=*coverage*) |
| 83 | doctest_add_test(NAME list_test_suites ${common_args} -lts -sf=*coverage*) |
onqtam | 3ac4c3f | 2018-06-01 15:31:06 +0300 | [diff] [blame] | 84 | doctest_add_test(NAME list_reporters ${common_args} -lr -sf=*coverage*) |
onqtam | 321f270 | 2017-05-01 19:14:58 +0300 | [diff] [blame] | 85 | |
onqtam | 89da654 | 2017-05-02 21:10:42 +0300 | [diff] [blame] | 86 | # options |
onqtam | 5dbcb1e | 2017-05-02 23:07:56 +0300 | [diff] [blame] | 87 | doctest_add_test(NAME all_binary ${common_args} -tc=all?binary* -s) # print all binary asserts - for getAssertString() |
| 88 | doctest_add_test(NAME abort_after ${common_args} -aa=2 -e=off -sf=*coverage*) # abort after 2 assert fails and parse a negative |
| 89 | doctest_add_test(NAME first_last ${common_args} -f=2 -l=4 -sf=*coverage*) # run a range |
onqtam | 14ddb1e | 2017-05-02 23:19:09 +0300 | [diff] [blame] | 90 | doctest_add_test(NAME filter_1 ${common_args} -ts=none) # should filter out all |
onqtam | 8ee3545 | 2021-12-15 15:42:40 +0200 | [diff] [blame] | 91 | # -order-by=name to avoid different output depending on the compiler used. See https://github.com/doctest/doctest/issues/287 |
Stefan | 8f63ba4 | 2021-12-09 16:01:47 +0100 | [diff] [blame] | 92 | doctest_add_test(NAME filter_2 COMMAND $<TARGET_FILE:all_features> -tse=* -nv -order-by=name) # should filter out all + print skipped |
| 93 | doctest_add_test(NAME filter_3 ${common_args} -sc=from*,sc* -sce=sc2 -sf=*subcases*) # enter a specific subcase - sc1 |
Egor Suvorov | bef1965 | 2022-03-05 15:36:58 +0300 | [diff] [blame] | 94 | doctest_add_test(NAME filter_4 ${common_args} -ts=*\\, -tc=*\\: -sc=*\\\\\\,,*:) # escape stuff |
Stefan | 8f63ba4 | 2021-12-09 16:01:47 +0100 | [diff] [blame] | 95 | doctest_add_test(NAME order_1 ${common_args} -ob=suite -ns -sf=*test_cases_and_suites*) |
| 96 | doctest_add_test(NAME order_2 ${common_args} -ob=name -sf=*test_cases_and_suites*) |
| 97 | doctest_add_test(NAME order_3 ${common_args} -ob=rand -sfe=*) # exclude everything for no output |
| 98 | doctest_add_test(NO_OUTPUT NAME quiet ${common_args} -q -sf=*test_cases_and_suites*) # quiet |
| 99 | doctest_add_test(NAME minimal ${common_args} -m -sf=*test_cases_and_suites*) # minimal with summary |
| 100 | doctest_add_test(NAME minimal_no_fail ${common_args} -m -sf=*no_failures.cpp) # minimal |
onqtam | e0f1880 | 2017-04-16 23:38:33 +0300 | [diff] [blame] | 101 | |
Salvage | 860904d | 2022-01-12 00:52:38 +0100 | [diff] [blame] | 102 | add_executable(disabled_but_evaluated assert_returns_disabled.cpp assert_returns_disabled_evaluate.cpp) |
| 103 | target_compile_definitions(disabled_but_evaluated PRIVATE DOCTEST_CONFIG_DISABLE) |
| 104 | target_link_libraries(disabled_but_evaluated doctest ${CMAKE_THREAD_LIBS_INIT}) |
| 105 | |
Stefan | 0fc371e | 2022-03-19 17:50:37 +0100 | [diff] [blame] | 106 | doctest_add_test_impl(NO_OUTPUT NAME disabled_but_evaluated COMMAND $<TARGET_FILE:disabled_but_evaluated>) |
Salvage | 860904d | 2022-01-12 00:52:38 +0100 | [diff] [blame] | 107 | |
Salvage | e798deb | 2022-01-12 02:44:57 +0100 | [diff] [blame] | 108 | if(MSVC) |
| 109 | target_compile_options(disabled_but_evaluated PRIVATE /wd4702) # unreachable code |
| 110 | endif() |
| 111 | |
| 112 | if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 113 | target_compile_options(disabled_but_evaluated PRIVATE -Wno-global-constructors) |
| 114 | target_compile_options(disabled_but_evaluated PRIVATE -Wno-unused-variable) |
| 115 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") |
| 116 | target_compile_options(disabled_but_evaluated PRIVATE -Wno-unused-variable) |
| 117 | endif() |
| 118 | |
Salvage | 860904d | 2022-01-12 00:52:38 +0100 | [diff] [blame] | 119 | ################################################################################ |
Stefan | 0fc371e | 2022-03-19 17:50:37 +0100 | [diff] [blame] | 120 | ## CONFIG TESTS - TESTS WITH VARIOUS CONFIGURATION OPTIONS |
onqtam | 7cc0e96 | 2017-04-17 23:30:36 +0300 | [diff] [blame] | 121 | ################################################################################ |
| 122 | |
Stefan | 0fc371e | 2022-03-19 17:50:37 +0100 | [diff] [blame] | 123 | function(add_test_all_features test_name flags) |
| 124 | add_executable(${test_name} ${files_with_output}) |
| 125 | target_compile_definitions(${test_name} PRIVATE ${flags}) |
| 126 | target_link_libraries(${test_name} doctest ${CMAKE_THREAD_LIBS_INIT}) |
onqtam | 7cc0e96 | 2017-04-17 23:30:36 +0300 | [diff] [blame] | 127 | |
Stefan | 0fc371e | 2022-03-19 17:50:37 +0100 | [diff] [blame] | 128 | doctest_add_test_impl(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}> --no-skipped-summary --no-version -ob=name) |
| 129 | endfunction() |
| 130 | |
| 131 | add_test_all_features(no_multithreading DOCTEST_CONFIG_NO_MULTITHREADING) |
| 132 | add_test_all_features(no_multi_lane_atomics DOCTEST_CONFIG_NO_MULTI_LANE_ATOMICS) |
| 133 | add_test_all_features(disabled DOCTEST_CONFIG_DISABLE) |
Stefan | 94b52bb | 2022-05-02 05:19:20 +0200 | [diff] [blame] | 134 | add_test_all_features(std_headers DOCTEST_CONFIG_USE_STD_HEADERS) |
onqtam | 7cc0e96 | 2017-04-17 23:30:36 +0300 | [diff] [blame] | 135 | |
onqtam | d320ac2 | 2017-04-17 11:44:32 +0300 | [diff] [blame] | 136 | # TODO: think about fixing these in a different way! - see issue #61 or commit 6b61e8aa3818c5ea100cedc1bb48a60ea10df6e8 |
Martin Moene | d8a7edc | 2017-08-01 17:08:08 +0200 | [diff] [blame] | 137 | if(MSVC) |
onqtam | d320ac2 | 2017-04-17 11:44:32 +0300 | [diff] [blame] | 138 | target_compile_options(disabled PRIVATE /wd4505) # unreferenced local function has been removed |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 139 | target_compile_options(disabled PRIVATE /wd4100) # unreferenced formal parameter |
onqtam | af07cbb | 2017-04-19 19:40:43 +0300 | [diff] [blame] | 140 | target_compile_options(disabled PRIVATE /wd4189) # local variable is initialized but not referenced |
Daan De Meyer | 3c6834b | 2019-09-10 15:40:53 +0200 | [diff] [blame] | 141 | endif() |
| 142 | |
| 143 | if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
onqtam | 135a50e | 2017-04-18 11:48:20 +0300 | [diff] [blame] | 144 | target_compile_options(disabled PRIVATE -Wno-unknown-warning-option) |
onqtam | d320ac2 | 2017-04-17 11:44:32 +0300 | [diff] [blame] | 145 | target_compile_options(disabled PRIVATE -Wno-unneeded-internal-declaration) |
onqtam | a82c1e4 | 2017-05-07 17:36:41 +0300 | [diff] [blame] | 146 | target_compile_options(disabled PRIVATE -Wno-unused-function) |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 147 | target_compile_options(disabled PRIVATE -Wno-unused-parameter) |
onqtam | c79b754 | 2017-04-19 20:47:13 +0300 | [diff] [blame] | 148 | target_compile_options(disabled PRIVATE -Wno-unused-variable) |
onqtam | eb96d16 | 2017-09-11 14:26:32 +0300 | [diff] [blame] | 149 | target_compile_options(disabled PRIVATE -Wno-unused-template) |
onqtam | c79b754 | 2017-04-19 20:47:13 +0300 | [diff] [blame] | 150 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") |
onqtam | cb7bad6 | 2017-04-19 11:19:57 +0300 | [diff] [blame] | 151 | target_compile_options(disabled PRIVATE -Wno-unused-function) |
onqtam | c79b754 | 2017-04-19 20:47:13 +0300 | [diff] [blame] | 152 | target_compile_options(disabled PRIVATE -Wno-unused-parameter) |
onqtam | af07cbb | 2017-04-19 19:40:43 +0300 | [diff] [blame] | 153 | target_compile_options(disabled PRIVATE -Wno-unused-variable) |
onqtam | d320ac2 | 2017-04-17 11:44:32 +0300 | [diff] [blame] | 154 | endif() |