[llvm] 9658e77 - [lit] Fix internal diff newlines for -w/-b
Joel E. Denny via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 17 07:50:13 PST 2019
Author: Joel E. Denny
Date: 2019-12-17T10:49:34-05:00
New Revision: 9658e77e27fa2a93667f840d230086d783fed6dc
URL: https://github.com/llvm/llvm-project/commit/9658e77e27fa2a93667f840d230086d783fed6dc
DIFF: https://github.com/llvm/llvm-project/commit/9658e77e27fa2a93667f840d230086d783fed6dc.diff
LOG: [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
Added:
llvm/utils/lit/tests/Inputs/shtest-shell/diff-b.txt
llvm/utils/lit/tests/Inputs/shtest-shell/diff-w.txt
Modified:
llvm/utils/lit/lit/builtin_commands/diff.py
llvm/utils/lit/tests/max-failures.py
llvm/utils/lit/tests/shtest-shell.py
Removed:
################################################################################
diff --git a/llvm/utils/lit/lit/builtin_commands/
diff .py b/llvm/utils/lit/lit/builtin_commands/
diff .py
index 77bf5d78ca50..a12e5e100b1b 100644
--- a/llvm/utils/lit/lit/builtin_commands/
diff .py
+++ b/llvm/utils/lit/lit/builtin_commands/
diff .py
@@ -89,7 +89,8 @@ def compose2(f, g):
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 000000000000..4c5f92b2d705
--- /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 000000000000..e5b0777c4186
--- /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 f661980ac2b5..267d7eec324d 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 443cc10ef3b5..5bf38ebd08f2 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)
More information about the llvm-commits
mailing list