[llvm] [orc-rt] Make noErrors report errors as test failures (PR #228807)

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 3 18:53:44 PDT 2026


https://github.com/lhames created https://github.com/llvm/llvm-project/pull/228807

noErrors used cantFail, so an unexpected error aborted the whole test binary without naming the test that hit it, and with assertions disabled was dropped silently. Use EXPECT_THAT_ERROR instead, so the error is reported as a failure of the current test and the remaining tests still run.

>From 35698ab7da2ca5d15d8eae7e23c339d2344a3fc4 Mon Sep 17 00:00:00 2001
From: Lang Hames <lhames at gmail.com>
Date: Thu, 1 Oct 2026 16:20:56 +1000
Subject: [PATCH] [orc-rt] Make noErrors report errors as test failures

noErrors used cantFail, so an unexpected error aborted the whole test
binary without naming the test that hit it, and with assertions disabled
was dropped silently. Use EXPECT_THAT_ERROR instead, so the error is
reported as a failure of the current test and the remaining tests still
run.
---
 orc-rt/test/unit/CommonTestUtils.h | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/orc-rt/test/unit/CommonTestUtils.h b/orc-rt/test/unit/CommonTestUtils.h
index f715b689da0bc..10f5534f6edb5 100644
--- a/orc-rt/test/unit/CommonTestUtils.h
+++ b/orc-rt/test/unit/CommonTestUtils.h
@@ -29,6 +29,7 @@
 #include <string>
 #include <vector>
 
+#include "ErrorMatchers.h"
 #include "gtest/gtest.h"
 
 namespace orc_rt {
@@ -37,17 +38,20 @@ class Session;
 
 namespace orc_rt::test {
 
-/// Error reporter for tests that expect no errors. Usable both as a plain
-/// error reporter and as a Session error reporter.
+/// Error reporter for tests that expect no errors: any reported error fails
+/// the current test. Usable both as a plain error reporter and as a Session
+/// error reporter.
 ///
 /// This is a function object rather than a pair of overloaded functions so
 /// that it can be passed to templated callable parameters (e.g.
 /// move_only_function's constructor): the name of an overload set can't be
 /// deduced.
 inline constexpr struct NoErrors {
-  void operator()(Error Err) const noexcept { cantFail(std::move(Err)); }
+  void operator()(Error Err) const noexcept {
+    EXPECT_THAT_ERROR(std::move(Err), Succeeded());
+  }
   void operator()(Session &, Error Err) const noexcept {
-    cantFail(std::move(Err));
+    EXPECT_THAT_ERROR(std::move(Err), Succeeded());
   }
 } noErrors;
 



More information about the llvm-commits mailing list