[Lldb-commits] [PATCH] D140112: [lldb][Test] Propagate llvm::yaml error message in TestFile::fromYaml

Michael Buch via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Dec 15 08:31:32 PST 2022


Michael137 created this revision.
Michael137 added reviewers: aprantl, JDevlieghere.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Currently the test-suite would swallow the error message
on `llvm::yaml::convertYAML` failures.

This patch simply propagates the error string up to the caller.

Before patch:

  [ RUN      ] DWARFASTParserClangTests.TestDefaultTemplateParamParsing
  /Users/michaelbuch/Git/llvm-worktrees/playground/lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp:19: Failure
  Value of: llvm::detail::TakeExpected(File)
  Expected: succeeded
    Actual: failed  (convertYAML() failed: )
  Assertion failed: (!HasError && "Cannot get value when an error exists!"), function getStorage, file Error.h, line 671.

After patch:

  [ RUN      ] DWARFASTParserClangTests.TestDefaultTemplateParamParsing
  /Users/michaelbuch/Git/llvm-worktrees/playground/lldb/unittests/TestingSupport/Symbol/YAMLModuleTester.cpp:19: Failure
  Value of: llvm::detail::TakeExpected(File)
  Expected: succeeded
    Actual: failed  (convertYAML() failed: wrote too much data somewhere, section offsets don't line up)
  Assertion failed: (!HasError && "Cannot get value when an error exists!"), function getStorage, file Error.h, line 671.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140112

Files:
  lldb/unittests/TestingSupport/TestUtilities.cpp


Index: lldb/unittests/TestingSupport/TestUtilities.cpp
===================================================================
--- lldb/unittests/TestingSupport/TestUtilities.cpp
+++ lldb/unittests/TestingSupport/TestUtilities.cpp
@@ -30,9 +30,11 @@
   std::string Buffer;
   llvm::raw_string_ostream OS(Buffer);
   llvm::yaml::Input YIn(Yaml);
-  if (!llvm::yaml::convertYAML(YIn, OS, [](const llvm::Twine &Msg) {}))
-    return llvm::createStringError(llvm::inconvertibleErrorCode(),
-                                   "convertYAML() failed");
+  std::string ErrorMsg("convertYAML() failed: ");
+  if (!llvm::yaml::convertYAML(YIn, OS, [&ErrorMsg](const llvm::Twine &Msg) {
+        ErrorMsg += Msg.str();
+      }))
+    return llvm::createStringError(llvm::inconvertibleErrorCode(), ErrorMsg);
   return TestFile(std::move(Buffer));
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140112.483202.patch
Type: text/x-patch
Size: 839 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20221215/8cc9e952/attachment.bin>


More information about the lldb-commits mailing list