diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 10:51:19 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 10:51:19 +0000 |
| commit | eb11fae6d08f479c0799db45860a98af528fa6e7 (patch) | |
| tree | 44d492a50c8c1a7eb8e2d17ea3360ec4d066f042 /include/llvm/Testing/Support/SupportHelpers.h | |
| parent | b8a2042aa938069e862750553db0e4d82d25822c (diff) | |
Notes
Diffstat (limited to 'include/llvm/Testing/Support/SupportHelpers.h')
| -rw-r--r-- | include/llvm/Testing/Support/SupportHelpers.h | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/include/llvm/Testing/Support/SupportHelpers.h b/include/llvm/Testing/Support/SupportHelpers.h index d7f0c7142b2c..96264ac81dc4 100644 --- a/include/llvm/Testing/Support/SupportHelpers.h +++ b/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); |
