mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 21:05:39 +02:00
Improve reporting of unmatched filters (#1684)
This PR ultimately does 3 things * Separately tracks matched tests per each filter part (that is, a set of filters separated by an OR (`,`)), which allows Catch2 to report each of the alternative filters that don't match any tests. * Fixes `-w NoTests` to return non-zero in the process * Adds tests for `-w NoTests`.
This commit is contained in:

committed by
Martin Hořeňovský

parent
cf55cfd76f
commit
6070745cab
@@ -393,8 +393,19 @@ set_tests_properties(ListTestNamesOnly PROPERTIES
|
||||
add_test(NAME NoAssertions COMMAND $<TARGET_FILE:SelfTest> -w NoAssertions)
|
||||
set_tests_properties(NoAssertions PROPERTIES PASS_REGULAR_EXPRESSION "No assertions in test case")
|
||||
|
||||
add_test(NAME NoTest COMMAND $<TARGET_FILE:SelfTest> -w NoTests "___nonexistent_test___")
|
||||
set_tests_properties(NoTest PROPERTIES PASS_REGULAR_EXPRESSION "No test cases matched")
|
||||
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"
|
||||
)
|
||||
|
||||
add_test(NAME WarnAboutNoTests COMMAND ${CMAKE_COMMAND} -P ${CATCH_DIR}/projects/SelfTest/WarnAboutNoTests.cmake $<TARGET_FILE:SelfTest>)
|
||||
|
||||
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\\]'"
|
||||
)
|
||||
|
||||
add_test(NAME FilteredSection-1 COMMAND $<TARGET_FILE:SelfTest> \#1394 -c RunSection)
|
||||
set_tests_properties(FilteredSection-1 PROPERTIES FAIL_REGULAR_EXPRESSION "No tests ran")
|
||||
|
19
projects/SelfTest/WarnAboutNoTests.cmake
Normal file
19
projects/SelfTest/WarnAboutNoTests.cmake
Normal file
@@ -0,0 +1,19 @@
|
||||
# Workaround for a peculiarity where CTest disregards the return code from a
|
||||
# test command if a PASS_REGULAR_EXPRESSION is also set
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_ARGV3} -w NoTests "___nonexistent_test___"
|
||||
RESULT_VARIABLE ret
|
||||
OUTPUT_VARIABLE out
|
||||
)
|
||||
|
||||
message("${out}")
|
||||
|
||||
if(NOT ${ret} MATCHES "^[0-9]+$")
|
||||
message(FATAL_ERROR "${ret}")
|
||||
endif()
|
||||
|
||||
if(${ret} EQUAL 0)
|
||||
message(FATAL_ERROR "Expected nonzero return code")
|
||||
elseif(${out} MATCHES "Helper failed with")
|
||||
message(FATAL_ERROR "Helper failed")
|
||||
endif()
|
Reference in New Issue
Block a user