Skip to content

Conversation

@hbirler
Copy link
Contributor

@hbirler hbirler commented Apr 15, 2024

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");
   }
}

@hbirler
Copy link
Contributor Author

hbirler commented Apr 15, 2024

I am not familiar with the internals of Catch2, so there might be a nicer way of doing this. For example, I am not sure whether it is possible to properly construct SectionEndInfo endInfo with correct prevAssertions and durationInSeconds

Closes catchorg#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");
   }
}
```
@hbirler
Copy link
Contributor Author

hbirler commented Apr 15, 2024

Additionally, it might be safe to do:

auto nl = CATCH_MOVE(m_activeSections.back()->nameAndLocation());

instead of a copy, but I took the "safe" route (allocating memory might also not be the best idea within a signal handler).

@codecov
Copy link

codecov bot commented Apr 15, 2024

Codecov Report

Attention: Patch coverage is 0% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 91.04%. Comparing base (029fe3b) to head (fe428d6).
Report is 5 commits behind head on devel.

❗ Current head fe428d6 differs from pull request most recent head 0b013eb. Consider uploading reports for the commit 0b013eb to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #2855      +/-   ##
==========================================
- Coverage   91.09%   91.04%   -0.05%     
==========================================
  Files         197      198       +1     
  Lines        8382     8391       +9     
==========================================
+ Hits         7635     7639       +4     
- Misses        747      752       +5     

@hbirler
Copy link
Contributor Author

hbirler commented Apr 15, 2024

The function RunContext::handleFatalErrorCondition seems to not be covered at all by the existing tests, and I wouldn't know how to test signal handlers reliably within the existing framework.

@horenmar
Copy link
Member

Thanks, this has been around for a while.

@horenmar horenmar merged commit efb3968 into catchorg:devel Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

virtual void Catch::CumulativeReporterBase::testCaseEnded(const Catch::TestCaseStats&): Assertion `m_sectionStack.size() == 0' failed

2 participants