[PATCH] D86926: FormatTest: Provide real line number in failure messages

Alexander Richardson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 1 07:05:59 PDT 2020


arichardson added inline comments.


================
Comment at: clang/unittests/Format/FormatTest.cpp:69
 
-  void verifyFormat(llvm::StringRef Expected, llvm::StringRef Code,
-                    const FormatStyle &Style = getLLVMStyle()) {
+  void _verifyFormat(const char *File, int Line, llvm::StringRef Expected,
+                     llvm::StringRef Code,
----------------
MyDeveloperDay wrote:
> Nit: I'm unsure of the convention for using _ at the front of functions, I'm not a major fan others might have other opinions
I just picked something that's different and makes it easy to change the calls without reformatting everything. Also happy to use `verifyImpl` or something like that?


================
Comment at: clang/unittests/Format/FormatTest.cpp:72
+                     const FormatStyle &Style = getLLVMStyle()) {
+    ScopedTrace t(File, Line, ::testing::Message() << Code.str());
     EXPECT_EQ(Expected.str(), format(Expected, Style))
----------------
MyDeveloperDay wrote:
> could you add an example as to what the output would look like? 
> 
> I think we could pass the File and line number to the EXPECT_EQ in the `<<` message
This is what it looks like now:
```
/Users/alex/cheri/upstream-llvm-project/clang/unittests/Format/FormatTest.cpp:81: Failure
      Expected: Expected.str()
      Which is: "void f() { MACRO(LIST(uint64_t) *a); }"
To be equal to: format(test::messUp(Code), ObjCStyle)
      Which is: "void f() { MACRO(LIST(uint64_t) * a); }"
Google Test trace:
/Users/alex/cheri/upstream-llvm-project/clang/unittests/Format/FormatTest.cpp:7859: void f() { MACRO(LIST(uint64_t) *a); }
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86926/new/

https://reviews.llvm.org/D86926



More information about the cfe-commits mailing list