diff --git a/llvm/utils/lit/lit/builtin_commands/diff.py b/llvm/utils/lit/lit/builtin_commands/diff.py --- a/llvm/utils/lit/lit/builtin_commands/diff.py +++ b/llvm/utils/lit/lit/builtin_commands/diff.py @@ -89,7 +89,8 @@ 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 --- /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 --- /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 --- 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 --- 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)