diff options
author | Joel E. Denny <jdenny.ornl@gmail.com> | 2019-12-17 10:23:11 -0500 |
---|---|---|
committer | Joel E. Denny <jdenny.ornl@gmail.com> | 2019-12-17 10:49:34 -0500 |
commit | 9658e77e27fa2a93667f840d230086d783fed6dc (patch) | |
tree | 317dc5a1d7e4a289df48635f87c76179d5257036 /llvm/utils | |
parent | fbaf835c5c515bf00dccd880b8afe0b2e0a10e06 (diff) | |
download | bcm5719-llvm-9658e77e27fa2a93667f840d230086d783fed6dc.tar.gz bcm5719-llvm-9658e77e27fa2a93667f840d230086d783fed6dc.zip |
[lit] Fix internal diff newlines for -w/-b
For example, without this patch:
```
$ python $LIT_BUILTINS/diff.py -b foo.txt bar.txt
*** /tmp/foo.txt
--- /tmp/bar.txt
***************
*** 1,2 ****
1! 2--- 1,2 ----
1! 20
```
With this patch:
```
$ python $LIT_BUILTINS/diff.py -b foo.txt bar.txt
*** /tmp/foo.txt
--- /tmp/bar.txt
***************
*** 1,2 ****
1
! 2
--- 1,2 ----
1
! 20
```
Reviewed By: rnk
Differential Revision: https://reviews.llvm.org/D71577
Diffstat (limited to 'llvm/utils')
-rw-r--r-- | llvm/utils/lit/lit/builtin_commands/diff.py | 3 | ||||
-rw-r--r-- | llvm/utils/lit/tests/Inputs/shtest-shell/diff-b.txt | 8 | ||||
-rw-r--r-- | llvm/utils/lit/tests/Inputs/shtest-shell/diff-w.txt | 10 | ||||
-rw-r--r-- | llvm/utils/lit/tests/max-failures.py | 2 | ||||
-rw-r--r-- | llvm/utils/lit/tests/shtest-shell.py | 34 |
5 files changed, 54 insertions, 3 deletions
diff --git a/llvm/utils/lit/lit/builtin_commands/diff.py b/llvm/utils/lit/lit/builtin_commands/diff.py index 77bf5d78ca5..a12e5e100b1 100644 --- a/llvm/utils/lit/lit/builtin_commands/diff.py +++ b/llvm/utils/lit/lit/builtin_commands/diff.py @@ -89,7 +89,8 @@ def compareTwoTextFiles(flags, filepaths, filelines_bin, encoding): if flags.strip_trailing_cr: f = compose2(lambda line: line.replace('\r\n', '\n'), f) if flags.ignore_all_space or flags.ignore_space_change: - ignoreSpace = lambda line, separator: separator.join(line.split()) + ignoreSpace = lambda line, separator: \ + separator.join(line.split()) + "\n" ignoreAllSpaceOrSpaceChange = functools.partial(ignoreSpace, separator='' if flags.ignore_all_space else ' ') f = compose2(ignoreAllSpaceOrSpaceChange, f) diff --git a/llvm/utils/lit/tests/Inputs/shtest-shell/diff-b.txt b/llvm/utils/lit/tests/Inputs/shtest-shell/diff-b.txt new file mode 100644 index 00000000000..4c5f92b2d70 --- /dev/null +++ b/llvm/utils/lit/tests/Inputs/shtest-shell/diff-b.txt @@ -0,0 +1,8 @@ +# RUN: echo 'f o o' > %t.0 +# RUN: echo 'b a r' >> %t.0 + +# RUN: echo 'f o o' > %t.1 +# RUN: echo 'bar' >> %t.1 + +# Due to -b, only second line has a change. +# RUN: diff -b %t.0 %t.1 diff --git a/llvm/utils/lit/tests/Inputs/shtest-shell/diff-w.txt b/llvm/utils/lit/tests/Inputs/shtest-shell/diff-w.txt new file mode 100644 index 00000000000..e5b0777c418 --- /dev/null +++ b/llvm/utils/lit/tests/Inputs/shtest-shell/diff-w.txt @@ -0,0 +1,10 @@ +# RUN: echo 'f o o' > %t.0 +# RUN: echo 'b a r' >> %t.0 +# RUN: echo 'b a z' >> %t.0 + +# RUN: echo 'f o o' > %t.1 +# RUN: echo 'bar' >> %t.1 +# RUN: echo 'b a t' >> %t.1 + +# Due to -w, only third line has a change. +# RUN: diff -w %t.0 %t.1 diff --git a/llvm/utils/lit/tests/max-failures.py b/llvm/utils/lit/tests/max-failures.py index f661980ac2b..267d7eec324 100644 --- a/llvm/utils/lit/tests/max-failures.py +++ b/llvm/utils/lit/tests/max-failures.py @@ -8,7 +8,7 @@ # # END. -# CHECK: Failing Tests (33) +# CHECK: Failing Tests (35) # CHECK: Failing Tests (1) # CHECK: Failing Tests (2) # CHECK: error: argument --max-failures: requires positive integer, but found '0' diff --git a/llvm/utils/lit/tests/shtest-shell.py b/llvm/utils/lit/tests/shtest-shell.py index 443cc10ef3b..5bf38ebd08f 100644 --- a/llvm/utils/lit/tests/shtest-shell.py +++ b/llvm/utils/lit/tests/shtest-shell.py @@ -34,6 +34,22 @@ # CHECK: error: command failed with exit status: 127 # CHECK: *** +# CHECK: PASS: shtest-shell :: dev-null.txt + +# CHECK: FAIL: shtest-shell :: diff-b.txt +# CHECK: *** TEST 'shtest-shell :: diff-b.txt' FAILED *** +# CHECK: $ "diff" "-b" "{{[^"]*}}.0" "{{[^"]*}}.1" +# CHECK: # command output: +# CHECK: 1,2 +# CHECK-NEXT: {{^ }}f o o +# CHECK-NEXT: ! b a r +# CHECK-NEXT: --- +# CHECK-NEXT: {{^ }}f o o +# CHECK-NEXT: ! bar +# CHECK-EMPTY: +# CHECK: error: command failed with exit status: 1 +# CHECK: *** + # CHECK: FAIL: shtest-shell :: diff-encodings.txt # CHECK: *** TEST 'shtest-shell :: diff-encodings.txt' FAILED *** @@ -460,6 +476,22 @@ # CHECK: *** +# CHECK: FAIL: shtest-shell :: diff-w.txt +# CHECK: *** TEST 'shtest-shell :: diff-w.txt' FAILED *** +# CHECK: $ "diff" "-w" "{{[^"]*}}.0" "{{[^"]*}}.1" +# CHECK: # command output: +# CHECK: 1,3 +# CHECK-NEXT: {{^ }}foo +# CHECK-NEXT: {{^ }}bar +# CHECK-NEXT: ! baz +# CHECK-NEXT: --- +# CHECK-NEXT: {{^ }}foo +# CHECK-NEXT: {{^ }}bar +# CHECK-NEXT: ! bat +# CHECK-EMPTY: +# CHECK: error: command failed with exit status: 1 +# CHECK: *** + # CHECK: FAIL: shtest-shell :: error-0.txt # CHECK: *** TEST 'shtest-shell :: error-0.txt' FAILED *** # CHECK: $ "not-a-real-command" @@ -551,4 +583,4 @@ # CHECK: *** # CHECK: PASS: shtest-shell :: valid-shell.txt -# CHECK: Failing Tests (33) +# CHECK: Failing Tests (35) |