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;
60 if (level ==
kWarning &&
strstr(
msg,
"Merging RNTuples is experimental") !=
nullptr) {
61 std::cerr <<
"Warning in " << location <<
" " <<
msg << std::endl;
67 &&
strstr(
msg,
"The DAOS backend is experimental and still under development") !=
nullptr) {
68 std::cerr <<
"Warning in " << location <<
" " <<
msg << std::endl;
74 &&
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) {
75 std::cerr <<
"Warning in " << location <<
" " <<
msg << std::endl;
79 FAIL() <<
"Received unexpected diagnostic of severity "
81 <<
" at '" << location <<
"' reading '" <<
msg <<
"'.\n"
82 <<
"Suppress those using ROOT/TestSupport.hxx";
97 if (!
diag.optional &&
diag.receivedCount < 1) {
98 ADD_FAILURE() <<
"ROOT::TestSupport::CheckDiagsRAII: Expected diagnostic message missing:\n" <<
diag;
103 ADD_FAILURE() <<
"ROOT::TestSupport::CheckDiagsRAII: Unexpected diagnostic message:\n" <<
diag;
111 const std::string message =
msg;
114 return expectedDiag.severity == severity
115 && strstr(location, expectedDiag.location.c_str()) != nullptr
116 && (expectedDiag.matchFullString ? expectedDiag.message == message : (message.find(expectedDiag.message) != std::string::npos));
121 }
else if (severity <=
kInfo) {
130 std::map<int, std::string> dict = {
133 constexpr auto indent = 15;
134 stream << std::right << std::setw(
indent) <<
"severity: " << dict[
diag.severity];
135 if (
diag.receivedCount >= 0) {
137 << std::setw(
indent) <<
"received: " <<
diag.receivedCount <<
" times ("
138 << (
diag.optional ?
"optional" :
"required") <<
", " << (
diag.matchFullString ?
"fullMatch" :
"subMatch")
142 << std::setw(
indent) <<
"origin: " <<
'"' <<
diag.location <<
"\""
144 << std::setw(
indent) <<
"message: " <<
diag.message <<
"\n";
static void indent(ostringstream &buf, int indent_level)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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.
const_iterator end() const
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
std::ostream & operator<<(std::ostream &stream, CheckDiagsRAII::Diag_t const &diag)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
@ kInfo
Informational messages; used for instance for tracing.
@ kWarning
Warnings about likely unexpected behavior.
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.