[clang] [clang-format] Separate License text and include blocks (PR #77918)

via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 15 06:11:51 PST 2024


================
@@ -610,6 +626,113 @@ TEST_F(DefinitionBlockSeparatorTest, JavaScript) {
                "}",
                Style);
 }
+
+TEST_P(LicenseTest, SeparateLicenseFromBlock) {
+  constexpr StringRef LicenseSingleLineCommentStyle = {"// start license\n"
+                                                       "// license text\n"
+                                                       "// more license text\n"
+                                                       "// end license\n"};
+  constexpr StringRef LicenseMultipleLineCommentStyle{"/*\n"
+                                                      "start license\n"
+                                                      "license text\n"
+                                                      "more license text\n"
+                                                      "end license */\n"};
+
+  const auto Block = GetParam();
+  FormatStyle Style = getLLVMStyle();
+  Style.SeparateDefinitionBlocks = FormatStyle::SDS_One;
+  Style.MaxEmptyLinesToKeep = 2;
+  verifyFormat(LicenseSingleLineCommentStyle.str() + "\n" + Block, Style);
----------------
mydeveloperday wrote:

Can we not write the test like this, I'm sorry but I think its so much more readable to say it all out in the verifyFormat

```c++
veryformat("// start license
                   ....., Style);
```

I don't want to have to run a debugger to understand the text thats being passed to verifyFormat I want to see it verbatum

https://github.com/llvm/llvm-project/pull/77918


More information about the cfe-commits mailing list