[llvm] [Offload] Make `ASSERT_ERROR` output more readable (PR #157653)
Ross Brunton via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 9 04:48:47 PDT 2025
https://github.com/RossBrunton created https://github.com/llvm/llvm-project/pull/157653
None
>From eaa31d7210d58c49120ac9092e4abb4a8648b27d Mon Sep 17 00:00:00 2001
From: Ross Brunton <ross at codeplay.com>
Date: Tue, 9 Sep 2025 12:48:09 +0100
Subject: [PATCH] [Offload] Make `ASSERT_ERROR` output more readable
---
offload/unittests/OffloadAPI/common/Fixtures.hpp | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/offload/unittests/OffloadAPI/common/Fixtures.hpp b/offload/unittests/OffloadAPI/common/Fixtures.hpp
index c5a35faba7a27..6f9961e2c6d58 100644
--- a/offload/unittests/OffloadAPI/common/Fixtures.hpp
+++ b/offload/unittests/OffloadAPI/common/Fixtures.hpp
@@ -40,12 +40,16 @@
} while (0)
#endif
-// TODO: rework this so the EXPECTED/ACTUAL results are readable
#ifndef ASSERT_ERROR
#define ASSERT_ERROR(EXPECTED, ACTUAL) \
do { \
ol_result_t Res = ACTUAL; \
- ASSERT_TRUE(Res && (Res->Code == EXPECTED)); \
+ if (!Res) \
+ GTEST_FAIL() << #ACTUAL " succeeded when we expected it to fail"; \
+ if (Res->Code != EXPECTED) \
+ GTEST_FAIL() << #ACTUAL " was expected to return " \
+ << #EXPECTED " but instead returned " << Res->Code << ": " \
+ << Res->Details; \
} while (0)
#endif
More information about the llvm-commits
mailing list