Author: Michael Buch
Date: 2022-12-15T22:45:46Z
New Revision: c46587bb83232bd639c1e6ba6bce2f290941675d

URL: 
https://github.com/llvm/llvm-project/commit/c46587bb83232bd639c1e6ba6bce2f290941675d
DIFF: 
https://github.com/llvm/llvm-project/commit/c46587bb83232bd639c1e6ba6bce2f290941675d.diff

LOG: [lldb][Test] Propagate llvm::yaml error message in TestFile::fromYaml

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.
```

Differential Revision: https://reviews.llvm.org/D140112

Added: 
    

Modified: 
    lldb/unittests/TestingSupport/TestUtilities.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/unittests/TestingSupport/TestUtilities.cpp 
b/lldb/unittests/TestingSupport/TestUtilities.cpp
index 86f3d1a7dfa75..9e5523e487547 100644
--- a/lldb/unittests/TestingSupport/TestUtilities.cpp
+++ b/lldb/unittests/TestingSupport/TestUtilities.cpp
@@ -30,9 +30,11 @@ llvm::Expected<TestFile> TestFile::fromYaml(llvm::StringRef 
Yaml) {
   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));
 }
 


        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to