• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1include(MiscFunctions)
2
3####
4# Temporary workaround for VS toolset changes in 2017
5# We need to disable <UseFullPaths> property, but CMake doesn't support it
6# until 3.13 (not yet released)
7####
8if (MSVC)
9configure_file(${CATCH_DIR}/misc/SelfTest.vcxproj.user
10               ${CMAKE_BINARY_DIR}/projects
11               COPYONLY)
12endif(MSVC) #Temporary workaround
13
14
15# define the sources of the self test
16# Please keep these ordered alphabetically
17set(TEST_SOURCES
18        ${SELF_TEST_DIR}/TestMain.cpp
19        ${SELF_TEST_DIR}/IntrospectiveTests/CmdLine.tests.cpp
20        ${SELF_TEST_DIR}/IntrospectiveTests/Details.tests.cpp
21        ${SELF_TEST_DIR}/IntrospectiveTests/GeneratorsImpl.tests.cpp
22        ${SELF_TEST_DIR}/IntrospectiveTests/InternalBenchmark.tests.cpp
23        ${SELF_TEST_DIR}/IntrospectiveTests/PartTracker.tests.cpp
24        ${SELF_TEST_DIR}/IntrospectiveTests/RandomNumberGeneration.tests.cpp
25        ${SELF_TEST_DIR}/IntrospectiveTests/Tag.tests.cpp
26        ${SELF_TEST_DIR}/IntrospectiveTests/String.tests.cpp
27        ${SELF_TEST_DIR}/IntrospectiveTests/StringManip.tests.cpp
28        ${SELF_TEST_DIR}/IntrospectiveTests/Xml.tests.cpp
29        ${SELF_TEST_DIR}/IntrospectiveTests/ToString.tests.cpp
30        ${SELF_TEST_DIR}/UsageTests/Approx.tests.cpp
31        ${SELF_TEST_DIR}/UsageTests/BDD.tests.cpp
32        ${SELF_TEST_DIR}/UsageTests/Benchmark.tests.cpp
33        ${SELF_TEST_DIR}/UsageTests/Class.tests.cpp
34        ${SELF_TEST_DIR}/UsageTests/Compilation.tests.cpp
35        ${SELF_TEST_DIR}/UsageTests/Condition.tests.cpp
36        ${SELF_TEST_DIR}/UsageTests/Decomposition.tests.cpp
37        ${SELF_TEST_DIR}/UsageTests/EnumToString.tests.cpp
38        ${SELF_TEST_DIR}/UsageTests/Exception.tests.cpp
39        ${SELF_TEST_DIR}/UsageTests/Generators.tests.cpp
40        ${SELF_TEST_DIR}/UsageTests/Message.tests.cpp
41        ${SELF_TEST_DIR}/UsageTests/Misc.tests.cpp
42        ${SELF_TEST_DIR}/UsageTests/ToStringByte.tests.cpp
43        ${SELF_TEST_DIR}/UsageTests/ToStringChrono.tests.cpp
44        ${SELF_TEST_DIR}/UsageTests/ToStringGeneral.tests.cpp
45        ${SELF_TEST_DIR}/UsageTests/ToStringOptional.tests.cpp
46        ${SELF_TEST_DIR}/UsageTests/ToStringPair.tests.cpp
47        ${SELF_TEST_DIR}/UsageTests/ToStringTuple.tests.cpp
48        ${SELF_TEST_DIR}/UsageTests/ToStringVariant.tests.cpp
49        ${SELF_TEST_DIR}/UsageTests/ToStringVector.tests.cpp
50        ${SELF_TEST_DIR}/UsageTests/ToStringWhich.tests.cpp
51        ${SELF_TEST_DIR}/UsageTests/Tricky.tests.cpp
52        ${SELF_TEST_DIR}/UsageTests/VariadicMacros.tests.cpp
53        ${SELF_TEST_DIR}/UsageTests/Matchers.tests.cpp
54        )
55CheckFileList(TEST_SOURCES ${SELF_TEST_DIR})
56
57# A set of impl files that just #include a single header
58# Please keep these ordered alphabetically
59set(SURROGATE_SOURCES
60        ${SELF_TEST_DIR}/SurrogateCpps/catch_console_colour.cpp
61        ${SELF_TEST_DIR}/SurrogateCpps/catch_debugger.cpp
62        ${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_reporter.cpp
63        ${SELF_TEST_DIR}/SurrogateCpps/catch_option.cpp
64        ${SELF_TEST_DIR}/SurrogateCpps/catch_stream.cpp
65        ${SELF_TEST_DIR}/SurrogateCpps/catch_test_case_tracker.cpp
66        ${SELF_TEST_DIR}/SurrogateCpps/catch_test_spec.cpp
67        ${SELF_TEST_DIR}/SurrogateCpps/catch_xmlwriter.cpp
68        )
69CheckFileList(SURROGATE_SOURCES ${SELF_TEST_DIR}/SurrogateCpps)
70
71
72# Please keep these ordered alphabetically
73set(TOP_LEVEL_HEADERS
74        ${HEADER_DIR}/catch.hpp
75        ${HEADER_DIR}/catch_with_main.hpp
76        )
77CheckFileList(TOP_LEVEL_HEADERS ${HEADER_DIR})
78
79# Please keep these ordered alphabetically
80set(EXTERNAL_HEADERS
81        ${HEADER_DIR}/external/clara.hpp
82        )
83CheckFileList(EXTERNAL_HEADERS ${HEADER_DIR}/external)
84
85
86# Please keep these ordered alphabetically
87set(BENCHMARK_HEADERS
88		${HEADER_DIR}/internal/benchmark/catch_benchmark.hpp
89        ${HEADER_DIR}/internal/benchmark/catch_chronometer.hpp
90        ${HEADER_DIR}/internal/benchmark/catch_clock.hpp
91        ${HEADER_DIR}/internal/benchmark/catch_constructor.hpp
92        ${HEADER_DIR}/internal/benchmark/catch_environment.hpp
93        ${HEADER_DIR}/internal/benchmark/catch_estimate.hpp
94        ${HEADER_DIR}/internal/benchmark/catch_execution_plan.hpp
95        ${HEADER_DIR}/internal/benchmark/catch_optimizer.hpp
96        ${HEADER_DIR}/internal/benchmark/catch_outlier_classification.hpp
97        ${HEADER_DIR}/internal/benchmark/catch_sample_analysis.hpp
98        ${HEADER_DIR}/internal/benchmark/detail/catch_analyse.hpp
99        ${HEADER_DIR}/internal/benchmark/detail/catch_benchmark_function.hpp
100        ${HEADER_DIR}/internal/benchmark/detail/catch_complete_invoke.hpp
101        ${HEADER_DIR}/internal/benchmark/detail/catch_estimate_clock.hpp
102        ${HEADER_DIR}/internal/benchmark/detail/catch_measure.hpp
103        ${HEADER_DIR}/internal/benchmark/detail/catch_repeat.hpp
104        ${HEADER_DIR}/internal/benchmark/detail/catch_run_for_at_least.hpp
105        ${HEADER_DIR}/internal/benchmark/detail/catch_stats.hpp
106        ${HEADER_DIR}/internal/benchmark/detail/catch_timing.hpp
107)
108set(BENCHMARK_SOURCES
109    ${HEADER_DIR}/internal/benchmark/detail/catch_stats.cpp
110)
111
112SOURCE_GROUP("benchmark" FILES ${BENCHMARK_HEADERS} ${BENCHMARK_SOURCES})
113
114set(INTERNAL_HEADERS
115        ${HEADER_DIR}/internal/catch_approx.h
116        ${HEADER_DIR}/internal/catch_assertionhandler.h
117        ${HEADER_DIR}/internal/catch_assertioninfo.h
118        ${HEADER_DIR}/internal/catch_assertionresult.h
119        ${HEADER_DIR}/internal/catch_capture.hpp
120        ${HEADER_DIR}/internal/catch_capture_matchers.h
121        ${HEADER_DIR}/internal/catch_clara.h
122        ${HEADER_DIR}/internal/catch_commandline.h
123        ${HEADER_DIR}/internal/catch_common.h
124        ${HEADER_DIR}/internal/catch_compiler_capabilities.h
125        ${HEADER_DIR}/internal/catch_config.hpp
126        ${HEADER_DIR}/internal/catch_console_colour.h
127        ${HEADER_DIR}/internal/catch_context.h
128        ${HEADER_DIR}/internal/catch_debug_console.h
129        ${HEADER_DIR}/internal/catch_debugger.h
130        ${HEADER_DIR}/internal/catch_decomposer.h
131        ${HEADER_DIR}/internal/catch_default_main.hpp
132        ${HEADER_DIR}/internal/catch_enforce.h
133        ${HEADER_DIR}/internal/catch_enum_values_registry.h
134        ${HEADER_DIR}/internal/catch_errno_guard.h
135        ${HEADER_DIR}/internal/catch_exception_translator_registry.h
136        ${HEADER_DIR}/internal/catch_external_interfaces.h
137        ${HEADER_DIR}/internal/catch_fatal_condition.h
138        ${HEADER_DIR}/internal/catch_generators.hpp
139        ${HEADER_DIR}/internal/catch_generators_generic.hpp
140        ${HEADER_DIR}/internal/catch_generators_specific.hpp
141        ${HEADER_DIR}/internal/catch_impl.hpp
142        ${HEADER_DIR}/internal/catch_interfaces_capture.h
143        ${HEADER_DIR}/internal/catch_interfaces_config.h
144        ${HEADER_DIR}/internal/catch_interfaces_enum_values_registry.h
145        ${HEADER_DIR}/internal/catch_interfaces_exception.h
146        ${HEADER_DIR}/internal/catch_interfaces_registry_hub.h
147        ${HEADER_DIR}/internal/catch_interfaces_reporter.h
148        ${HEADER_DIR}/internal/catch_interfaces_runner.h
149        ${HEADER_DIR}/internal/catch_interfaces_tag_alias_registry.h
150        ${HEADER_DIR}/internal/catch_interfaces_testcase.h
151        ${HEADER_DIR}/internal/catch_leak_detector.h
152        ${HEADER_DIR}/internal/catch_list.h
153        ${HEADER_DIR}/internal/catch_matchers.h
154        ${HEADER_DIR}/internal/catch_matchers_exception.hpp
155        ${HEADER_DIR}/internal/catch_matchers_floating.h
156        ${HEADER_DIR}/internal/catch_matchers_generic.hpp
157        ${HEADER_DIR}/internal/catch_matchers_string.h
158        ${HEADER_DIR}/internal/catch_matchers_vector.h
159        ${HEADER_DIR}/internal/catch_message.h
160        ${HEADER_DIR}/internal/catch_meta.hpp
161        ${HEADER_DIR}/internal/catch_objc.hpp
162        ${HEADER_DIR}/internal/catch_objc_arc.hpp
163        ${HEADER_DIR}/internal/catch_option.hpp
164        ${HEADER_DIR}/internal/catch_output_redirect.h
165        ${HEADER_DIR}/internal/catch_platform.h
166        ${HEADER_DIR}/internal/catch_polyfills.hpp
167        ${HEADER_DIR}/internal/catch_preprocessor.hpp
168        ${HEADER_DIR}/internal/catch_random_number_generator.h
169        ${HEADER_DIR}/internal/catch_reenable_warnings.h
170        ${HEADER_DIR}/internal/catch_reporter_registrars.hpp
171        ${HEADER_DIR}/internal/catch_reporter_registry.h
172        ${HEADER_DIR}/internal/catch_result_type.h
173        ${HEADER_DIR}/internal/catch_run_context.h
174        ${HEADER_DIR}/internal/catch_section.h
175        ${HEADER_DIR}/internal/catch_section_info.h
176        ${HEADER_DIR}/internal/catch_session.h
177        ${HEADER_DIR}/internal/catch_singletons.hpp
178        ${HEADER_DIR}/internal/catch_startup_exception_registry.h
179        ${HEADER_DIR}/internal/catch_stream.h
180        ${HEADER_DIR}/internal/catch_stringref.h
181        ${HEADER_DIR}/internal/catch_string_manip.h
182        ${HEADER_DIR}/internal/catch_suppress_warnings.h
183        ${HEADER_DIR}/internal/catch_tag_alias.h
184        ${HEADER_DIR}/internal/catch_tag_alias_autoregistrar.h
185        ${HEADER_DIR}/internal/catch_tag_alias_registry.h
186        ${HEADER_DIR}/internal/catch_test_case_info.h
187        ${HEADER_DIR}/internal/catch_test_case_registry_impl.h
188        ${HEADER_DIR}/internal/catch_test_case_tracker.h
189        ${HEADER_DIR}/internal/catch_test_registry.h
190        ${HEADER_DIR}/internal/catch_test_spec.h
191        ${HEADER_DIR}/internal/catch_test_spec_parser.h
192        ${HEADER_DIR}/internal/catch_text.h
193        ${HEADER_DIR}/internal/catch_timer.h
194        ${HEADER_DIR}/internal/catch_to_string.hpp
195        ${HEADER_DIR}/internal/catch_tostring.h
196        ${HEADER_DIR}/internal/catch_totals.h
197        ${HEADER_DIR}/internal/catch_uncaught_exceptions.h
198        ${HEADER_DIR}/internal/catch_user_interfaces.h
199        ${HEADER_DIR}/internal/catch_version.h
200        ${HEADER_DIR}/internal/catch_wildcard_pattern.h
201        ${HEADER_DIR}/internal/catch_windows_h_proxy.h
202        ${HEADER_DIR}/internal/catch_xmlwriter.h
203        )
204set(IMPL_SOURCES
205        ${HEADER_DIR}/internal/catch_approx.cpp
206        ${HEADER_DIR}/internal/catch_assertionhandler.cpp
207        ${HEADER_DIR}/internal/catch_assertionresult.cpp
208        ${HEADER_DIR}/internal/catch_capture_matchers.cpp
209        ${HEADER_DIR}/internal/catch_commandline.cpp
210        ${HEADER_DIR}/internal/catch_common.cpp
211        ${HEADER_DIR}/internal/catch_config.cpp
212        ${HEADER_DIR}/internal/catch_console_colour.cpp
213        ${HEADER_DIR}/internal/catch_context.cpp
214        ${HEADER_DIR}/internal/catch_debug_console.cpp
215        ${HEADER_DIR}/internal/catch_debugger.cpp
216        ${HEADER_DIR}/internal/catch_decomposer.cpp
217        ${HEADER_DIR}/internal/catch_enforce.cpp
218        ${HEADER_DIR}/internal/catch_enum_values_registry.cpp
219        ${HEADER_DIR}/internal/catch_errno_guard.cpp
220        ${HEADER_DIR}/internal/catch_exception_translator_registry.cpp
221        ${HEADER_DIR}/internal/catch_fatal_condition.cpp
222        ${HEADER_DIR}/internal/catch_generators.cpp
223        ${HEADER_DIR}/internal/catch_interfaces_capture.cpp
224        ${HEADER_DIR}/internal/catch_interfaces_config.cpp
225        ${HEADER_DIR}/internal/catch_interfaces_exception.cpp
226        ${HEADER_DIR}/internal/catch_interfaces_generatortracker.h
227        ${HEADER_DIR}/internal/catch_interfaces_registry_hub.cpp
228        ${HEADER_DIR}/internal/catch_interfaces_runner.cpp
229        ${HEADER_DIR}/internal/catch_interfaces_testcase.cpp
230        ${HEADER_DIR}/internal/catch_list.cpp
231        ${HEADER_DIR}/internal/catch_leak_detector.cpp
232        ${HEADER_DIR}/internal/catch_matchers.cpp
233        ${HEADER_DIR}/internal/catch_matchers_exception.cpp
234        ${HEADER_DIR}/internal/catch_matchers_floating.cpp
235        ${HEADER_DIR}/internal/catch_matchers_generic.cpp
236        ${HEADER_DIR}/internal/catch_matchers_string.cpp
237        ${HEADER_DIR}/internal/catch_message.cpp
238        ${HEADER_DIR}/internal/catch_output_redirect.cpp
239        ${HEADER_DIR}/internal/catch_registry_hub.cpp
240        ${HEADER_DIR}/internal/catch_interfaces_reporter.cpp
241        ${HEADER_DIR}/internal/catch_polyfills.cpp
242        ${HEADER_DIR}/internal/catch_random_number_generator.cpp
243        ${HEADER_DIR}/internal/catch_reporter_registry.cpp
244        ${HEADER_DIR}/internal/catch_result_type.cpp
245        ${HEADER_DIR}/internal/catch_run_context.cpp
246        ${HEADER_DIR}/internal/catch_section.cpp
247        ${HEADER_DIR}/internal/catch_section_info.cpp
248        ${HEADER_DIR}/internal/catch_session.cpp
249        ${HEADER_DIR}/internal/catch_singletons.cpp
250        ${HEADER_DIR}/internal/catch_startup_exception_registry.cpp
251        ${HEADER_DIR}/internal/catch_stream.cpp
252        ${HEADER_DIR}/internal/catch_stringref.cpp
253        ${HEADER_DIR}/internal/catch_string_manip.cpp
254        ${HEADER_DIR}/internal/catch_tag_alias.cpp
255        ${HEADER_DIR}/internal/catch_tag_alias_autoregistrar.cpp
256        ${HEADER_DIR}/internal/catch_tag_alias_registry.cpp
257        ${HEADER_DIR}/internal/catch_test_case_info.cpp
258        ${HEADER_DIR}/internal/catch_test_case_registry_impl.cpp
259        ${HEADER_DIR}/internal/catch_test_case_tracker.cpp
260        ${HEADER_DIR}/internal/catch_test_registry.cpp
261        ${HEADER_DIR}/internal/catch_test_spec.cpp
262        ${HEADER_DIR}/internal/catch_test_spec_parser.cpp
263        ${HEADER_DIR}/internal/catch_timer.cpp
264        ${HEADER_DIR}/internal/catch_tostring.cpp
265        ${HEADER_DIR}/internal/catch_totals.cpp
266        ${HEADER_DIR}/internal/catch_uncaught_exceptions.cpp
267        ${HEADER_DIR}/internal/catch_version.cpp
268        ${HEADER_DIR}/internal/catch_wildcard_pattern.cpp
269        ${HEADER_DIR}/internal/catch_xmlwriter.cpp
270        )
271set(INTERNAL_FILES ${IMPL_SOURCES} ${INTERNAL_HEADERS})
272CheckFileList(INTERNAL_FILES ${HEADER_DIR}/internal)
273
274# Please keep these ordered alphabetically
275set(REPORTER_HEADERS
276        ${HEADER_DIR}/reporters/catch_reporter_automake.hpp
277        ${HEADER_DIR}/reporters/catch_reporter_bases.hpp
278        ${HEADER_DIR}/reporters/catch_reporter_compact.h
279        ${HEADER_DIR}/reporters/catch_reporter_console.h
280        ${HEADER_DIR}/reporters/catch_reporter_junit.h
281        ${HEADER_DIR}/reporters/catch_reporter_listening.h
282        ${HEADER_DIR}/reporters/catch_reporter_tap.hpp
283        ${HEADER_DIR}/reporters/catch_reporter_teamcity.hpp
284        ${HEADER_DIR}/reporters/catch_reporter_xml.h
285        ${HEADER_DIR}/reporters/catch_reporter_sonarqube.hpp
286        )
287set(REPORTER_SOURCES
288        ${HEADER_DIR}/reporters/catch_reporter_bases.cpp
289        ${HEADER_DIR}/reporters/catch_reporter_compact.cpp
290        ${HEADER_DIR}/reporters/catch_reporter_console.cpp
291        ${HEADER_DIR}/reporters/catch_reporter_junit.cpp
292        ${HEADER_DIR}/reporters/catch_reporter_listening.cpp
293        ${HEADER_DIR}/reporters/catch_reporter_xml.cpp
294        )
295set(REPORTER_FILES ${REPORTER_HEADERS} ${REPORTER_SOURCES})
296CheckFileList(REPORTER_FILES ${HEADER_DIR}/reporters)
297
298# Specify the headers, too, so CLion recognises them as project files
299set(HEADERS
300        ${TOP_LEVEL_HEADERS}
301        ${EXTERNAL_HEADERS}
302        ${INTERNAL_HEADERS}
303        ${REPORTER_HEADERS}
304		${BENCHMARK_HEADERS}
305        ${BENCHMARK_SOURCES}
306)
307
308# Provide some groupings for IDEs
309SOURCE_GROUP("Tests" FILES ${TEST_SOURCES})
310SOURCE_GROUP("Surrogates" FILES ${SURROGATE_SOURCES})
311
312include(CTest)
313
314add_executable(SelfTest ${TEST_SOURCES} ${IMPL_SOURCES} ${REPORTER_SOURCES} ${SURROGATE_SOURCES} ${HEADERS})
315target_include_directories(SelfTest PRIVATE ${HEADER_DIR})
316
317# It took CMake until 3.8 to abandon the doomed approach of enumerating
318# required features so we just list C++11 features to support older ones.
319target_compile_features(SelfTest
320  PRIVATE
321    cxx_alignas
322    cxx_alignof
323    cxx_attributes
324    cxx_auto_type
325    cxx_constexpr
326    cxx_defaulted_functions
327    cxx_deleted_functions
328    cxx_final
329    cxx_lambdas
330    cxx_noexcept
331    cxx_override
332    cxx_range_for
333    cxx_rvalue_references
334    cxx_static_assert
335    cxx_strong_enums
336    cxx_trailing_return_types
337    cxx_unicode_literals
338    cxx_user_literals
339    cxx_variadic_macros
340)
341
342
343if (CATCH_ENABLE_COVERAGE)
344    set(ENABLE_COVERAGE ON CACHE BOOL "Enable coverage build." FORCE)
345    find_package(codecov)
346    add_coverage(SelfTest)
347    list(APPEND LCOV_REMOVE_PATTERNS "'/usr/*'")
348    coverage_evaluate()
349endif()
350
351# Add per compiler options
352if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang|GNU" )
353    target_compile_options( SelfTest PRIVATE -Wall -Wextra -Wunreachable-code -Wpedantic -Wmissing-declarations )
354    if (CATCH_ENABLE_WERROR)
355        target_compile_options( SelfTest PRIVATE -Werror )
356    endif()
357endif()
358# Clang specific options go here
359if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
360    target_compile_options( SelfTest PRIVATE -Wweak-vtables -Wexit-time-destructors -Wglobal-constructors -Wmissing-noreturn )
361endif()
362if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
363    STRING(REGEX REPLACE "/W[0-9]" "/W4" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # override default warning level
364    target_compile_options( SelfTest PRIVATE /w44265 /w44061 /w44062 /w45038 )
365    if (CATCH_ENABLE_WERROR)
366        target_compile_options( SelfTest PRIVATE /WX)
367    endif()
368    # Force MSVC to consider everything as encoded in utf-8
369    target_compile_options( SelfTest PRIVATE /utf-8 )
370endif()
371
372
373# configure unit tests via CTest
374add_test(NAME RunTests COMMAND $<TARGET_FILE:SelfTest>)
375set_tests_properties(RunTests PROPERTIES
376    FAIL_REGULAR_EXPRESSION "Filters:"
377)
378
379add_test(NAME ListTests COMMAND $<TARGET_FILE:SelfTest> --list-tests --verbosity high)
380set_tests_properties(ListTests PROPERTIES
381    PASS_REGULAR_EXPRESSION "[0-9]+ test cases"
382    FAIL_REGULAR_EXPRESSION "Hidden Test"
383)
384
385add_test(NAME ListTags COMMAND $<TARGET_FILE:SelfTest> --list-tags)
386set_tests_properties(ListTags PROPERTIES
387    PASS_REGULAR_EXPRESSION "[0-9]+ tags"
388    FAIL_REGULAR_EXPRESSION "\\[\\.\\]")
389
390add_test(NAME ListReporters COMMAND $<TARGET_FILE:SelfTest> --list-reporters)
391set_tests_properties(ListReporters PROPERTIES PASS_REGULAR_EXPRESSION "Available reporters:")
392
393add_test(NAME ListTestNamesOnly COMMAND $<TARGET_FILE:SelfTest> --list-test-names-only)
394set_tests_properties(ListTestNamesOnly PROPERTIES
395    PASS_REGULAR_EXPRESSION "Regex string matcher"
396    FAIL_REGULAR_EXPRESSION "Hidden Test")
397
398add_test(NAME NoAssertions COMMAND $<TARGET_FILE:SelfTest> -w NoAssertions)
399set_tests_properties(NoAssertions PROPERTIES PASS_REGULAR_EXPRESSION "No assertions in test case")
400
401add_test(NAME NoTest COMMAND $<TARGET_FILE:SelfTest> Tracker, "___nonexistent_test___")
402set_tests_properties(NoTest PROPERTIES
403    PASS_REGULAR_EXPRESSION "No test cases matched '___nonexistent_test___'"
404    FAIL_REGULAR_EXPRESSION "No tests ran"
405)
406
407add_test(NAME WarnAboutNoTests COMMAND ${CMAKE_COMMAND} -P ${CATCH_DIR}/projects/SelfTest/WarnAboutNoTests.cmake $<TARGET_FILE:SelfTest>)
408
409add_test(NAME UnmatchedOutputFilter COMMAND $<TARGET_FILE:SelfTest> [this-tag-does-not-exist] -w NoTests)
410set_tests_properties(UnmatchedOutputFilter
411  PROPERTIES
412    PASS_REGULAR_EXPRESSION "No test cases matched '\\[this-tag-does-not-exist\\]'"
413)
414
415add_test(NAME FilteredSection-1 COMMAND $<TARGET_FILE:SelfTest> \#1394 -c RunSection)
416set_tests_properties(FilteredSection-1 PROPERTIES FAIL_REGULAR_EXPRESSION "No tests ran")
417add_test(NAME FilteredSection-2 COMMAND $<TARGET_FILE:SelfTest> \#1394\ nested -c NestedRunSection -c s1)
418set_tests_properties(FilteredSection-2 PROPERTIES FAIL_REGULAR_EXPRESSION "No tests ran")
419
420# AppVeyor has a Python 2.7 in path, but doesn't have .py files as autorunnable
421add_test(NAME ApprovalTests COMMAND ${PYTHON_EXECUTABLE} ${CATCH_DIR}/scripts/approvalTests.py $<TARGET_FILE:SelfTest>)
422set_tests_properties(ApprovalTests PROPERTIES FAIL_REGULAR_EXPRESSION "Results differed")
423
424add_test(NAME RegressionCheck-1670 COMMAND $<TARGET_FILE:SelfTest> "#1670 regression check" -c A -r compact)
425set_tests_properties(RegressionCheck-1670 PROPERTIES PASS_REGULAR_EXPRESSION "Passed 1 test case with 2 assertions.")
426
427add_test(NAME VersionCheck COMMAND $<TARGET_FILE:SelfTest> -h)
428set_tests_properties(VersionCheck PROPERTIES PASS_REGULAR_EXPRESSION "Catch v${PROJECT_VERSION}")
429
430add_test(NAME LibIdentityTest COMMAND $<TARGET_FILE:SelfTest> --libidentify)
431set_tests_properties(LibIdentityTest PROPERTIES PASS_REGULAR_EXPRESSION "description:    A Catch2 test executable")
432
433add_test(NAME FilenameAsTagsTest COMMAND $<TARGET_FILE:SelfTest> -\# --list-tags)
434set_tests_properties(FilenameAsTagsTest PROPERTIES PASS_REGULAR_EXPRESSION "\\[#Approx.tests\\]")
435
436add_test(NAME EscapeSpecialCharactersInTestNames COMMAND $<TARGET_FILE:SelfTest> "Test with special\\, characters \"in name")
437set_tests_properties(EscapeSpecialCharactersInTestNames PROPERTIES PASS_REGULAR_EXPRESSION "1 assertion in 1 test case")
438
439add_test(NAME TestsInFile::SimpleSpecs COMMAND $<TARGET_FILE:SelfTest> "-f ${CATCH_DIR}/projects/SelfTest/Misc/plain-old-tests.input")
440set_tests_properties(TestsInFile::SimpleSpecs PROPERTIES PASS_REGULAR_EXPRESSION "6 assertions in 2 test cases")
441
442add_test(NAME TestsInFile::EscapeSpecialCharacters COMMAND $<TARGET_FILE:SelfTest> "-f ${CATCH_DIR}/projects/SelfTest/Misc/special-characters-in-file.input")
443set_tests_properties(TestsInFile::EscapeSpecialCharacters PROPERTIES PASS_REGULAR_EXPRESSION "1 assertion in 1 test case")
444
445# CTest does not allow us to create an AND of required regular expressions,
446# so we have to split the test into 2 parts and look for parts of the expected
447# output separately.
448add_test(NAME TestsInFile::InvalidTestNames-1 COMMAND $<TARGET_FILE:SelfTest> "-f ${CATCH_DIR}/projects/SelfTest/Misc/invalid-test-names.input")
449set_tests_properties(TestsInFile::InvalidTestNames-1 PROPERTIES PASS_REGULAR_EXPRESSION "Invalid Filter: \"Test with special, characters in \\\\\" name\"")
450
451add_test(NAME TestsInFile::InvalidTestNames-2 COMMAND $<TARGET_FILE:SelfTest> "-f ${CATCH_DIR}/projects/SelfTest/Misc/invalid-test-names.input")
452set_tests_properties(TestsInFile::InvalidTestNames-2 PROPERTIES PASS_REGULAR_EXPRESSION "No tests ran")
453
454
455if (CATCH_USE_VALGRIND)
456    add_test(NAME ValgrindRunTests COMMAND valgrind --leak-check=full --error-exitcode=1 $<TARGET_FILE:SelfTest>)
457    add_test(NAME ValgrindListTests COMMAND valgrind --leak-check=full --error-exitcode=1 $<TARGET_FILE:SelfTest> --list-tests --verbosity high)
458    set_tests_properties(ValgrindListTests PROPERTIES PASS_REGULAR_EXPRESSION "definitely lost: 0 bytes in 0 blocks")
459    add_test(NAME ValgrindListTags COMMAND valgrind --leak-check=full --error-exitcode=1 $<TARGET_FILE:SelfTest> --list-tags)
460    set_tests_properties(ValgrindListTags PROPERTIES PASS_REGULAR_EXPRESSION "definitely lost: 0 bytes in 0 blocks")
461endif()
462