Skip to content

Commit

Permalink
igl | Compile-out usage of report mustfix in TestErrorGuard behind 'I…
Browse files Browse the repository at this point in the history
…GL_REPORT_ERROR_ENABLED'.

Summary: If someone builds test utils with compiled out error reporting - we won't be able to build the source - make sure it's compiled out as well uniformly.

Reviewed By: mmaurer

Differential Revision: D51315379

fbshipit-source-id: bed372e773a46675e3c311bc5deeffc5e86893b6
  • Loading branch information
nlutsenko authored and facebook-github-bot committed Nov 14, 2023
1 parent 34e0a4c commit 64ae2ae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/igl/tests/util/TestErrorGuard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@
#include <string>

igl::tests::util::TestErrorGuard::TestErrorGuard() {
#if IGL_REPORT_ERROR_ENABLED
savedErrorHandler_ = IGLReportErrorGetHandler();
IGLReportErrorSetHandler(ReportErrorHandler);
#endif
}

igl::tests::util::TestErrorGuard::~TestErrorGuard() {
#if IGL_REPORT_ERROR_ENABLED
IGLReportErrorSetHandler(savedErrorHandler_);
#endif
}

void igl::tests::util::TestErrorGuard::ReportErrorHandler(const char* file,
Expand All @@ -28,6 +32,7 @@ void igl::tests::util::TestErrorGuard::ReportErrorHandler(const char* file,
const char* category,
const char* format,
...) {
#if IGL_REPORT_ERROR_ENABLED
va_list ap;
va_start(ap, format);

Expand All @@ -44,4 +49,5 @@ void igl::tests::util::TestErrorGuard::ReportErrorHandler(const char* file,

ADD_FAILURE() << "IGL error encountered in " << file << ":" << line << " category=" << category
<< " " << fmtString;
#endif
}
2 changes: 2 additions & 0 deletions src/igl/tests/util/TestErrorGuard.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ class TestErrorGuard final {
...);

private:
#if IGL_REPORT_ERROR_ENABLED
IGLReportErrorFunc savedErrorHandler_;
#endif
};
} // namespace util
} // namespace tests
Expand Down

0 comments on commit 64ae2ae

Please sign in to comment.