Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert Info reset need to also reset result disposition to normal to handle uncaught exception correctly #2723

Merged
merged 4 commits into from Aug 7, 2023

Conversation

rosstang
Copy link
Contributor

Description

why?
After CHECK_ELSE is run, uncaught exception would pass unit tests which causes huge issues.

what?
This pull request added two unit tests to demo how uncaught exception are swallowed silently, and fixes that with resetting the result disposition flag to normal. Since populateReaction uses the last assertion info, it needs to be reset after populateReaction is called.

GitHub Issues

Closes #2719

Ross added 3 commits July 22, 2023 01:03
…r populateReaction. And reset assertion info would also reset the result disposition to normal, so that any uncaught exception would be reported as failure
@codecov
Copy link

codecov bot commented Jul 22, 2023

Codecov Report

Merging #2723 (52f9ea7) into devel (4acc518) will increase coverage by 0.08%.
The diff coverage is 85.71%.

@@            Coverage Diff             @@
##            devel    #2723      +/-   ##
==========================================
+ Coverage   91.20%   91.29%   +0.08%     
==========================================
  Files         192      192              
  Lines        7843     7849       +6     
==========================================
+ Hits         7153     7165      +12     
+ Misses        690      684       -6     

Comment on lines +12 to +16
Catch::AssertionHandler catchAssertionHandler(
"REQUIRE"_catch_sr,
CATCH_INTERNAL_LINEINFO,
"Dummy",
Catch::ResultDisposition::Normal );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand what the other two tests are for, but what is this one supposed to check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function is not covered in coverage, as it is preprocessor switched off in tests. But it needs to be fixed for completeness. So adding unit tests for that to satisfy the coverage percentage requirement.

@@ -447,6 +449,7 @@ namespace Catch {
AssertionResult result(m_lastAssertionInfo, CATCH_MOVE(tempResult));

assertionEnded(CATCH_MOVE(result) );
resetAssertionInfo();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually neeeded? RunContext::assertionEnded (called on the line before this one) already calls resetAssertionInfo.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait sorry, I didn't notice that you changed assertionEnded to not reset assertion info anymore.

@horenmar
Copy link
Member

horenmar commented Aug 7, 2023

Thanks.

@horenmar horenmar merged commit cd60a03 into catchorg:devel Aug 7, 2023
74 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception is treated as passing when used CHECKED_ELSE before in xml reporter
2 participants