[PATCH] D41776: [lit] Implement "-r" option for builtin "diff" command + a test using that.

Max Moroz via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 5 14:35:19 PST 2018

Dor1s added a comment.

Please take a look :)

Comment at: utils/lit/lit/TestRunner.py:378
+        lines = []
+        for dir, subdirList, fileList in os.walk(path):
+            for file in fileList:
Dor1s wrote:
> morehouse wrote:
> > Does os.walk have well-defined ordering?  What if contents of `dir1` are visited in a different order than `dir2`?
> I believe so, but either way it looks like this needs more work in order to provide the same output as a regular "diff" utility does.
Resolved now, as I put filepaths and contents into a dict.

Comment at: utils/lit/tests/Inputs/shtest-shell/diff-r.txt:26
+# RUN: not diff -r %t/dir1 %t/dir2 > %t.output
+# RUN: grep "Only in %t/dir1: dir1unique" %t.output
+# RUN: grep "Only in %t/dir2: dir2unique" %t.output
I was hoping to use `FileCheck --check-prefix` and different prefixes, but for some reason I'm getting weird errors, e.g.:

$ "not" "diff" "-r" "/usr/local/google/home/mmoroz/Projects/llvm/build/utils/lit/tests/Inputs/shtest-shell/Output/diff-r.txt.tmp/dir1" "/usr/local/google/home/mmoroz/Projects/llvm/build/utils/lit/tests/Inputs/shtest-shell/Output/diff-r.txt.tmp/dir2"
$ "FileCheck" "--check-prefix=ERROR1" "/usr/local/google/home/mmoroz/Projects/llvm/build/utils/lit/tests/Inputs/shtest-shell/diff-r.txt"
# command stderr:
/usr/local/google/home/mmoroz/Projects/llvm/build/utils/lit/tests/Inputs/shtest-shell/diff-r.txt:27:11: error: expected string not found in input
# ERROR1: Only in %t/dir1: dir1unique
<stdin>:1:1: note: scanning from here
Only in /usr/local/google/home/mmoroz/Projects/llvm/build/utils/lit/tests/Inputs/shtest-shell/Output/diff-r.txt.tmp/dir1: dir1unique
<stdin>:1:106: note: possible intended match here
Only in /usr/local/google/home/mmoroz/Projects/llvm/build/utils/lit/tests/Inputs/shtest-shell/Output/diff-r.txt.tmp/dir1: dir1unique

error: command failed with exit status: 1


I'm fine to proceed with `grep`, if reviewers don't mind.


More information about the llvm-commits mailing list