mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-22 11:23:29 +01:00
Handle active Sections for fatal errors
Closes #1210 When a signal is caught, the destructors of Sections will not be called. Thus, we must call `sectionEndedEarly` manually for those Sections. Example test case: ``` TEST_CASE("broken") { SECTION("section") { /// Use illegal cpu instruction __asm__ __volatile__("ud2" : : : "memory"); } } ```
This commit is contained in:
parent
2bce3e276b
commit
42fe78d0ba
@ -450,6 +450,13 @@ namespace Catch {
|
||||
assertionEnded(CATCH_MOVE(result) );
|
||||
resetAssertionInfo();
|
||||
|
||||
// Best effort cleanup for sections that have not been destructed yet
|
||||
// Since this is a fatal error, we have not had and won't have the opportunity to destruct them properly
|
||||
while (!m_activeSections.empty()) {
|
||||
auto nl = m_activeSections.back()->nameAndLocation();
|
||||
SectionEndInfo endInfo{ SectionInfo(CATCH_MOVE(nl.location), CATCH_MOVE(nl.name)), {}, 0.0 };
|
||||
sectionEndedEarly(CATCH_MOVE(endInfo));
|
||||
}
|
||||
handleUnfinishedSections();
|
||||
|
||||
// Recreate section for test case (as we will lose the one that was in scope)
|
||||
|
Loading…
Reference in New Issue
Block a user