summaryrefslogtreecommitdiffstats
path: root/llvm/utils/lit/tests
diff options
context:
space:
mode:
authorJoel E. Denny <jdenny.ornl@gmail.com>2019-10-17 14:02:42 +0000
committerJoel E. Denny <dennyje@ornl.gov>2019-10-29 15:13:52 -0400
commitb163806cdc317ee160a2ce694958c088a949fa7d (patch)
tree12022f7999d0698318fd87bd22c1f278bc12170a /llvm/utils/lit/tests
parent772533d9214b6e23762847fc7080a4201396fb10 (diff)
downloadbcm5719-llvm-b163806cdc317ee160a2ce694958c088a949fa7d.tar.gz
bcm5719-llvm-b163806cdc317ee160a2ce694958c088a949fa7d.zip
[lit] Make internal diff work in pipelines
When using lit's internal shell, RUN lines like the following accidentally execute an external `diff` instead of lit's internal `diff`: ``` # RUN: program | diff file - # RUN: not diff file1 file2 | FileCheck %s ``` Such cases exist now, in `clang/test/Analysis` for example. We are preparing patches to ensure lit's internal `diff` is called in such cases, which will then fail because lit's internal `diff` cannot currently be used in pipelines and doesn't recognize `-` as a command-line option. To enable pipelines, this patch moves lit's `diff` implementation into an out-of-process script, similar to lit's `cat` implementation. A follow-up patch will implement `-` to mean stdin. Also, when lit's `diff` prints differences to stdout in Windows, this patch ensures it always terminate lines with `\n` not `\r\n`. That way, strict FileCheck directives checking the `diff` output succeed in both Linux and Windows. This wasn't an issue when `diff` was internal to lit because `diff` didn't then write to the true stdout, which is where the `\n` -> `\r\n` conversion happened in Python. Reviewed By: probinson, stella.stamenova Differential Revision: https://reviews.llvm.org/D66574
Diffstat (limited to 'llvm/utils/lit/tests')
-rw-r--r--llvm/utils/lit/tests/Inputs/shtest-shell/diff-error-0.txt3
-rw-r--r--llvm/utils/lit/tests/Inputs/shtest-shell/diff-pipes.txt15
-rw-r--r--llvm/utils/lit/tests/Inputs/shtest-shell/diff-unified-error-0.txt3
-rw-r--r--llvm/utils/lit/tests/Inputs/shtest-shell/diff-unified-error-1.txt3
-rw-r--r--llvm/utils/lit/tests/Inputs/shtest-shell/diff-unified.txt4
-rw-r--r--llvm/utils/lit/tests/max-failures.py2
-rw-r--r--llvm/utils/lit/tests/shtest-shell.py78
7 files changed, 65 insertions, 43 deletions
diff --git a/llvm/utils/lit/tests/Inputs/shtest-shell/diff-error-0.txt b/llvm/utils/lit/tests/Inputs/shtest-shell/diff-error-0.txt
deleted file mode 100644
index 81888cf8197..00000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-shell/diff-error-0.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-# Check error on a unsupported diff (cannot be part of a pipeline).
-#
-# RUN: diff diff-error-0.txt diff-error-0.txt | echo Output
diff --git a/llvm/utils/lit/tests/Inputs/shtest-shell/diff-pipes.txt b/llvm/utils/lit/tests/Inputs/shtest-shell/diff-pipes.txt
new file mode 100644
index 00000000000..ce0abca1661
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-shell/diff-pipes.txt
@@ -0,0 +1,15 @@
+# RUN: echo foo > %t.foo
+# RUN: echo bar > %t.bar
+
+# Check output pipe.
+# RUN: diff %t.foo %t.foo | FileCheck -allow-empty -check-prefix=EMPTY %s
+# RUN: diff -u %t.foo %t.bar | FileCheck %s && false || true
+
+# Fail so lit will print output.
+# RUN: false
+
+# CHECK: @@
+# CHECK-NEXT: -foo
+# CHECK-NEXT: +bar
+
+# EMPTY-NOT: {{.}}
diff --git a/llvm/utils/lit/tests/Inputs/shtest-shell/diff-unified-error-0.txt b/llvm/utils/lit/tests/Inputs/shtest-shell/diff-unified-error-0.txt
deleted file mode 100644
index ee3858a02ba..00000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-shell/diff-unified-error-0.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-# Check bad -U argument.
-# RUN: echo foo > %t
-# RUN: diff -U 30.1 %t %t
diff --git a/llvm/utils/lit/tests/Inputs/shtest-shell/diff-unified-error-1.txt b/llvm/utils/lit/tests/Inputs/shtest-shell/diff-unified-error-1.txt
deleted file mode 100644
index e46e8b5783b..00000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-shell/diff-unified-error-1.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-# Check bad -U argument.
-# RUN: echo foo > %t
-# RUN: diff -U-1 %t %t
diff --git a/llvm/utils/lit/tests/Inputs/shtest-shell/diff-unified.txt b/llvm/utils/lit/tests/Inputs/shtest-shell/diff-unified.txt
index a6a7eef3f9b..e977c193247 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-shell/diff-unified.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-shell/diff-unified.txt
@@ -30,5 +30,9 @@
# RUN: diff -U4 %t.foo %t.bar && false || true
# RUN: diff -U0 %t.foo %t.bar && false || true
+# Check bad -U argument.
+# RUN: diff -U 30.1 %t.foo %t.foo && false || true
+# RUN: diff -U-1 %t.foo %t.foo && false || true
+
# Fail so lit will print output.
# RUN: false
diff --git a/llvm/utils/lit/tests/max-failures.py b/llvm/utils/lit/tests/max-failures.py
index f661980ac2b..3b85ae18611 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 (31)
# 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 cef3728dd00..150c2fe362c 100644
--- a/llvm/utils/lit/tests/shtest-shell.py
+++ b/llvm/utils/lit/tests/shtest-shell.py
@@ -86,28 +86,20 @@
# CHECK: ***
-# CHECK: FAIL: shtest-shell :: diff-error-0.txt
-# CHECK: *** TEST 'shtest-shell :: diff-error-0.txt' FAILED ***
-# CHECK: $ "diff" "diff-error-0.txt" "diff-error-0.txt"
-# CHECK: # command stderr:
-# CHECK: Unsupported: 'diff' cannot be part of a pipeline
-# CHECK: error: command failed with exit status: 127
-# CHECK: ***
-
# CHECK: FAIL: shtest-shell :: diff-error-1.txt
# CHECK: *** TEST 'shtest-shell :: diff-error-1.txt' FAILED ***
# CHECK: $ "diff" "-B" "temp1.txt" "temp2.txt"
# CHECK: # command stderr:
# CHECK: Unsupported: 'diff': option -B not recognized
-# CHECK: error: command failed with exit status: 127
+# CHECK: error: command failed with exit status: 1
# CHECK: ***
# CHECK: FAIL: shtest-shell :: diff-error-2.txt
# CHECK: *** TEST 'shtest-shell :: diff-error-2.txt' FAILED ***
# CHECK: $ "diff" "temp.txt"
# CHECK: # command stderr:
-# CHECK: Error: missing or extra operand
-# CHECK: error: command failed with exit status: 127
+# CHECK: Error: missing or extra operand
+# CHECK: error: command failed with exit status: 1
# CHECK: ***
# CHECK: FAIL: shtest-shell :: diff-error-3.txt
@@ -134,18 +126,43 @@
# CHECK: *** TEST 'shtest-shell :: diff-error-5.txt' FAILED ***
# CHECK: $ "diff"
# CHECK: # command stderr:
-# CHECK: Error: missing or extra operand
-# CHECK: error: command failed with exit status: 127
+# CHECK: Error: missing or extra operand
+# CHECK: error: command failed with exit status: 1
# CHECK: ***
# CHECK: FAIL: shtest-shell :: diff-error-6.txt
# CHECK: *** TEST 'shtest-shell :: diff-error-6.txt' FAILED ***
# CHECK: $ "diff"
# CHECK: # command stderr:
-# CHECK: Error: missing or extra operand
-# CHECK: error: command failed with exit status: 127
+# CHECK: Error: missing or extra operand
+# CHECK: error: command failed with exit status: 1
+# CHECK: ***
+
+
+# CHECK: FAIL: shtest-shell :: diff-pipes.txt
+
+# CHECK: *** TEST 'shtest-shell :: diff-pipes.txt' FAILED ***
+
+# CHECK: $ "diff" "{{[^"]*}}.foo" "{{[^"]*}}.foo"
+# CHECK-NOT: note
+# CHECK-NOT: error
+# CHECK: $ "FileCheck"
+# CHECK-NOT: note
+# CHECK-NOT: error
+
+# CHECK: $ "diff" "-u" "{{[^"]*}}.foo" "{{[^"]*}}.bar"
+# CHECK: note: command had no output on stdout or stderr
+# CHECK: error: command failed with exit status: 1
+# CHECK: $ "FileCheck"
+# CHECK-NOT: note
+# CHECK-NOT: error
+# CHECK: $ "true"
+
+# CHECK: $ "false"
+
# CHECK: ***
+
# CHECK: FAIL: shtest-shell :: diff-r-error-0.txt
# CHECK: *** TEST 'shtest-shell :: diff-r-error-0.txt' FAILED ***
# CHECK: $ "diff" "-r"
@@ -255,23 +272,6 @@
# CHECK: ***
-# CHECK: FAIL: shtest-shell :: diff-unified-error-0.txt
-# CHECK: *** TEST 'shtest-shell :: diff-unified-error-0.txt' FAILED ***
-# CHECK: $ "diff" "-U" "30.1" "{{[^"]*}}" "{{[^"]*}}"
-# CHECK: # command stderr:
-# CHECK: Error: invalid '-U' argument: 30.1
-# CHECK: error: command failed with exit status: 127
-# CHECK: ***
-
-# CHECK: FAIL: shtest-shell :: diff-unified-error-1.txt
-# CHECK: *** TEST 'shtest-shell :: diff-unified-error-1.txt' FAILED ***
-# CHECK: $ "diff" "-U-1" "{{[^"]*}}" "{{[^"]*}}"
-# CHECK: # command stderr:
-# CHECK: Error: invalid '-U' argument: -1
-# CHECK: error: command failed with exit status: 127
-# CHECK: ***
-
-
# CHECK: FAIL: shtest-shell :: diff-unified.txt
# CHECK: *** TEST 'shtest-shell :: diff-unified.txt' FAILED ***
@@ -330,6 +330,18 @@
# CHECK-NEXT: error: command failed with exit status: 1
# CHECK-NEXT: $ "true"
+# CHECK: $ "diff" "-U" "30.1" "{{[^"]*}}" "{{[^"]*}}"
+# CHECK: # command stderr:
+# CHECK: Error: invalid '-U' argument: 30.1
+# CHECK: error: command failed with exit status: 1
+# CHECK: $ "true"
+
+# CHECK: $ "diff" "-U-1" "{{[^"]*}}" "{{[^"]*}}"
+# CHECK: # command stderr:
+# CHECK: Error: invalid '-U' argument: -1
+# CHECK: error: command failed with exit status: 1
+# CHECK: $ "true"
+
# CHECK: $ "false"
# CHECK: ***
@@ -426,4 +438,4 @@
# CHECK: ***
# CHECK: PASS: shtest-shell :: valid-shell.txt
-# CHECK: Failing Tests (33)
+# CHECK: Failing Tests (31)
OpenPOWER on IntegriCloud