mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-02 13:25:41 +02:00
Only track the last line info in RunContext
There were only two places where we used the full `AssertionInfo` instance in `m_lastAssertionInfo`: 1) when reporting unexpected exception from running a test case 2) when reporting fatal error because in those two places we do not have access to a real instance of `AssertionInfo`, but we still need to send one to the reporters. As a bonus, in both of these places we were already constructing a fake-ish assertion info, by using the last encountered source location, but dummying out the other information. Instead, we only keep track of the last encountered source location, and construct the dummy `AssertionInfo` on-demand. This finishes the set of refactoring around `m_lastAssertionInfo` in `RunContext` and improves the performance of running assertions by ~5% in both Debug and Release mode. -------------- Note that this change also causes small difference in output. It could be avoided by having an invalidation flag and tracking where the information would be invalidated before, but the difference includes more precise line location for unexpected errors (both exceptions and fatals), so I prefer the new output.
This commit is contained in:
@@ -53,8 +53,9 @@ Nor would this
|
||||
<testcase classname="<exe-name>.global" name="#2152 - ULP checks between differently signed values were wrong - float" time="{duration}" status="run"/>
|
||||
<testcase classname="<exe-name>.global" name="#2615 - Throwing in constructor generator fails test case but does not abort" time="{duration}" status="run">
|
||||
<skipped message="TEST_CASE tagged with !mayfail"/>
|
||||
<error type="TEST_CASE">
|
||||
<error message="{Unknown expression after the reported line}">
|
||||
FAILED:
|
||||
{Unknown expression after the reported line}
|
||||
failure to init
|
||||
at Generators.tests.cpp:<line number>
|
||||
</error>
|
||||
@@ -62,8 +63,9 @@ at Generators.tests.cpp:<line number>
|
||||
<testcase classname="<exe-name>.global" name="#748 - captures with unexpected exceptions" time="{duration}" status="run"/>
|
||||
<testcase classname="<exe-name>.global" name="#748 - captures with unexpected exceptions/outside assertions" time="{duration}" status="run">
|
||||
<skipped message="TEST_CASE tagged with !mayfail"/>
|
||||
<error type="TEST_CASE">
|
||||
<error message="{Unknown expression after the reported line}">
|
||||
FAILED:
|
||||
{Unknown expression after the reported line}
|
||||
expected exception
|
||||
answer := 42
|
||||
at Exception.tests.cpp:<line number>
|
||||
@@ -1837,8 +1839,9 @@ at Exception.tests.cpp:<line number>
|
||||
</error>
|
||||
</testcase>
|
||||
<testcase classname="<exe-name>.global" name="When unchecked exceptions are thrown from sections they are always failures/section name" time="{duration}" status="run">
|
||||
<error type="TEST_CASE">
|
||||
<error message="{Unknown expression after the reported line}">
|
||||
FAILED:
|
||||
{Unknown expression after the reported line}
|
||||
unexpected exception
|
||||
at Exception.tests.cpp:<line number>
|
||||
</error>
|
||||
|
Reference in New Issue
Block a user