[PATCH] D140217: [lit] Script to automate use of %(line-n). Use in CodeComplete tests.

Haojian Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 19 01:46:11 PST 2022


hokein added inline comments.


================
Comment at: llvm/utils/relative_lines.py:45
+for file in args.files:
+    contents = open(file).read()
+    failures = 0
----------------
it would be nice to make the script more robust (capture and bailout the `UnicodeDecodeError` exception)-- there are some test files that contain invalid utf-8 characters


================
Comment at: llvm/utils/relative_lines.py:94
+    for pattern in args.pattern:
+        contents = re.sub(pattern, replace_match, contents)
+    if failures > 0 and not args.partial:
----------------
looks like we modify the file more eagerly -- if there are no matching pattern, we will replace the content as well (most cases are ok, I saw the CRLF => LF change, I think we'd better only overwrite the content if there are matching patterns). 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140217



More information about the llvm-commits mailing list