[clang] [llvm] Reland "[Utils] Add new --update-tests flag to llvm-lit" (PR #153821)
Min-Yih Hsu via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 15 09:41:30 PDT 2025
================
@@ -0,0 +1,39 @@
+import shutil
+
+
+def get_source_and_target(a, b):
+ """
+ Try to figure out which file is the test output and which is the reference.
+ """
+ expected_suffix = ".expected"
+ if a.endswith(expected_suffix) and not b.endswith(expected_suffix):
+ return b, a
+ if b.endswith(expected_suffix) and not a.endswith(expected_suffix):
+ return a, b
+
+ tmp_substr = ".tmp"
+ if tmp_substr in a and not tmp_substr in b:
+ return a, b
+ if tmp_substr in b and not tmp_substr in a:
+ return b, a
+
+ return None
+
+
+def filter_flags(args):
+ return [arg for arg in args if not arg.startswith("-")]
+
+
+def diff_test_updater(result, test):
----------------
mshockwave wrote:
I think it's clever to catch failed diff commands and relay it to this plugin (which update the expected output file), but it wasn't so straightforward to me at first -- perhaps adding some comments at the beginning of this file?
https://github.com/llvm/llvm-project/pull/153821
More information about the cfe-commits
mailing list