mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 01:58:20 +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;
|
s += buffer;
|
||||||
|
|
||||||
|
#ifdef ENABLE_ZEEK_UNIT_TESTS
|
||||||
if ( doctest::is_running_in_test )
|
if ( doctest::is_running_in_test )
|
||||||
MESSAGE(s);
|
{
|
||||||
|
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
|
else
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
s += "\n";
|
s += "\n";
|
||||||
fprintf(out, "%s", s.c_str());
|
fprintf(out, "%s", s.c_str());
|
||||||
|
#ifdef ENABLE_ZEEK_UNIT_TESTS
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( alloced )
|
if ( alloced )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue