2018-06-11 10:48:10 +02:00
|
|
|
include(MiscFunctions)
|
|
|
|
|
2018-08-28 10:48:05 +02:00
|
|
|
####
|
|
|
|
# Temporary workaround for VS toolset changes in 2017
|
|
|
|
# We need to disable <UseFullPaths> property, but CMake doesn't support it
|
|
|
|
# until 3.13 (not yet released)
|
|
|
|
####
|
|
|
|
if (MSVC)
|
2019-12-06 11:40:53 +01:00
|
|
|
configure_file(${CATCH_DIR}/tools/misc/SelfTest.vcxproj.user
|
2019-12-05 16:00:20 +01:00
|
|
|
${CMAKE_BINARY_DIR}/tests
|
2018-08-28 10:48:05 +02:00
|
|
|
COPYONLY)
|
|
|
|
endif(MSVC) #Temporary workaround
|
|
|
|
|
|
|
|
|
2018-06-11 10:48:10 +02:00
|
|
|
# define the sources of the self test
|
|
|
|
# Please keep these ordered alphabetically
|
|
|
|
set(TEST_SOURCES
|
2020-05-07 16:24:05 +02:00
|
|
|
${SELF_TEST_DIR}/TestRegistrations.cpp
|
2018-06-11 10:48:10 +02:00
|
|
|
${SELF_TEST_DIR}/IntrospectiveTests/CmdLine.tests.cpp
|
2019-08-09 10:50:53 +02:00
|
|
|
${SELF_TEST_DIR}/IntrospectiveTests/Details.tests.cpp
|
2018-06-12 18:50:39 +02:00
|
|
|
${SELF_TEST_DIR}/IntrospectiveTests/GeneratorsImpl.tests.cpp
|
2019-04-23 23:41:13 +02:00
|
|
|
${SELF_TEST_DIR}/IntrospectiveTests/InternalBenchmark.tests.cpp
|
2018-06-11 10:48:10 +02:00
|
|
|
${SELF_TEST_DIR}/IntrospectiveTests/PartTracker.tests.cpp
|
2019-10-06 21:47:54 +02:00
|
|
|
${SELF_TEST_DIR}/IntrospectiveTests/RandomNumberGeneration.tests.cpp
|
2019-03-29 10:48:56 +01:00
|
|
|
${SELF_TEST_DIR}/IntrospectiveTests/Tag.tests.cpp
|
2018-06-11 10:48:10 +02:00
|
|
|
${SELF_TEST_DIR}/IntrospectiveTests/String.tests.cpp
|
2019-09-06 18:50:57 +02:00
|
|
|
${SELF_TEST_DIR}/IntrospectiveTests/StringManip.tests.cpp
|
2018-06-11 10:48:10 +02:00
|
|
|
${SELF_TEST_DIR}/IntrospectiveTests/Xml.tests.cpp
|
2019-04-25 11:13:11 +02:00
|
|
|
${SELF_TEST_DIR}/IntrospectiveTests/ToString.tests.cpp
|
2020-05-24 23:41:02 +02:00
|
|
|
${SELF_TEST_DIR}/IntrospectiveTests/UniquePtr.tests.cpp
|
2018-06-11 10:48:10 +02:00
|
|
|
${SELF_TEST_DIR}/UsageTests/Approx.tests.cpp
|
|
|
|
${SELF_TEST_DIR}/UsageTests/BDD.tests.cpp
|
|
|
|
${SELF_TEST_DIR}/UsageTests/Benchmark.tests.cpp
|
|
|
|
${SELF_TEST_DIR}/UsageTests/Class.tests.cpp
|
|
|
|
${SELF_TEST_DIR}/UsageTests/Compilation.tests.cpp
|
|
|
|
${SELF_TEST_DIR}/UsageTests/Condition.tests.cpp
|
|
|
|
${SELF_TEST_DIR}/UsageTests/Decomposition.tests.cpp
|
|
|
|
${SELF_TEST_DIR}/UsageTests/EnumToString.tests.cpp
|
|
|
|
${SELF_TEST_DIR}/UsageTests/Exception.tests.cpp
|
2018-06-12 18:50:39 +02:00
|
|
|
${SELF_TEST_DIR}/UsageTests/Generators.tests.cpp
|
2018-06-11 10:48:10 +02:00
|
|
|
${SELF_TEST_DIR}/UsageTests/Message.tests.cpp
|
|
|
|
${SELF_TEST_DIR}/UsageTests/Misc.tests.cpp
|
2019-07-13 14:47:56 +02:00
|
|
|
${SELF_TEST_DIR}/UsageTests/ToStringByte.tests.cpp
|
2018-06-11 10:48:10 +02:00
|
|
|
${SELF_TEST_DIR}/UsageTests/ToStringChrono.tests.cpp
|
|
|
|
${SELF_TEST_DIR}/UsageTests/ToStringGeneral.tests.cpp
|
2019-01-25 22:05:40 +01:00
|
|
|
${SELF_TEST_DIR}/UsageTests/ToStringOptional.tests.cpp
|
2018-06-11 10:48:10 +02:00
|
|
|
${SELF_TEST_DIR}/UsageTests/ToStringPair.tests.cpp
|
|
|
|
${SELF_TEST_DIR}/UsageTests/ToStringTuple.tests.cpp
|
2018-09-20 14:13:35 +02:00
|
|
|
${SELF_TEST_DIR}/UsageTests/ToStringVariant.tests.cpp
|
2018-06-11 10:48:10 +02:00
|
|
|
${SELF_TEST_DIR}/UsageTests/ToStringVector.tests.cpp
|
|
|
|
${SELF_TEST_DIR}/UsageTests/ToStringWhich.tests.cpp
|
|
|
|
${SELF_TEST_DIR}/UsageTests/Tricky.tests.cpp
|
|
|
|
${SELF_TEST_DIR}/UsageTests/VariadicMacros.tests.cpp
|
2020-03-02 14:25:43 +01:00
|
|
|
${SELF_TEST_DIR}/UsageTests/MatchersRanges.tests.cpp
|
2018-06-11 10:48:10 +02:00
|
|
|
${SELF_TEST_DIR}/UsageTests/Matchers.tests.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# Specify the headers, too, so CLion recognises them as project files
|
|
|
|
set(HEADERS
|
|
|
|
${TOP_LEVEL_HEADERS}
|
|
|
|
${EXTERNAL_HEADERS}
|
|
|
|
${INTERNAL_HEADERS}
|
|
|
|
${REPORTER_HEADERS}
|
2019-12-18 17:28:19 +01:00
|
|
|
${BENCHMARK_HEADERS}
|
2019-06-15 11:14:24 +02:00
|
|
|
${BENCHMARK_SOURCES}
|
|
|
|
)
|
2018-06-11 10:48:10 +02:00
|
|
|
|
|
|
|
# Provide some groupings for IDEs
|
2019-11-30 20:45:34 +01:00
|
|
|
#SOURCE_GROUP("benchmark" FILES ${BENCHMARK_HEADERS} ${BENCHMARK_SOURCES})
|
|
|
|
#SOURCE_GROUP("Tests" FILES ${TEST_SOURCES})
|
2018-06-11 10:48:10 +02:00
|
|
|
|
|
|
|
include(CTest)
|
|
|
|
|
2019-11-30 17:41:41 +01:00
|
|
|
add_executable(SelfTest ${TEST_SOURCES})
|
2020-05-07 16:24:05 +02:00
|
|
|
target_link_libraries(SelfTest PRIVATE Catch2WithMain)
|
2018-06-11 10:48:10 +02:00
|
|
|
|
|
|
|
if (CATCH_ENABLE_COVERAGE)
|
|
|
|
set(ENABLE_COVERAGE ON CACHE BOOL "Enable coverage build." FORCE)
|
|
|
|
find_package(codecov)
|
|
|
|
add_coverage(SelfTest)
|
|
|
|
list(APPEND LCOV_REMOVE_PATTERNS "'/usr/*'")
|
|
|
|
coverage_evaluate()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# configure unit tests via CTest
|
2020-05-03 09:49:59 +02:00
|
|
|
add_test(NAME RunTests COMMAND $<TARGET_FILE:SelfTest> --order rand --rng-seed time)
|
2019-04-16 23:49:22 +02:00
|
|
|
set_tests_properties(RunTests PROPERTIES
|
|
|
|
FAIL_REGULAR_EXPRESSION "Filters:"
|
2020-02-18 13:48:34 +01:00
|
|
|
COST 60
|
2019-04-16 23:49:22 +02:00
|
|
|
)
|
2018-06-11 10:48:10 +02:00
|
|
|
|
2019-06-16 16:12:47 +02:00
|
|
|
# Because CTest does not allow us to check both return code _and_ expected
|
|
|
|
# output in one test, we run these commands twice. First time we check
|
|
|
|
# the output, the second time we check the exit code.
|
|
|
|
add_test(NAME List::Tests::Output COMMAND $<TARGET_FILE:SelfTest> --list-tests --verbosity high)
|
|
|
|
set_tests_properties(List::Tests::Output PROPERTIES
|
2018-06-11 10:48:10 +02:00
|
|
|
PASS_REGULAR_EXPRESSION "[0-9]+ test cases"
|
|
|
|
FAIL_REGULAR_EXPRESSION "Hidden Test"
|
|
|
|
)
|
2019-06-16 16:12:47 +02:00
|
|
|
add_test(NAME List::Tests::ExitCode COMMAND $<TARGET_FILE:SelfTest> --list-tests --verbosity high)
|
2019-06-22 15:31:11 +02:00
|
|
|
add_test(NAME List::Tests::XmlOutput COMMAND $<TARGET_FILE:SelfTest> --list-tests --verbosity high -r xml)
|
|
|
|
set_tests_properties(List::Tests::XmlOutput PROPERTIES
|
|
|
|
PASS_REGULAR_EXPRESSION "<Line>[0-9]+</Line>"
|
|
|
|
FAIL_REGULAR_EXPRESSION "[0-9]+ test cases"
|
|
|
|
)
|
2018-06-11 10:48:10 +02:00
|
|
|
|
2019-06-16 16:12:47 +02:00
|
|
|
add_test(NAME List::Tags::Output COMMAND $<TARGET_FILE:SelfTest> --list-tags)
|
|
|
|
set_tests_properties(List::Tags::Output PROPERTIES
|
|
|
|
PASS_REGULAR_EXPRESSION "[0-9]+ tags"
|
2018-09-08 20:56:31 +02:00
|
|
|
FAIL_REGULAR_EXPRESSION "\\[\\.\\]")
|
2019-06-16 16:12:47 +02:00
|
|
|
add_test(NAME List::Tags::ExitCode COMMAND $<TARGET_FILE:SelfTest> --list-tags)
|
2019-06-22 15:31:11 +02:00
|
|
|
add_test(NAME List::Tags::XmlOutput COMMAND $<TARGET_FILE:SelfTest> --list-tags -r xml)
|
|
|
|
set_tests_properties(List::Tags::XmlOutput PROPERTIES
|
|
|
|
PASS_REGULAR_EXPRESSION "<Count>18</Count>"
|
|
|
|
FAIL_REGULAR_EXPRESSION "[0-9]+ tags"
|
|
|
|
)
|
|
|
|
|
2018-06-11 10:48:10 +02:00
|
|
|
|
2019-06-16 16:12:47 +02:00
|
|
|
add_test(NAME List::Reporters::Output COMMAND $<TARGET_FILE:SelfTest> --list-reporters)
|
|
|
|
set_tests_properties(List::Reporters::Output PROPERTIES PASS_REGULAR_EXPRESSION "Available reporters:")
|
|
|
|
add_test(NAME List::Reporters::ExitCode COMMAND $<TARGET_FILE:SelfTest> --list-reporters)
|
2019-06-22 15:31:11 +02:00
|
|
|
add_test(NAME List::Reporters::XmlOutput COMMAND $<TARGET_FILE:SelfTest> --list-reporters -r xml)
|
|
|
|
set_tests_properties(List::Reporters::XmlOutput PROPERTIES
|
|
|
|
PASS_REGULAR_EXPRESSION "<Name>compact</Name>"
|
|
|
|
FAIL_REGULAR_EXPRESSION "Available reporters:"
|
|
|
|
)
|
2018-06-11 10:48:10 +02:00
|
|
|
|
2019-06-16 16:12:47 +02:00
|
|
|
|
2018-06-11 10:48:10 +02:00
|
|
|
|
2020-02-03 21:24:53 +01:00
|
|
|
add_test(NAME NoAssertions COMMAND $<TARGET_FILE:SelfTest> -w NoAssertions "An empty test with no assertions")
|
2018-06-11 10:48:10 +02:00
|
|
|
set_tests_properties(NoAssertions PROPERTIES PASS_REGULAR_EXPRESSION "No assertions in test case")
|
|
|
|
|
2019-08-06 20:51:19 +02:00
|
|
|
add_test(NAME NoTest COMMAND $<TARGET_FILE:SelfTest> Tracker, "___nonexistent_test___")
|
|
|
|
set_tests_properties(NoTest PROPERTIES
|
|
|
|
PASS_REGULAR_EXPRESSION "No test cases matched '___nonexistent_test___'"
|
|
|
|
FAIL_REGULAR_EXPRESSION "No tests ran"
|
|
|
|
)
|
|
|
|
|
2019-12-05 16:00:20 +01:00
|
|
|
add_test(NAME WarnAboutNoTests COMMAND ${CMAKE_COMMAND} -P ${SELF_TEST_DIR}/WarnAboutNoTests.cmake $<TARGET_FILE:SelfTest>)
|
2019-08-06 20:51:19 +02:00
|
|
|
|
|
|
|
add_test(NAME UnmatchedOutputFilter COMMAND $<TARGET_FILE:SelfTest> [this-tag-does-not-exist] -w NoTests)
|
|
|
|
set_tests_properties(UnmatchedOutputFilter
|
|
|
|
PROPERTIES
|
|
|
|
PASS_REGULAR_EXPRESSION "No test cases matched '\\[this-tag-does-not-exist\\]'"
|
|
|
|
)
|
2018-06-11 10:48:10 +02:00
|
|
|
|
2019-01-15 23:13:16 +01:00
|
|
|
add_test(NAME FilteredSection-1 COMMAND $<TARGET_FILE:SelfTest> \#1394 -c RunSection)
|
|
|
|
set_tests_properties(FilteredSection-1 PROPERTIES FAIL_REGULAR_EXPRESSION "No tests ran")
|
|
|
|
add_test(NAME FilteredSection-2 COMMAND $<TARGET_FILE:SelfTest> \#1394\ nested -c NestedRunSection -c s1)
|
|
|
|
set_tests_properties(FilteredSection-2 PROPERTIES FAIL_REGULAR_EXPRESSION "No tests ran")
|
|
|
|
|
2018-06-11 10:48:10 +02:00
|
|
|
# AppVeyor has a Python 2.7 in path, but doesn't have .py files as autorunnable
|
2019-12-06 11:53:31 +01:00
|
|
|
add_test(NAME ApprovalTests COMMAND ${PYTHON_EXECUTABLE} ${CATCH_DIR}/tools/scripts/approvalTests.py $<TARGET_FILE:SelfTest>)
|
2020-02-03 09:07:23 +01:00
|
|
|
set_tests_properties(ApprovalTests
|
|
|
|
PROPERTIES
|
|
|
|
FAIL_REGULAR_EXPRESSION "Results differed"
|
|
|
|
COST 120 # We know that this is either the most, or second most,
|
|
|
|
# expensive test in the test suite, so we give it high estimate for CI runs
|
|
|
|
)
|
2018-06-11 10:48:10 +02:00
|
|
|
|
2019-06-30 00:00:41 +02:00
|
|
|
add_test(NAME RegressionCheck-1670 COMMAND $<TARGET_FILE:SelfTest> "#1670 regression check" -c A -r compact)
|
|
|
|
set_tests_properties(RegressionCheck-1670 PROPERTIES PASS_REGULAR_EXPRESSION "Passed 1 test case with 2 assertions.")
|
2019-01-15 23:13:16 +01:00
|
|
|
|
2019-08-03 20:16:46 +02:00
|
|
|
add_test(NAME VersionCheck COMMAND $<TARGET_FILE:SelfTest> -h)
|
|
|
|
set_tests_properties(VersionCheck PROPERTIES PASS_REGULAR_EXPRESSION "Catch v${PROJECT_VERSION}")
|
|
|
|
|
2019-09-07 20:36:12 +02:00
|
|
|
add_test(NAME LibIdentityTest COMMAND $<TARGET_FILE:SelfTest> --libidentify)
|
|
|
|
set_tests_properties(LibIdentityTest PROPERTIES PASS_REGULAR_EXPRESSION "description: A Catch2 test executable")
|
|
|
|
|
2019-09-07 20:43:14 +02:00
|
|
|
add_test(NAME FilenameAsTagsTest COMMAND $<TARGET_FILE:SelfTest> -\# --list-tags)
|
|
|
|
set_tests_properties(FilenameAsTagsTest PROPERTIES PASS_REGULAR_EXPRESSION "\\[#Approx.tests\\]")
|
|
|
|
|
2019-09-21 00:11:45 +02:00
|
|
|
add_test(NAME EscapeSpecialCharactersInTestNames COMMAND $<TARGET_FILE:SelfTest> "Test with special\\, characters \"in name")
|
|
|
|
set_tests_properties(EscapeSpecialCharactersInTestNames PROPERTIES PASS_REGULAR_EXPRESSION "1 assertion in 1 test case")
|
|
|
|
|
2019-06-22 20:26:03 +02:00
|
|
|
add_test(NAME NegativeSpecNoHiddenTests COMMAND $<TARGET_FILE:SelfTest> --list-tests ~[approval])
|
|
|
|
set_tests_properties(NegativeSpecNoHiddenTests PROPERTIES FAIL_REGULAR_EXPRESSION "\\[\\.\\]")
|
|
|
|
|
2019-12-05 16:00:20 +01:00
|
|
|
add_test(NAME TestsInFile::SimpleSpecs COMMAND $<TARGET_FILE:SelfTest> "-f ${SELF_TEST_DIR}/Misc/plain-old-tests.input")
|
2019-10-20 15:14:50 +02:00
|
|
|
set_tests_properties(TestsInFile::SimpleSpecs PROPERTIES PASS_REGULAR_EXPRESSION "6 assertions in 2 test cases")
|
2019-10-09 12:48:55 +02:00
|
|
|
|
2019-12-05 16:00:20 +01:00
|
|
|
add_test(NAME TestsInFile::EscapeSpecialCharacters COMMAND $<TARGET_FILE:SelfTest> "-f ${SELF_TEST_DIR}/Misc/special-characters-in-file.input")
|
2019-10-20 15:14:50 +02:00
|
|
|
set_tests_properties(TestsInFile::EscapeSpecialCharacters PROPERTIES PASS_REGULAR_EXPRESSION "1 assertion in 1 test case")
|
|
|
|
|
|
|
|
# CTest does not allow us to create an AND of required regular expressions,
|
|
|
|
# so we have to split the test into 2 parts and look for parts of the expected
|
|
|
|
# output separately.
|
2019-12-05 16:00:20 +01:00
|
|
|
add_test(NAME TestsInFile::InvalidTestNames-1 COMMAND $<TARGET_FILE:SelfTest> "-f ${SELF_TEST_DIR}/Misc/invalid-test-names.input")
|
2019-10-20 15:14:50 +02:00
|
|
|
set_tests_properties(TestsInFile::InvalidTestNames-1 PROPERTIES PASS_REGULAR_EXPRESSION "Invalid Filter: \"Test with special, characters in \\\\\" name\"")
|
|
|
|
|
2019-12-05 16:00:20 +01:00
|
|
|
add_test(NAME TestsInFile::InvalidTestNames-2 COMMAND $<TARGET_FILE:SelfTest> "-f ${SELF_TEST_DIR}/Misc/invalid-test-names.input")
|
2019-10-20 15:14:50 +02:00
|
|
|
set_tests_properties(TestsInFile::InvalidTestNames-2 PROPERTIES PASS_REGULAR_EXPRESSION "No tests ran")
|
2019-10-09 12:48:55 +02:00
|
|
|
|
2019-12-18 17:30:41 +01:00
|
|
|
add_test(NAME TagAlias COMMAND $<TARGET_FILE:SelfTest> [@tricky] --list-tests)
|
|
|
|
set_tests_properties(TagAlias PROPERTIES
|
|
|
|
PASS_REGULAR_EXPRESSION "[0-9]+ matching test cases"
|
|
|
|
FAIL_REGULAR_EXPRESSION "0 matching test cases"
|
|
|
|
)
|
2019-08-03 20:16:46 +02:00
|
|
|
|
2020-04-10 23:25:13 +02:00
|
|
|
add_test(NAME RandomTestOrdering COMMAND ${PYTHON_EXECUTABLE}
|
|
|
|
${CATCH_DIR}/tests/TestScripts/testRandomOrder.py $<TARGET_FILE:SelfTest>)
|
|
|
|
|
2020-05-06 14:57:55 +02:00
|
|
|
add_test(NAME CheckConvenienceHeaders
|
|
|
|
COMMAND
|
|
|
|
${PYTHON_EXECUTABLE} ${CATCH_DIR}/tools/scripts/checkConvenienceHeaders.py
|
|
|
|
)
|
|
|
|
|
2018-06-11 10:48:10 +02:00
|
|
|
if (CATCH_USE_VALGRIND)
|
|
|
|
add_test(NAME ValgrindRunTests COMMAND valgrind --leak-check=full --error-exitcode=1 $<TARGET_FILE:SelfTest>)
|
|
|
|
add_test(NAME ValgrindListTests COMMAND valgrind --leak-check=full --error-exitcode=1 $<TARGET_FILE:SelfTest> --list-tests --verbosity high)
|
|
|
|
set_tests_properties(ValgrindListTests PROPERTIES PASS_REGULAR_EXPRESSION "definitely lost: 0 bytes in 0 blocks")
|
|
|
|
add_test(NAME ValgrindListTags COMMAND valgrind --leak-check=full --error-exitcode=1 $<TARGET_FILE:SelfTest> --list-tags)
|
|
|
|
set_tests_properties(ValgrindListTags PROPERTIES PASS_REGULAR_EXPRESSION "definitely lost: 0 bytes in 0 blocks")
|
|
|
|
endif()
|
2020-02-21 21:15:45 +01:00
|
|
|
|
|
|
|
list(APPEND CATCH_WARNING_TARGETS SelfTest)
|
|
|
|
set(CATCH_WARNING_TARGETS ${CATCH_WARNING_TARGETS} PARENT_SCOPE)
|