mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 15:19:07 +01:00
test: Allow testing of check failures
This allows specific tests to mock the check behavior to consistently use exceptions instead of aborts for intentionally failing checks in all build configurations.
This commit is contained in:
@@ -27,8 +27,13 @@ NonFatalCheckError::NonFatalCheckError(std::string_view msg, std::string_view fi
|
||||
{
|
||||
}
|
||||
|
||||
bool g_detail_test_only_CheckFailuresAreExceptionsNotAborts{false};
|
||||
|
||||
void assertion_fail(std::string_view file, int line, std::string_view func, std::string_view assertion)
|
||||
{
|
||||
if (g_detail_test_only_CheckFailuresAreExceptionsNotAborts) {
|
||||
throw NonFatalCheckError{assertion, file, line, func};
|
||||
}
|
||||
auto str = strprintf("%s:%s %s: Assertion `%s' failed.\n", file, line, func, assertion);
|
||||
fwrite(str.data(), 1, str.size(), stderr);
|
||||
std::abort();
|
||||
|
||||
Reference in New Issue
Block a user