Fix bad error reporting for nested exceptions in default configuration

Bad handling of `TestFailureException` when translating unexpected
exceptions inside assertion macros led to the unexpected exceptions
handling erroring out through throwing the same exception again.

This was then backstopped by the machinery for handling uncaught
exceptions from assertions, which is normally used by the
`CATCH_CONFIG_FAST_COMPILE` machinery, where we assume that it can
only be invoked because the assertion macros are not configured to
catch assertions.

Closes #1292
This commit is contained in:
Martin Hořeňovský
2025-07-27 20:28:51 +02:00
parent fee81626d2
commit d547cae549
21 changed files with 595 additions and 23 deletions

View File

@@ -2566,6 +2566,41 @@ Compilation.tests.cpp:<line number>: PASSED:
with expansion:
!(Val: 1 ^ Val: 1)
-------------------------------------------------------------------------------
Assertions can be nested - CHECK
-------------------------------------------------------------------------------
AssertionHandler.tests.cpp:<line number>
...............................................................................
AssertionHandler.tests.cpp:<line number>: FAILED:
REQUIRE( i > 10 )
with expansion:
2 > 10
AssertionHandler.tests.cpp:<line number>: FAILED:
CHECK( foo( 2 ) == 2 )
due to unexpected exception with message:
{ nested assertion failed }
AssertionHandler.tests.cpp:<line number>: PASSED:
CHECK( true )
-------------------------------------------------------------------------------
Assertions can be nested - REQUIRE
-------------------------------------------------------------------------------
AssertionHandler.tests.cpp:<line number>
...............................................................................
AssertionHandler.tests.cpp:<line number>: FAILED:
REQUIRE( i > 10 )
with expansion:
2 > 10
AssertionHandler.tests.cpp:<line number>: FAILED:
REQUIRE( foo( 2 ) == 2 )
due to unexpected exception with message:
{ nested assertion failed }
-------------------------------------------------------------------------------
Assertions then sections
-------------------------------------------------------------------------------
@@ -4561,6 +4596,21 @@ Message.tests.cpp:<line number>: FAILED:
explicitly with message:
This is a failure
-------------------------------------------------------------------------------
FAIL can be nested in assertion
-------------------------------------------------------------------------------
AssertionHandler.tests.cpp:<line number>
...............................................................................
AssertionHandler.tests.cpp:<line number>: FAILED:
explicitly with message:
Throw a Catch::TestFailureException
AssertionHandler.tests.cpp:<line number>: FAILED:
CHECK_NOTHROW( do_fail() )
due to unexpected exception with message:
{ nested assertion failed }
-------------------------------------------------------------------------------
FAIL does not require an argument
-------------------------------------------------------------------------------
@@ -19134,6 +19184,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED:
===============================================================================
test cases: 428 | 313 passed | 95 failed | 6 skipped | 14 failed as expected
assertions: 2281 | 2089 passed | 157 failed | 35 failed as expected
test cases: 431 | 313 passed | 95 failed | 6 skipped | 17 failed as expected
assertions: 2288 | 2090 passed | 157 failed | 41 failed as expected