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

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 5 14:39:53 PST 2018


zturner added inline comments.


================
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
----------------
Dor1s wrote:
> 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.
You can't use substitutions like `%t` in a check prefix.  Those are expanded only in run lines.  The general solution for this is to wrap that part in a regex.  So for example, instead of this:

```
ERROR1: Only in %t/dir1: dir1unique
```

You would write this:

```
ERROR1: Only in {{.*}}dir1: dir1unique
```

That said, I would really prefer if we could use the check lines instead of grep, since that's the canonical way of writing tests and there are other advantages as well (`CHECK-NEXT`, etc)


https://reviews.llvm.org/D41776





More information about the llvm-commits mailing list