Skip to content

Commit 64b9237

Browse files
committed
[Utils] Document DiffUpdater.py
1 parent bccb825 commit 64b9237

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

llvm/utils/lit/lit/DiffUpdater.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
import shutil
22

3+
"""
4+
This file provides the `diff_test_updater` function, which is invoked on failed RUN lines when lit is executed with --update-tests.
5+
It checks whether the failed command is `diff` and, if so, uses heuristics to determine which file is the checked-in reference file and which file is output from the test case.
6+
The heuristics are currently as follows:
7+
- if exactly one file ends with ".expected" (common pattern in LLVM), that file is the reference file and the other is the output file
8+
- if exactly one file path contains ".tmp" (e.g. because it contains the expansion of "%t"), that file is the reference file and the other is the output file
9+
If the command matches one of these patterns the output file content is copied to the reference file to make the test pass.
10+
Otherwise the test is ignored.
11+
12+
Possible improvements:
13+
- Support stdin patterns like "my_binary %s | diff expected.txt"
14+
- Scan RUN lines to see if a file is the source of output from a previous command.
15+
If it is then it is not a reference file that can be copied to, regardless of name, since the test will overwrite it anyways.
16+
- Only update the parts that need updating (based on the diff output). Could help avoid noisy updates when e.g. whitespace changes are ignored.
17+
"""
318

419
def get_source_and_target(a, b):
520
"""

0 commit comments

Comments
 (0)