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

Add support for catching std::terminate and signals (SIGSEGV etc) #35

Open
cschreib opened this issue Dec 8, 2022 · 2 comments
Open
Labels
enhancement New feature or request
Milestone

Comments

@cschreib
Copy link
Member

cschreib commented Dec 8, 2022

Currently, if a test calls std::terminate(), the whole test application stops. We should be able to register a handler for the abort signal (doctest does this), report the failure, and continue with the next test.

We need to be able to figure out who calls std::terminate(); if the test framework itself calls it (because of out-of-bounds access, or reaching a hard-coded limit), we should propagate the error and stop. Ideally we would implement this so that we can test for our own termination; perhaps the test runner function could register the abort handler just before starting the test?

At any rate, this would allow us to support REQUIRE_* and FAIL when exceptions are not used, if we make them use std::terminate() instead of return.

@cschreib cschreib added the enhancement New feature or request label Dec 8, 2022
@cschreib cschreib added this to the v1.0 milestone Dec 8, 2022
@cschreib cschreib changed the title Add support for catching std::terminate Add support for catching std::terminate and signals (SIGSEGV etc) Dec 11, 2022
@cschreib
Copy link
Member Author

Apparently, "catch and continue" is impossible within the same process. We would need to run each test into a sub-process, which is what Google Test does to support "death tests". At the time of writing this, neither Catch2 nor doctest support this, while Boost UT has an implementation for Unix only (no Windows).

@cschreib cschreib modified the milestones: v1.0, v1.x Dec 11, 2022
@cschreib
Copy link
Member Author

cschreib commented Dec 11, 2022

#38 will nonetheless switch REQUIRE() to call std::terminate() when exceptions are disabled, because return is not reliable enough (when called in functions and not in test cases). Adding support for "catch and continue", or improving reporting on caught signals, will be postponed to a future version (but possibly may never happen...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant