Debian Codegraph @

3rdparty/catch2/tests/ExtraTests/CMakeLists.txt

raw
1 #
2 # Build extra tests.
3 #
4
5 cmake_minimum_required( VERSION 3.10 )
6
7 project( Catch2ExtraTests LANGUAGES CXX )
8
9 message( STATUS "Extra tests included" )
10
11
12 add_test(
13 NAME TestShardingIntegration
14 COMMAND ${PYTHON_EXECUTABLE} ${CATCH_DIR}/tests/TestScripts/testSharding.py $<TARGET_FILE:SelfTest>
15 )
16 set_tests_properties(TestShardingIntegration
17 PROPERTIES
18 LABELS "uses-python"
19 )
20
21 add_test(
22 NAME TestSharding::OverlyLargeShardIndex
23 COMMAND $<TARGET_FILE:SelfTest> --shard-index 5 --shard-count 5
24 )
25 set_tests_properties(
26 TestSharding::OverlyLargeShardIndex
27 PROPERTIES
28 PASS_REGULAR_EXPRESSION "The shard count \\(5\\) must be greater than the shard index \\(5\\)"
29 )
30
31 # The MinDuration reporting tests do not need separate compilation, but
32 # they have non-trivial execution time, so they are categorized as
33 # extra tests, so that they are run less.
34 add_test(NAME MinDuration::SimpleThreshold COMMAND $<TARGET_FILE:SelfTest> --min-duration 0.950 [min_duration_test])
35 set_tests_properties(
36 MinDuration::SimpleThreshold
37 PROPERTIES
38 PASS_REGULAR_EXPRESSION "s: sleep_for_1000ms"
39 FAIL_REGULAR_EXPRESSION "sleep_for_100ms"
40 RUN_SERIAL ON # The test is timing sensitive, so we want to run it
41 # serially to avoid false positives on oversubscribed machines
42 )
43
44 # -d yes overrides the threshold, so we should see the faster test even
45 # with a ridiculous high min duration threshold
46 add_test(NAME MinDuration::DurationOverrideYes COMMAND $<TARGET_FILE:SelfTest> --min-duration 1.0 -d yes [min_duration_test])
47 set_tests_properties(
48 MinDuration::DurationOverrideYes
49 PROPERTIES
50 PASS_REGULAR_EXPRESSION "s: sleep_for_100ms"
51 )
52
53 # -d no overrides the threshold, so we should never see any tests even
54 # with ridiculously low min duration threshold
55 add_test(NAME MinDuration::DurationOverrideNo COMMAND $<TARGET_FILE:SelfTest> --min-duration 0.0001 -d no [min_duration_test])
56 set_tests_properties(
57 MinDuration::DurationOverrideNo
58 PROPERTIES
59 FAIL_REGULAR_EXPRESSION "sleep_for_250ms"
60 )
61
62
63 # ------------ end of duration reporting tests
64
65 # define folders used:
66 set( TESTS_DIR ${CATCH_DIR}/tests/ExtraTests )
67
68 add_executable(PrefixedMacros ${TESTS_DIR}/X01-PrefixedMacros.cpp)
69 target_compile_definitions( PrefixedMacros PRIVATE CATCH_CONFIG_PREFIX_ALL CATCH_CONFIG_RUNTIME_STATIC_REQUIRE )
70 # Macro configuration does not touch the compiled parts, so we can link
71 # it against the main library
72 target_link_libraries( PrefixedMacros Catch2WithMain )
73
74 add_test(NAME CATCH_CONFIG_PREFIX_ALL COMMAND PrefixedMacros -s)
75 set_tests_properties(
76 CATCH_CONFIG_PREFIX_ALL
77 PROPERTIES
78 PASS_REGULAR_EXPRESSION "CATCH_"
79 FAIL_REGULAR_EXPRESSION
80 # The spaces are important -> They disambiguate between CATCH_REQUIRE
81 # and REQUIRE without prefix.
82 " REQUIRE; REQUIRE_FALSE; REQUIRE_THROWS; REQUIRE_THROWS_AS; REQUIRE_THROWS_WITH; REQUIRE_THROWS_MATCHES; REQUIRE_NOTHROW; CHECK; CHECK_FALSE; CHECKED_IF; CHECKED_ELSE; CHECK_NOFAIL; CHECK_THROWS; CHECK_THROWS_AS; CHECK_THROWS_WITH; CHECK_THROWS_MATCHES; CHECK_NOTHROW; REQUIRE_THAT; CHECK_THAT"
83 )
84
85
86 add_executable(DisabledMacros ${TESTS_DIR}/X02-DisabledMacros.cpp)
87 target_compile_definitions( DisabledMacros PRIVATE CATCH_CONFIG_DISABLE )
88 # Macro configuration does not touch the compiled parts, so we can link
89 # it against the main library
90 target_link_libraries( DisabledMacros Catch2WithMain )
91
92 add_test(NAME CATCH_CONFIG_DISABLE-1 COMMAND DisabledMacros -s)
93 set_tests_properties(
94 CATCH_CONFIG_DISABLE-1
95 PROPERTIES
96 PASS_REGULAR_EXPRESSION "No tests ran"
97 FAIL_REGULAR_EXPRESSION "This should not happen"
98 )
99 add_test(NAME CATCH_CONFIG_DISABLE-2 COMMAND DisabledMacros --list-tests)
100 set_tests_properties(
101 CATCH_CONFIG_DISABLE-2
102 PROPERTIES
103 PASS_REGULAR_EXPRESSION "0 test cases"
104 )
105
106 add_executable( DisabledExceptions-DefaultHandler ${TESTS_DIR}/X03-DisabledExceptions-DefaultHandler.cpp )
107 add_executable( DisabledExceptions-CustomHandler ${TESTS_DIR}/X04-DisabledExceptions-CustomHandler.cpp )
108
109 foreach(target DisabledExceptions-DefaultHandler DisabledExceptions-CustomHandler)
110 target_compile_options( ${target}
111 PUBLIC
112 $<$<CXX_COMPILER_ID:MSVC>:/EHs-c-;/D_HAS_EXCEPTIONS=0>
113 $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:AppleClang>>:-fno-exceptions>
114 )
115 target_link_libraries(${target} Catch2_buildall_interface)
116 endforeach()
117 target_compile_definitions( DisabledExceptions-CustomHandler PUBLIC CATCH_CONFIG_DISABLE_EXCEPTIONS_CUSTOM_HANDLER )
118
119
120 add_test(NAME CATCH_CONFIG_DISABLE_EXCEPTIONS-1 COMMAND DisabledExceptions-DefaultHandler "Tests that run")
121 set_tests_properties(
122 CATCH_CONFIG_DISABLE_EXCEPTIONS-1
123 PROPERTIES
124 PASS_REGULAR_EXPRESSION "assertions: 4 \| 2 passed \| 2 failed"
125 FAIL_REGULAR_EXPRESSION "abort;terminate;fatal"
126 )
127
128 add_executable( BazelReporter ${TESTS_DIR}/X30-BazelReporter.cpp )
129 target_compile_definitions( BazelReporter PRIVATE CATCH_CONFIG_BAZEL_SUPPORT )
130 target_link_libraries(BazelReporter Catch2_buildall_interface)
131 add_test(NAME CATCH_CONFIG_BAZEL_REPORTER-1
132 COMMAND
133 "${PYTHON_EXECUTABLE}" "${CATCH_DIR}/tests/TestScripts/testBazelReporter.py" $<TARGET_FILE:BazelReporter> "${CMAKE_CURRENT_BINARY_DIR}"
134 )
135 set_tests_properties(CATCH_CONFIG_BAZEL_REPORTER-1
136 PROPERTIES
137 LABELS "uses-python"
138 )
139
140 # We must now test this works without the build flag.
141 add_executable( BazelReporterNoCatchConfig ${TESTS_DIR}/X30-BazelReporter.cpp )
142 target_link_libraries(BazelReporterNoCatchConfig Catch2WithMain)
143 add_test(NAME NO_CATCH_CONFIG_BAZEL_REPORTER-1
144 COMMAND
145 "${PYTHON_EXECUTABLE}" "${CATCH_DIR}/tests/TestScripts/testBazelReporter.py" $<TARGET_FILE:BazelReporterNoCatchConfig> "${CMAKE_CURRENT_BINARY_DIR}"
146 )
147 set_tests_properties(NO_CATCH_CONFIG_BAZEL_REPORTER-1
148 PROPERTIES
149 LABELS "uses-python"
150 ENVIRONMENT "BAZEL_TEST=1"
151 )
152
153 add_test(NAME BazelEnv::TESTBRIDGE_TEST_ONLY
154 COMMAND
155 $<TARGET_FILE:BazelReporterNoCatchConfig>
156 )
157 set_tests_properties(BazelEnv::TESTBRIDGE_TEST_ONLY
158 PROPERTIES
159 ENVIRONMENT "BAZEL_TEST=1;TESTBRIDGE_TEST_ONLY=Passing test case"
160 PASS_REGULAR_EXPRESSION "All tests passed \\(1 assertion in 1 test case\\)"
161 )
162
163
164 add_test(NAME BazelEnv::Sharding
165 COMMAND
166 "${PYTHON_EXECUTABLE}" "${CATCH_DIR}/tests/TestScripts/testBazelSharding.py"
167 $<TARGET_FILE:BazelReporterNoCatchConfig>
168 "${CMAKE_CURRENT_BINARY_DIR}"
169 )
170 set_tests_properties(BazelEnv::Sharding
171 PROPERTIES
172 LABELS "uses-python"
173 )
174
175
176 # The default handler on Windows leads to the just-in-time debugger firing,
177 # which makes this test unsuitable for CI and headless runs, as it opens
178 # up an interactive dialog.
179 if (NOT WIN32)
180 add_test(NAME CATCH_CONFIG_DISABLE_EXCEPTIONS-2 COMMAND DisabledExceptions-DefaultHandler "Tests that abort")
181 set_tests_properties(
182 CATCH_CONFIG_DISABLE_EXCEPTIONS-2
183 PROPERTIES
184 PASS_REGULAR_EXPRESSION "Catch will terminate"
185 )
186 endif(NOT WIN32)
187
188
189 add_test(NAME CATCH_CONFIG_DISABLE_EXCEPTIONS-3 COMMAND DisabledExceptions-CustomHandler "Tests that run")
190 set_tests_properties(
191 CATCH_CONFIG_DISABLE_EXCEPTIONS-3
192 PROPERTIES
193 PASS_REGULAR_EXPRESSION "assertions: 4 \| 2 passed \| 2 failed"
194 FAIL_REGULAR_EXPRESSION "====== CUSTOM HANDLER ======"
195 )
196
197 add_test(NAME CATCH_CONFIG_DISABLE_EXCEPTIONS-4 COMMAND DisabledExceptions-CustomHandler "Tests that abort")
198 set_tests_properties(
199 CATCH_CONFIG_DISABLE_EXCEPTIONS-4
200 PROPERTIES
201 PASS_REGULAR_EXPRESSION "====== CUSTOM HANDLER ======"
202 )
203
204
205 add_executable(DeferredStaticChecks ${TESTS_DIR}/X05-DeferredStaticChecks.cpp)
206 target_link_libraries(DeferredStaticChecks PRIVATE Catch2WithMain)
207 target_compile_definitions(DeferredStaticChecks PRIVATE "CATCH_CONFIG_RUNTIME_STATIC_REQUIRE")
208
209 add_test(NAME DeferredStaticChecks COMMAND DeferredStaticChecks -r compact)
210 set_tests_properties(
211 DeferredStaticChecks
212 PROPERTIES
213 PASS_REGULAR_EXPRESSION "test cases: 1 \\| 1 failed\nassertions: 3 \\| 3 failed"
214 )
215
216
217 add_executable(FallbackStringifier ${TESTS_DIR}/X10-FallbackStringifier.cpp)
218 target_compile_definitions( FallbackStringifier PRIVATE CATCH_CONFIG_FALLBACK_STRINGIFIER=fallbackStringifier )
219 target_link_libraries( FallbackStringifier Catch2WithMain )
220
221 add_test(NAME FallbackStringifier COMMAND FallbackStringifier -r compact -s)
222 set_tests_properties(
223 FallbackStringifier
224 PROPERTIES
225 PASS_REGULAR_EXPRESSION "foo{} for: { !!! }"
226 )
227
228
229 add_executable(DisableStringification ${TESTS_DIR}/X11-DisableStringification.cpp)
230 target_compile_definitions( DisableStringification PRIVATE CATCH_CONFIG_DISABLE_STRINGIFICATION )
231 target_link_libraries(DisableStringification Catch2WithMain)
232 add_test(NAME CATCH_CONFIG_DISABLE_STRINGIFICATION COMMAND DisableStringification -r compact -s)
233 set_tests_properties(
234 CATCH_CONFIG_DISABLE_STRINGIFICATION
235 PROPERTIES
236 PASS_REGULAR_EXPRESSION "Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION"
237 FAIL_REGULAR_EXPRESSION "Hidden{} == Hidden{}"
238 )
239
240
241 # This test touches windows.h, so it should only be compiled under msvc
242 if (MSVC)
243 # This test fails if it does not compile and succeeds otherwise
244 add_executable(WindowsHeader ${TESTS_DIR}/X90-WindowsHeaderInclusion.cpp)
245 target_link_libraries( WindowsHeader Catch2WithMain )
246 add_test(NAME WindowsHeader COMMAND WindowsHeader -r compact)
247 list(APPEND CATCH_WARNING_TARGETS ${EXTRA_TEST_BINARIES} WindowsHeader)
248 endif()
249
250
251 add_executable(PartialTestCaseEvents ${TESTS_DIR}/X21-PartialTestCaseEvents.cpp)
252 target_link_libraries(PartialTestCaseEvents PRIVATE Catch2WithMain)
253 add_test(
254 NAME PartialTestCaseEvents
255 COMMAND ${PYTHON_EXECUTABLE} ${CATCH_DIR}/tests/TestScripts/testPartialTestCaseEvent.py $<TARGET_FILE:PartialTestCaseEvents>
256 )
257 set_tests_properties(PartialTestCaseEvents
258 PROPERTIES
259 LABELS "uses-python"
260 )
261
262 add_executable(BenchmarksInCumulativeReporter ${TESTS_DIR}/X22-BenchmarksInCumulativeReporter.cpp)
263 target_link_libraries(BenchmarksInCumulativeReporter PRIVATE Catch2::Catch2WithMain)
264 add_test(
265 NAME BenchmarksInCumulativeReporter
266 COMMAND BenchmarksInCumulativeReporter --reporter testReporter
267 )
268 set_tests_properties(
269 BenchmarksInCumulativeReporter
270 PROPERTIES
271 PASS_REGULAR_EXPRESSION "1\n2\n3\n4\n5\n"
272 COST 30
273 )
274
275
276 add_executable(CasingInReporterNames ${TESTS_DIR}/X23-CasingInReporterNames.cpp)
277 target_link_libraries(CasingInReporterNames PRIVATE Catch2::Catch2WithMain)
278 add_test(
279 NAME Reporters::registration-is-case-preserving
280 COMMAND CasingInReporterNames --list-reporters
281 )
282 set_tests_properties(
283 Reporters::registration-is-case-preserving
284 PROPERTIES
285 PASS_REGULAR_EXPRESSION "testReporterCASED"
286 )
287 add_test(
288 NAME Reporters::selection-is-case-insensitive
289 COMMAND CasingInReporterNames -r testReportercased
290 )
291 set_tests_properties(
292 Reporters::selection-is-case-insensitive
293 PROPERTIES
294 PASS_REGULAR_EXPRESSION "TestReporter constructed"
295 )
296
297 add_executable(CapturedStdoutInTestCaseEvents ${TESTS_DIR}/X27-CapturedStdoutInTestCaseEvents.cpp)
298 target_link_libraries(CapturedStdoutInTestCaseEvents PRIVATE Catch2::Catch2WithMain)
299 add_test(
300 NAME Reporters::CapturedStdOutInEvents
301 COMMAND CapturedStdoutInTestCaseEvents
302 --reporter test-reporter
303 )
304 set_tests_properties(
305 Reporters::CapturedStdOutInEvents
306 PROPERTIES
307 PASS_REGULAR_EXPRESSION "X27 - TestReporter constructed"
308 FAIL_REGULAR_EXPRESSION "X27 ERROR"
309 )
310
311
312 if (MSVC)
313 set(_NullFile "NUL")
314 else()
315 set(_NullFile "/dev/null")
316 endif()
317
318 add_executable(ListenerStdoutCaptureInMultireporter ${TESTS_DIR}/X24-ListenerStdoutCaptureInMultireporter.cpp)
319 target_link_libraries(ListenerStdoutCaptureInMultireporter PRIVATE Catch2::Catch2WithMain)
320
321 # This test checks that there is nothing written out from the process,
322 # but if CMake is running the tests under Valgrind or similar tool, then
323 # that will write its own output to stdout and the test would fail.
324 if (NOT MEMORYCHECK_COMMAND)
325 add_test(
326 NAME MultiReporter::NoncapturingListenerDoesntCauseStdoutPassThrough
327 COMMAND ListenerStdoutCaptureInMultireporter
328 --reporter xml::out=${_NullFile}
329 --reporter junit::out=${_NullFile}
330 )
331
332 set_tests_properties(
333 MultiReporter::NoncapturingListenerDoesntCauseStdoutPassThrough
334 PROPERTIES
335 PASS_REGULAR_EXPRESSION "X24 - NonCapturingListener initialized"
336 FAIL_REGULAR_EXPRESSION "X24 - FooBarBaz"
337 )
338 endif()
339
340
341 add_executable(ListenerCanAskForCapturedStdout ${TESTS_DIR}/X25-ListenerCanAskForCapturedStdout.cpp)
342 target_link_libraries(ListenerCanAskForCapturedStdout PRIVATE Catch2::Catch2WithMain)
343 add_test(
344 NAME MultiReporter::CapturingListenerCausesStdoutCapture
345 COMMAND ListenerCanAskForCapturedStdout
346 --reporter compact::out=${_NullFile}
347 --reporter console::out=${_NullFile}
348 )
349 set_tests_properties(
350 MultiReporter::CapturingListenerCausesStdoutCapture
351 PROPERTIES
352 PASS_REGULAR_EXPRESSION "CapturingListener initialized"
353 FAIL_REGULAR_EXPRESSION "X25 - ERROR"
354 )
355
356 add_executable(ReporterPreferencesForPassingAssertionsIsRespected ${TESTS_DIR}/X26-ReporterPreferencesForPassingAssertionsIsRespected.cpp)
357 target_link_libraries(ReporterPreferencesForPassingAssertionsIsRespected PRIVATE Catch2::Catch2WithMain)
358 add_test(
359 NAME Reporters::PreferencesForPassingAssertionsIsRespected
360 COMMAND ReporterPreferencesForPassingAssertionsIsRespected
361 --reporter test-reporter
362 )
363 set_tests_properties(
364 Reporters::PreferencesForPassingAssertionsIsRespected
365 PROPERTIES
366 PASS_REGULAR_EXPRESSION "X26 - TestReporter constructed"
367 FAIL_REGULAR_EXPRESSION "X26 - assertionEnded"
368 )
369 add_test(
370 NAME MultiReporter::PreferencesForPassingAssertionsIsRespected
371 COMMAND ReporterPreferencesForPassingAssertionsIsRespected
372 --reporter test-reporter
373 --reporter console::out=${_NullFile}
374 )
375 set_tests_properties(
376 MultiReporter::PreferencesForPassingAssertionsIsRespected
377 PROPERTIES
378 PASS_REGULAR_EXPRESSION "X26 - TestReporter constructed"
379 FAIL_REGULAR_EXPRESSION "X26 - assertionEnded"
380 )
381
382 add_executable(ListenersGetEventsBeforeReporters ${TESTS_DIR}/X28-ListenersGetEventsBeforeReporters.cpp)
383 target_link_libraries(ListenersGetEventsBeforeReporters PRIVATE Catch2::Catch2WithMain)
384 add_test(
385 NAME ListenersGetEventsBeforeReporters
386 COMMAND ListenersGetEventsBeforeReporters --reporter test-reporter
387 )
388 set_tests_properties(
389 ListenersGetEventsBeforeReporters
390 PROPERTIES
391 PASS_REGULAR_EXPRESSION "X28 - TestReporter constructed"
392 FAIL_REGULAR_EXPRESSION "X28 - ERROR"
393 )
394
395 add_executable(CustomArgumentsForReporters ${TESTS_DIR}/X29-CustomArgumentsForReporters.cpp)
396 target_link_libraries(CustomArgumentsForReporters PRIVATE Catch2::Catch2WithMain)
397 add_test(
398 NAME CustomArgumentsForReporters
399 COMMAND CustomArgumentsForReporters
400 --reporter "test-reporter::Xa b=c 1::Xz:e = 1234"
401 )
402 set_tests_properties(
403 CustomArgumentsForReporters
404 PROPERTIES
405 PASS_REGULAR_EXPRESSION "Xa b=c 1::Xz:e = 1234"
406 )
407
408
409 add_executable(DuplicatedTestCases-SameNameAndTags ${TESTS_DIR}/X31-DuplicatedTestCases.cpp)
410 target_link_libraries(DuplicatedTestCases-SameNameAndTags PRIVATE Catch2::Catch2WithMain)
411 add_test(
412 NAME DuplicatedTestCases::SameNameAndTags
413 COMMAND $<TARGET_FILE:DuplicatedTestCases-SameNameAndTags>
414 )
415 set_tests_properties(
416 DuplicatedTestCases::SameNameAndTags
417 PROPERTIES
418 PASS_REGULAR_EXPRESSION "error: .* already defined\\."
419 )
420
421 add_executable(DuplicatedTestCases-SameNameDifferentTags ${TESTS_DIR}/X32-DuplicatedTestCasesDifferentTags.cpp)
422 target_link_libraries(DuplicatedTestCases-SameNameDifferentTags PRIVATE Catch2::Catch2WithMain)
423 add_test(
424 NAME DuplicatedTestCases::SameNameDifferentTags
425 COMMAND $<TARGET_FILE:DuplicatedTestCases-SameNameDifferentTags>
426 )
427 set_tests_properties(
428 DuplicatedTestCases::SameNameDifferentTags
429 PROPERTIES
430 FAIL_REGULAR_EXPRESSION "error: .* already defined\\."
431 )
432
433 add_executable(DuplicatedTestCases-DuplicatedTestCaseMethods ${TESTS_DIR}/X33-DuplicatedTestCaseMethods.cpp)
434 target_link_libraries(DuplicatedTestCases-DuplicatedTestCaseMethods PRIVATE Catch2::Catch2WithMain)
435 add_test(
436 NAME DuplicatedTestCases::DuplicatedTestCaseMethods
437 COMMAND $<TARGET_FILE:DuplicatedTestCases-DuplicatedTestCaseMethods>
438 )
439 set_tests_properties(
440 DuplicatedTestCases::DuplicatedTestCaseMethods
441 PROPERTIES
442 PASS_REGULAR_EXPRESSION "error: .* already defined\\."
443 )
444
445 add_executable(DuplicatedTestCases-DifferentFixtures ${TESTS_DIR}/X34-DuplicatedTestCaseMethodsDifferentFixtures.cpp)
446 target_link_libraries(DuplicatedTestCases-DifferentFixtures PRIVATE Catch2::Catch2WithMain)
447 add_test(
448 NAME DuplicatedTestCases::DuplicatedTestCaseMethodsDifferentFixtures
449 COMMAND $<TARGET_FILE:DuplicatedTestCases-DifferentFixtures>
450 )
451 set_tests_properties(
452 DuplicatedTestCases::DuplicatedTestCaseMethodsDifferentFixtures
453 PROPERTIES
454 FAIL_REGULAR_EXPRESSION "error: .* already defined\\."
455 )
456
457
458 add_executable(DuplicatedReporters ${TESTS_DIR}/X35-DuplicatedReporterNames.cpp)
459 target_link_libraries(DuplicatedReporters PRIVATE Catch2::Catch2WithMain)
460 add_test(
461 NAME Reporters::RegistrationErrorsAreCaught
462 COMMAND $<TARGET_FILE:DuplicatedReporters>
463 )
464 set_tests_properties(
465 Reporters::RegistrationErrorsAreCaught
466 PROPERTIES
467 PASS_REGULAR_EXPRESSION "Errors occurred during startup!"
468 )
469
470
471 add_executable(AssertionStartingEventGoesBeforeAssertionIsEvaluated
472 X20-AssertionStartingEventGoesBeforeAssertionIsEvaluated.cpp
473 )
474 target_link_libraries(AssertionStartingEventGoesBeforeAssertionIsEvaluated
475 PRIVATE Catch2::Catch2WithMain
476 )
477 add_test(
478 NAME ReporterEvents::AssertionStartingHappensBeforeAssertionIsEvaluated
479 COMMAND $<TARGET_FILE:AssertionStartingEventGoesBeforeAssertionIsEvaluated>
480 )
481
482 #add_executable(DebugBreakMacros ${TESTS_DIR}/X12-CustomDebugBreakMacro.cpp)
483 #target_link_libraries(DebugBreakMacros Catch2)
484 #add_test(NAME DebugBreakMacros COMMAND DebugBreakMacros --break)
485 #set_tests_properties(
486 # DebugBreakMacros
487 # PROPERTIES
488 # PASS_REGULAR_EXPRESSION "Pretty please, break into debugger"
489 #)
490
491 add_executable(NoTests ${TESTS_DIR}/X92-NoTests.cpp)
492 target_link_libraries(NoTests PRIVATE Catch2::Catch2WithMain)
493
494 add_test(
495 NAME TestSpecs::EmptySpecWithNoTestsFails
496 COMMAND $<TARGET_FILE:NoTests>
497 )
498 set_tests_properties(TestSpecs::EmptySpecWithNoTestsFails
499 PROPERTIES
500 WILL_FAIL ON
501 )
502
503 add_test(
504 NAME TestSpecs::OverrideFailureWithEmptySpec
505 COMMAND $<TARGET_FILE:NoTests> --allow-running-no-tests
506 )
507
508 add_test(
509 NAME List::Listeners::WorksWithoutRegisteredListeners
510 COMMAND $<TARGET_FILE:NoTests> --list-listeners
511 )
512
513
514 add_executable(AllSkipped ${TESTS_DIR}/X93-AllSkipped.cpp)
515 target_link_libraries(AllSkipped PRIVATE Catch2::Catch2WithMain)
516
517 add_test(
518 NAME TestSpecs::SkippingAllTestsFails
519 COMMAND $<TARGET_FILE:AllSkipped>
520 )
521 set_tests_properties(TestSpecs::SkippingAllTestsFails
522 PROPERTIES
523 WILL_FAIL ON
524 )
525
526 set( EXTRA_TEST_BINARIES
527 AllSkipped
528 PrefixedMacros
529 DisabledMacros
530 DisabledExceptions-DefaultHandler
531 DisabledExceptions-CustomHandler
532 FallbackStringifier
533 DisableStringification
534 PartialTestCaseEvents
535 DuplicatedTestCases-SameNameAndTags
536 DuplicatedTestCases-SameNameDifferentTags
537 DuplicatedTestCases-DuplicatedTestCaseMethods
538 NoTests
539 ListenersGetEventsBeforeReporters
540 # DebugBreakMacros
541 )
542
543 # Notice that we are modifying EXTRA_TEST_BINARIES destructively, do not
544 # use it after this point!
545 list(FILTER EXTRA_TEST_BINARIES EXCLUDE REGEX "DisabledExceptions.*")
546 list(APPEND CATCH_WARNING_TARGETS ${EXTRA_TEST_BINARIES})
547 set(CATCH_WARNING_TARGETS ${CATCH_WARNING_TARGETS} PARENT_SCOPE)
548
549
550 # This sets up a one-off executable that compiles against the amalgamated
551 # files, and then runs it for a super simple check that the amalgamated
552 # files are usable.
553 add_executable(AmalgamatedTestCompilation
554 ${TESTS_DIR}/X91-AmalgamatedCatch.cpp
555 ${CATCH_DIR}/extras/catch_amalgamated.hpp
556 ${CATCH_DIR}/extras/catch_amalgamated.cpp
557 )
558 target_include_directories(AmalgamatedTestCompilation PRIVATE ${CATCH_DIR}/extras)
559
560 add_test(NAME AmalgamatedFileTest COMMAND AmalgamatedTestCompilation)
561 set_tests_properties(
562 AmalgamatedFileTest
563 PROPERTIES
564 PASS_REGULAR_EXPRESSION "All tests passed \\(14 assertions in 3 test cases\\)"
565 )