mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-03 05:45:39 +02:00
Regularize scoped message lifetime to only consider the object's scope
This means that: 1) Scoped messages are always removed at the end of their scope, even if the scope ended due to an exception. 2) Scoped messages outlive section end, if that section's scope is enclosed in their own. Previously neither of these were true, which has led to a number of surprising behaviour, where e.g. this: ```cpp TEST_CASE() { try { INFO( "some info" ); throw std::runtime_error( "ex" ); } catch (std::exception const&) {} REQUIRE( false ); } ``` would print "some info" as the message for the assertion, while this: ```cpp TEST_CASE() { INFO("Hello"); SECTION("dummy") {} REQUIRE(false); } ``` would not print out "Hello" as the message for the assertion. This had an underlying reason, in that it was trying to helpfully keep the messages around in case of unexpected exceptions, so that code like this: ```cpp TEST_CASE() { auto [input, expected] = GENERATE(...); CAPTURE(input); auto result = transform(input); // throws REQUIRE(result == expected); } ``` would report the value of `input` when `transform` throws. However, it was surprising in practice and was causing various issues around handling of messages in other cases. Closes #1759 Closes #2019 Closes #2959
This commit is contained in:
@@ -100,6 +100,8 @@
|
||||
:test-result: PASS CAPTURE can deal with complex expressions involving commas
|
||||
:test-result: PASS CAPTURE parses string and character constants
|
||||
:test-result: PASS Capture and info messages
|
||||
:test-result: FAIL Captures do not leave block with an exception
|
||||
:test-result: FAIL Captures outlive section end
|
||||
:test-result: PASS CaseInsensitiveEqualsTo is case insensitive
|
||||
:test-result: PASS CaseInsensitiveLess is case insensitive
|
||||
:test-result: PASS Character pretty printing
|
||||
@@ -224,6 +226,9 @@
|
||||
:test-result: PASS Scenario: Do that thing with the thing
|
||||
:test-result: PASS Scenario: This is a really long scenario name to see how the list command deals with wrapping
|
||||
:test-result: PASS Scenario: Vector resizing affects size and capacity
|
||||
:test-result: FAIL Scoped message applies to all assertions in scope
|
||||
:test-result: FAIL Scoped messages do not leave block with an exception
|
||||
:test-result: FAIL Scoped messages outlive section end
|
||||
:test-result: FAIL Sends stuff to stdout and stderr
|
||||
:test-result: PASS Some simple comparisons between doubles
|
||||
:test-result: FAIL Standard output from all sections is reported
|
||||
|
Reference in New Issue
Block a user