From 221e418f0c56d6b4a8b188fb4d8e75e21f7b0c8d Mon Sep 17 00:00:00 2001 From: "Joel E. Denny" Date: Thu, 17 Oct 2019 14:02:42 +0000 Subject: [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. Reviewed By: probinson, stella.stamenova Differential Revision: https://reviews.llvm.org/D66574 llvm-svn: 375114 --- llvm/utils/lit/tests/Inputs/shtest-shell/diff-error-0.txt | 3 --- llvm/utils/lit/tests/Inputs/shtest-shell/diff-pipes.txt | 15 +++++++++++++++ .../tests/Inputs/shtest-shell/diff-unified-error-0.txt | 3 --- .../tests/Inputs/shtest-shell/diff-unified-error-1.txt | 3 --- llvm/utils/lit/tests/Inputs/shtest-shell/diff-unified.txt | 4 ++++ 5 files changed, 19 insertions(+), 9 deletions(-) delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-shell/diff-error-0.txt create mode 100644 llvm/utils/lit/tests/Inputs/shtest-shell/diff-pipes.txt delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-shell/diff-unified-error-0.txt delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-shell/diff-unified-error-1.txt (limited to 'llvm/utils/lit/tests/Inputs') 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 -- cgit v1.2.3