[llvm] [orc-rt] Use the Error matchers in SimpleRemoteCATest (PR #228672)
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 3 00:20:01 PDT 2026
https://github.com/lhames created https://github.com/llvm/llvm-project/pull/228672
Use the Error matchers introduced in 4c8a437d0487 to clean up error checks in SimpleRemoteCATest.
>From 7b901687655959621f4ecea0567875173fb53022 Mon Sep 17 00:00:00 2001
From: Lang Hames <lhames at gmail.com>
Date: Thu, 1 Oct 2026 09:28:42 +1000
Subject: [PATCH] [orc-rt] Use the Error matchers in SimpleRemoteCATest
Use the Error matchers introduced in 4c8a437d0487 to clean up error
checks in SimpleRemoteCATest.
---
.../unit/bedrock/sps/SimpleRemoteCATest.cpp | 32 +++++++++----------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/orc-rt/test/unit/bedrock/sps/SimpleRemoteCATest.cpp b/orc-rt/test/unit/bedrock/sps/SimpleRemoteCATest.cpp
index 4f4d6c253d72bf..f160a4280f217e 100644
--- a/orc-rt/test/unit/bedrock/sps/SimpleRemoteCATest.cpp
+++ b/orc-rt/test/unit/bedrock/sps/SimpleRemoteCATest.cpp
@@ -20,6 +20,7 @@
#include "BedrockTestUtils.h"
#include "CommonTestUtils.h"
+#include "ErrorMatchers.h"
#include "orc-rt/support/sps/SimplePackedSerialization.h"
@@ -108,7 +109,7 @@ TEST(SimpleRemoteCATest, SetupMessageRoundTrips) {
SimpleSymbolTable Symbols;
std::vector<std::pair<SymbolNameSpec, const void *>> SymbolDefs = {
{SymbolNameSpec::linker("foo"), &SomeSymbol}};
- cantFail(Symbols.addUnique(SymbolDefs));
+ ASSERT_THAT_ERROR(Symbols.addUnique(SymbolDefs), Succeeded());
BootstrapInfo BI(S, std::move(Symbols),
BootstrapInfo::ValueMap{{"key", "value"}});
@@ -170,25 +171,25 @@ TEST(SimpleRemoteCATest, MessageHeaderRoundTripsWithNoPayload) {
TEST(SimpleRemoteCATest, OrderlyHangupRoundTrips) {
// Both ends encode and decode hang-ups through these, so a success value must
// survive the trip as a success.
- auto Err = TestCA::decodeHangup(TestCA::encodeHangup(Error::success()));
- EXPECT_FALSE(!!Err) << "an orderly hang-up is not an error";
+ EXPECT_THAT_ERROR(
+ TestCA::decodeHangup(TestCA::encodeHangup(Error::success())), Succeeded())
+ << "an orderly hang-up is not an error";
}
TEST(SimpleRemoteCATest, HangupReasonRoundTrips) {
- auto Err = TestCA::decodeHangup(
- TestCA::encodeHangup(make_error<StringError>("controller ran out of x")));
- ASSERT_TRUE(!!Err);
- EXPECT_EQ(toString(std::move(Err)), "controller ran out of x");
+ EXPECT_THAT_ERROR(TestCA::decodeHangup(TestCA::encodeHangup(
+ make_error<StringError>("controller ran out of x"))),
+ FailedWithMessage("controller ran out of x"));
}
TEST(SimpleRemoteCATest, DecodeHangupRejectsAnEmptyPayload) {
// Never valid: the two ends are rev-locked, so this is a bug in the peer
// rather than version skew. It comes back as an error like any other reason,
// since both outcomes end the session.
- auto Err = TestCA::decodeHangup(WrapperFunctionBuffer());
- ASSERT_TRUE(!!Err);
- EXPECT_EQ(toString(std::move(Err)),
- "Malformed hang-up message: could not deserialize reason");
+ EXPECT_THAT_ERROR(
+ TestCA::decodeHangup(WrapperFunctionBuffer()),
+ FailedWithMessage(
+ "Malformed hang-up message: could not deserialize reason"));
}
TEST(SimpleRemoteCATest, ResultValueRoundTrips) {
@@ -239,11 +240,10 @@ TEST(SimpleRemoteCATest, ResultWithAnUnknownKindIsRejected) {
uint64_t UnknownKind =
static_cast<uint64_t>(TestCA::ResultKind::LastResultKind) + 1;
- auto A = CA->handleMessage(static_cast<uint64_t>(TestCA::Opcode::Result),
- /*SeqNo=*/1, UnknownKind, WrapperFunctionBuffer());
- ASSERT_FALSE(!!A);
- EXPECT_EQ(toString(A.takeError()),
- "Malformed result message: invalid kind 2");
+ EXPECT_THAT_EXPECTED(
+ CA->handleMessage(static_cast<uint64_t>(TestCA::Opcode::Result),
+ /*SeqNo=*/1, UnknownKind, WrapperFunctionBuffer()),
+ FailedWithMessage("Malformed result message: invalid kind 2"));
S.detach();
}
More information about the llvm-commits
mailing list