22namespace TestSupport {
37 static void handler(
int level,
bool abort,
42 std::cerr <<
"ROOT::TestSupport::ForbidDiagnostics::handler(): Diagnostic in '" << location <<
"':\n"
48 std::cerr <<
"ROOT::TestSupport::ForbidDiagnostics::handler(): Forced to abort because of diagnostic with severity "
49 << level <<
" in '" << location <<
"' reading '" << msg <<
"'\n";
54 if (level ==
kError && strcmp(location,
"TCling::LoadPCM") == 0 && strstr(msg,
"file does not exist") !=
nullptr) {
55 std::cerr <<
"Error in " << location <<
" " << msg << std::endl;
61 && strstr(msg,
"The RNTuple file format will change. Do not store real data with this version of RNTuple!") !=
nullptr) {
62 std::cerr <<
"Warning in " << location <<
" " << msg << std::endl;
66 && strstr(msg,
"Pre-release format version: RC ") !=
nullptr) {
67 std::cerr <<
"Warning in " << location <<
" " << msg << std::endl;
70 if (level ==
kWarning && strstr(msg,
"Merging RNTuples is experimental") !=
nullptr) {
71 std::cerr <<
"Warning in " << location <<
" " << msg << std::endl;
77 && strstr(msg,
"The DAOS backend is experimental and still under development") !=
nullptr) {
78 std::cerr <<
"Warning in " << location <<
" " << msg << std::endl;
84 && strcmp(msg,
"Fast recovery from undefined function values only implemented for little-endian machines. If necessary, request an extension of functionality on https://root.cern") == 0) {
85 std::cerr <<
"Warning in " << location <<
" " << msg << std::endl;
89 FAIL() <<
"Received unexpected diagnostic of severity "
91 <<
" at '" << location <<
"' reading '" << msg <<
"'.\n"
92 <<
"Suppress those using ROOT/TestSupport.hxx";
107 if (!diag.optional && diag.receivedCount < 1) {
108 ADD_FAILURE() <<
"ROOT::TestSupport::CheckDiagsRAII: Expected diagnostic message missing:\n" << diag;
113 ADD_FAILURE() <<
"ROOT::TestSupport::CheckDiagsRAII: Unexpected diagnostic message:\n" << diag;
121 const std::string message = msg;
122 const auto expectedMatch =
124 return expectedDiag.severity == severity
125 && strstr(location, expectedDiag.location.c_str()) != nullptr
126 && (expectedDiag.matchFullString ? expectedDiag.message == message : (message.find(expectedDiag.message) != std::string::npos));
130 expectedMatch->receivedCount += 1;
131 }
else if (severity <=
kInfo) {
140 std::map<int, std::string> dict = {
143 constexpr auto indent = 15;
144 stream << std::right << std::setw(
indent) <<
"severity: " << dict[diag.
severity];
152 << 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
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
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.