Catch and register startup exceptions in autoregistrars

Previously they were registered where they would be thrown otherwise
This commit is contained in:
Martin Hořeňovský 2017-06-04 22:37:59 +02:00
parent da0edcbe25
commit 860de28b8d
3 changed files with 28 additions and 41 deletions

View file

@ -154,14 +154,18 @@ namespace Catch {
char const* classOrQualifiedMethodName,
NameAndDesc const& nameAndDesc,
SourceLineInfo const& lineInfo ) {
getMutableRegistryHub().registerTest
( makeTestCase
( testCase,
extractClassName( classOrQualifiedMethodName ),
nameAndDesc.name,
nameAndDesc.description,
lineInfo ) );
try {
getMutableRegistryHub().registerTest
(makeTestCase
(testCase,
extractClassName(classOrQualifiedMethodName),
nameAndDesc.name,
nameAndDesc.description,
lineInfo));
} catch (...) {
// Do not throw when constructing global objects, instead register the exception to be processed later
getMutableRegistryHub().registerStartupException( std::current_exception() );
}
}
void registerTestCaseFunction
( TestFunction function,