[clang] [clang-format] Add test to ensure formatting options docs are updated (PR #118154)

via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 4 22:53:53 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-format

@llvm/pr-subscribers-clang

Author: Aiden Grossman (boomanaiden154)

<details>
<summary>Changes</summary>

This patch adds a lit test to clang format to ensure that the ClangFormatStyleOptions doc page has been updated appropriately. The test just runs the automatic update script and diffs the outputs to ensure they are the same.

---
Full diff: https://github.com/llvm/llvm-project/pull/118154.diff


3 Files Affected:

- (modified) clang/docs/tools/dump_format_style.py (+2-1) 
- (added) clang/test/Format/docs_updated.test (+2) 
- (modified) clang/test/Format/lit.local.cfg (+1) 


``````````diff
diff --git a/clang/docs/tools/dump_format_style.py b/clang/docs/tools/dump_format_style.py
index af0e658fcdc55d..c82b4479f299d9 100755
--- a/clang/docs/tools/dump_format_style.py
+++ b/clang/docs/tools/dump_format_style.py
@@ -487,5 +487,6 @@ class State:
 
 contents = substitute(contents, "FORMAT_STYLE_OPTIONS", options_text)
 
-with open(DOC_FILE, "wb") as output:
+output_file_path = sys.argv[1] if len(sys.argv) == 2 else DOC_FILE
+with open(output_file_path, "wb") as output:
     output.write(contents.encode())
diff --git a/clang/test/Format/docs_updated.test b/clang/test/Format/docs_updated.test
new file mode 100644
index 00000000000000..fe2e4f1bd13a1b
--- /dev/null
+++ b/clang/test/Format/docs_updated.test
@@ -0,0 +1,2 @@
+// RUN: %python %S/../../docs/tools/dump_format_style.py %t
+// RUN: diff %t %S/../../docs/ClangFormatStyleOptions.rst
diff --git a/clang/test/Format/lit.local.cfg b/clang/test/Format/lit.local.cfg
index 3eb0f54ceaa6f9..8acf02725d701b 100644
--- a/clang/test/Format/lit.local.cfg
+++ b/clang/test/Format/lit.local.cfg
@@ -17,4 +17,5 @@ config.suffixes = [
     ".textpb",
     ".asciipb",
     ".td",
+    ".test"
 ]

``````````

</details>


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


More information about the cfe-commits mailing list