summaryrefslogtreecommitdiffstats
path: root/llvm/include/llvm/Testing/Support/SupportHelpers.h
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/include/llvm/Testing/Support/SupportHelpers.h')
-rw-r--r--llvm/include/llvm/Testing/Support/SupportHelpers.h20
1 files changed, 14 insertions, 6 deletions
diff --git a/llvm/include/llvm/Testing/Support/SupportHelpers.h b/llvm/include/llvm/Testing/Support/SupportHelpers.h
index d7f0c7142b2..96264ac81dc 100644
--- a/llvm/include/llvm/Testing/Support/SupportHelpers.h
+++ b/llvm/include/llvm/Testing/Support/SupportHelpers.h
@@ -17,8 +17,9 @@
namespace llvm {
namespace detail {
struct ErrorHolder {
- bool Success;
- std::string Message;
+ std::vector<std::shared_ptr<ErrorInfoBase>> Infos;
+
+ bool Success() const { return Infos.empty(); }
};
template <typename T> struct ExpectedHolder : public ErrorHolder {
@@ -29,15 +30,22 @@ template <typename T> struct ExpectedHolder : public ErrorHolder {
};
inline void PrintTo(const ErrorHolder &Err, std::ostream *Out) {
- *Out << (Err.Success ? "succeeded" : "failed");
- if (!Err.Success) {
- *Out << " (" << StringRef(Err.Message).trim().str() << ")";
+ raw_os_ostream OS(*Out);
+ OS << (Err.Success() ? "succeeded" : "failed");
+ if (!Err.Success()) {
+ const char *Delim = " (";
+ for (const auto &Info : Err.Infos) {
+ OS << Delim;
+ Delim = "; ";
+ Info->log(OS);
+ }
+ OS << ")";
}
}
template <typename T>
void PrintTo(const ExpectedHolder<T> &Item, std::ostream *Out) {
- if (Item.Success) {
+ if (Item.Success()) {
*Out << "succeeded with value " << ::testing::PrintToString(*Item.Exp);
} else {
PrintTo(static_cast<const ErrorHolder &>(Item), Out);
OpenPOWER on IntegriCloud