21namespace TestSupport {
36 static void handler(
int level,
bool abort,
41 std::cerr <<
"ROOT::TestSupport::ForbidDiagnostics::handler(): Diagnostic in '" << location <<
"':\n"
47 std::cerr <<
"ROOT::TestSupport::ForbidDiagnostics::handler(): Forced to abort because of diagnostic with severity "
48 << level <<
" in '" << location <<
"' reading '" << msg <<
"'\n";
53 if (level ==
kError && strcmp(location,
"TCling::LoadPCM") == 0 && strstr(msg,
"file does not exist") !=
nullptr) {
54 std::cerr <<
"Error in " << location <<
" " << msg << std::endl;
60 && strstr(msg,
"The RNTuple file format will change. Do not store real data with this version of RNTuple!") !=
nullptr) {
61 std::cerr <<
"Warning in " << location <<
" " << msg << std::endl;
65 && strstr(msg,
"Pre-release format version: RC ") !=
nullptr) {
66 std::cerr <<
"Warning in " << location <<
" " << msg << std::endl;
72 && strstr(msg,
"The DAOS backend is experimental and still under development") !=
nullptr) {
73 std::cerr <<
"Warning in " << location <<
" " << msg << std::endl;
77 FAIL() <<
"Received unexpected diagnostic of severity "
79 <<
" at '" << location <<
"' reading '" << msg <<
"'.\n"
80 <<
"Suppress those using ROOT/TestSupport.hxx";
95 if (!diag.optional && diag.receivedCount < 1) {
96 ADD_FAILURE() <<
"ROOT::TestSupport::CheckDiagsRAII: Expected diagnostic message missing:\n" << diag;
101 ADD_FAILURE() <<
"ROOT::TestSupport::CheckDiagsRAII: Unexpected diagnostic message:\n" << diag;
109 const std::string message = msg;
110 const auto expectedMatch =
112 return expectedDiag.severity == severity
113 && strstr(location, expectedDiag.location.c_str()) != nullptr
114 && (expectedDiag.matchFullString ? expectedDiag.message == message : (message.find(expectedDiag.message) != std::string::npos));
118 expectedMatch->receivedCount += 1;
119 }
else if (severity <=
kInfo) {
128 std::map<int, std::string> dict = {
131 constexpr auto indent = 15;
132 stream << std::right << std::setw(
indent) <<
"severity: " << dict[diag.
severity];
140 << std::setw(
indent) <<
"origin: " <<
'"' << diag.
location <<
"\""
TBuffer & operator<<(TBuffer &buf, const Tmpl *obj)
static void indent(ostringstream &buf, int indent_level)
ErrorHandlerFunc_t GetErrorHandler()
Returns the current error handler function.
void(* ErrorHandlerFunc_t)(int level, Bool_t abort, const char *location, const char *msg)
Int_t gErrorIgnoreLevel
Error handling routines.
constexpr Int_t kSysError
ErrorHandlerFunc_t SetErrorHandler(ErrorHandlerFunc_t newhandler)
Set an errorhandler function. Returns the old handler.
The file contains facilities allowing easier writing of in-tree unit tests.
ErrorHandlerFunc_t const fOldErrorHandler
Last active handler in case handlers are nested.
static CheckDiagsRAII * sActiveInstance
Last active error handler function.
std::vector< Diag_t > fUnexpectedDiags
std::vector< Diag_t > fExpectedDiags
void checkDiag(int severity, const char *location, const char *msg)
Check all received diags against list of expected ones.
CheckDiagsRAII *const fOldInstance
static struct ROOT::TestSupport::ForbidDiagnostics noDiagCheckerInstance
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
Error handler for gtests that generates failures for every received diagnostic > kInfo when this file...
ErrorHandlerFunc_t const sOldErrorHandler
static void handler(int level, bool abort, const char *location, const char *msg)
Diagnostic handler that's installed for all google tests.