mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 17:48:21 +00:00
Wrap call to doctest's MESSAGE() method in Reporter in try/catch block
Also check whether doctest is even enabled before trying to use it.
This commit is contained in:
parent
6f2bedaa56
commit
84ea086167
1 changed files with 16 additions and 1 deletions
|
@ -678,13 +678,28 @@ void Reporter::DoLog(const char* prefix, EventHandlerPtr event, FILE* out, Conne
|
|||
|
||||
s += buffer;
|
||||
|
||||
#ifdef ENABLE_ZEEK_UNIT_TESTS
|
||||
if ( doctest::is_running_in_test )
|
||||
{
|
||||
try
|
||||
{
|
||||
MESSAGE(s);
|
||||
}
|
||||
catch ( const doctest::detail::TestFailureException& e )
|
||||
{
|
||||
// If doctest throws an exception, just write the string out to stdout
|
||||
// like normal, just so it's captured somewhere.
|
||||
fprintf(out, "%s\n", s.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif
|
||||
s += "\n";
|
||||
fprintf(out, "%s", s.c_str());
|
||||
#ifdef ENABLE_ZEEK_UNIT_TESTS
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if ( alloced )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue