[PATCH] D42034: [clang-format] In tests, expected code should be format-stable

Mark Zeren via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 14 07:13:52 PST 2018


mzeren-vmw created this revision.
mzeren-vmw added reviewers: klimek, krasimir, euhlmann.
Herald added a subscriber: cfe-commits.

Extend the verifyFormat helper function to check that the expected text
is "stable". This provides some protection against bugs where formatting
results are ocilating between two forms, or continually change in some
other way.

Testing Done:

- Ran unit tests.

- Reproduced a known instability in preprocessor indentation which was caught by this new check (to be resolved in a later change.)


Repository:
  rC Clang

https://reviews.llvm.org/D42034

Files:
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===================================================================
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -72,6 +72,7 @@
 
   void verifyFormat(llvm::StringRef Expected, llvm::StringRef Code,
                     const FormatStyle &Style = getLLVMStyle()) {
+    EXPECT_EQ(Expected.str(), format(Expected, Style));
     EXPECT_EQ(Expected.str(), format(Code, Style));
     if (Style.Language == FormatStyle::LK_Cpp) {
       // Objective-C++ is a superset of C++, so everything checked for C++


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42034.129775.patch
Type: text/x-patch
Size: 570 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180114/80dffc40/attachment.bin>


More information about the cfe-commits mailing list