-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang-format] Add test to ensure formatting options docs are updated #118154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang-format] Add test to ensure formatting options docs are updated #118154
Conversation
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.
@llvm/pr-subscribers-clang-format @llvm/pr-subscribers-clang Author: Aiden Grossman (boomanaiden154) ChangesThis 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:
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"
]
|
Hello, When running the new testcase the file plurals.txt, which is in the repo, is opened for writing? Is this really desired? I noticed this when I tried to run top of tree lit tests in an environment setup with read-only access on the files in the repo. |
Hm, or it's not related to the testcase, but it happens every time we build now due to 6bec180
? So when we build, plurals.txt is opened for writing? |
That's more likely to be due to #111513. That got reverted. If it's still an issue here, let me know. Everything should be read only here, but that doesn't mean things aren't getting opened with inappropriate permissions. |
Fixed in 74d29c6. |
Thanks! |
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.