From efae14e96c92985d0f02353a006ffc2d87beb4ff Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Fri, 31 Aug 2012 17:49:33 +0000 Subject: [PATCH] Fix tests to be more robust (to older versions of grep, lesser lit-like test runners, etc) Seems I had a problem with my version of grep, when run by lit, not supporting the \s escape. This seems to fix it for me & I'll be getting the buildbots to run these tests too to keep an eye on them (actually loop-convert tests still fail when run via a make build, so that'll be addressed in a future commit). I could use [[:space:]] to generalize over other whitespace but that seemed unnecessarily verbose when the flexibility wasn't actually required by the current text of the tests. Also I just simplified a lot of the loop-convert tests (removing the unecessary temp file deletion at the start, removing the unnecessary && for FileCheck, etc). The remove-cstr-calls/basic.cpp changes were necessitated by an out of tree lit-like test runner that's a bit less fantastic about escaping. They were modeled on existing tooling test cases in Clang, with thanks to Manuel Klimek for the pointers. llvm-svn: 163009 --- clang-tools-extra/test/loop-convert/array.cpp | 15 +++++++-------- .../test/loop-convert/confidence.cpp | 11 +++++------ .../test/loop-convert/dependency.cpp | 3 +-- clang-tools-extra/test/loop-convert/iterator.cpp | 9 +++------ clang-tools-extra/test/loop-convert/naming.cpp | 7 +++---- .../test/loop-convert/negative-iterator.cpp | 7 +++---- .../test/loop-convert/negative-multi-end-call.cpp | 7 +++---- .../loop-convert/negative-pseudoarray-extra.cpp | 7 +++---- .../test/loop-convert/negative-pseudoarray.cpp | 7 +++---- clang-tools-extra/test/loop-convert/negative.cpp | 12 +++++------- clang-tools-extra/test/loop-convert/nesting.cpp | 7 +++---- clang-tools-extra/test/loop-convert/nocompile.cpp | 8 +++----- .../test/loop-convert/pseudoarray.cpp | 8 +++----- .../test/loop-convert/single-iterator.cpp | 9 +++------ .../test/remove-cstr-calls/basic.cpp | 10 ++++++---- 15 files changed, 54 insertions(+), 73 deletions(-) diff --git a/clang-tools-extra/test/loop-convert/array.cpp b/clang-tools-extra/test/loop-convert/array.cpp index 8853dd6f68d5..330ed8099418 100644 --- a/clang-tools-extra/test/loop-convert/array.cpp +++ b/clang-tools-extra/test/loop-convert/array.cpp @@ -1,12 +1,11 @@ -// RUN: rm -rf %t.cpp -// RUN: grep -Ev "//\s*[A-Z-]+:" %s > %t.cpp -// RUN: loop-convert . %t.cpp -- -I %S/Inputs \ -// RUN: && FileCheck -input-file=%t.cpp %s -// RUN: grep -Ev "//\s*[A-Z-]+:" %s > %t.cpp +// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp // RUN: cp %t.cpp %t.base -// RUN: loop-convert -count-only . %t.cpp -- -I %S/Inputs > %T/out \ -// RUN: && FileCheck -check-prefix=COUNTONLY -input-file=%T/out %s \ -// RUN: && diff %t.cpp %t.base +// RUN: loop-convert . %t.cpp -- -I %S/Inputs +// RUN: FileCheck -input-file=%t.cpp %s +// RUN: cp %t.base %t.cpp +// RUN: loop-convert -count-only . %t.cpp -- -I %S/Inputs > %T/out +// RUN: FileCheck -check-prefix=COUNTONLY -input-file=%T/out %s +// RUN: diff %t.cpp %t.base #include "structures.h" diff --git a/clang-tools-extra/test/loop-convert/confidence.cpp b/clang-tools-extra/test/loop-convert/confidence.cpp index 61f6ebe03ab8..6542ff3266b1 100644 --- a/clang-tools-extra/test/loop-convert/confidence.cpp +++ b/clang-tools-extra/test/loop-convert/confidence.cpp @@ -1,9 +1,8 @@ -// RUN: rm -rf %t.cpp -// RUN: grep -Ev "//\s*[A-Z-]+:" %s > %t.cpp -// RUN: loop-convert . %t.cpp -- -I %S/Inputs \ -// RUN: && FileCheck -input-file=%t.cpp %s -// RUN: loop-convert . %t.cpp -A2 -- -I %S/Inputs \ -// RUN: && FileCheck -check-prefix=RISKY -input-file=%t.cpp %s +// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp +// RUN: loop-convert . %t.cpp -- -I %S/Inputs +// RUN: FileCheck -input-file=%t.cpp %s +// RUN: loop-convert . %t.cpp -A2 -- -I %S/Inputs +// RUN: FileCheck -check-prefix=RISKY -input-file=%t.cpp %s #include "structures.h" diff --git a/clang-tools-extra/test/loop-convert/dependency.cpp b/clang-tools-extra/test/loop-convert/dependency.cpp index 2f960052d284..d3c6690da873 100644 --- a/clang-tools-extra/test/loop-convert/dependency.cpp +++ b/clang-tools-extra/test/loop-convert/dependency.cpp @@ -1,5 +1,4 @@ -// RUN: rm -rf %t.cpp -// RUN: grep -Ev "//\s*[A-Z-]+:" %s > %t.cpp +// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp // RUN: loop-convert . %t.cpp -- && FileCheck -input-file=%t.cpp %s void f() { diff --git a/clang-tools-extra/test/loop-convert/iterator.cpp b/clang-tools-extra/test/loop-convert/iterator.cpp index 8f4102002d22..837764202c4e 100644 --- a/clang-tools-extra/test/loop-convert/iterator.cpp +++ b/clang-tools-extra/test/loop-convert/iterator.cpp @@ -1,9 +1,6 @@ -// RUN: rm -rf %t.cpp -// RUN: grep -Ev "//\s*[A-Z-]+:" %s > %t.cpp -// RUN: loop-convert . %t.cpp -- -I %S/Inputs \ -// RUN: && FileCheck -input-file=%t.cpp %s -// RUN: grep -Ev "//\s*[A-Z-]+:" %s > %t.cpp -// RUN: rm -rf %t.cpp +// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp +// RUN: loop-convert . %t.cpp -- -I %S/Inputs +// RUN: FileCheck -input-file=%t.cpp %s #include "structures.h" diff --git a/clang-tools-extra/test/loop-convert/naming.cpp b/clang-tools-extra/test/loop-convert/naming.cpp index 0bfef339c656..da270d4f8aaa 100644 --- a/clang-tools-extra/test/loop-convert/naming.cpp +++ b/clang-tools-extra/test/loop-convert/naming.cpp @@ -1,7 +1,6 @@ -// RUN: rm -rf %t.cpp -// RUN: grep -Ev "//\s*[A-Z-]+:" %s > %t.cpp -// RUN: loop-convert . %t.cpp -- -I %S/Inputs \ -// RUN: && FileCheck -input-file=%t.cpp %s +// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp +// RUN: loop-convert . %t.cpp -- -I %S/Inputs +// RUN: FileCheck -input-file=%t.cpp %s #include "structures.h" diff --git a/clang-tools-extra/test/loop-convert/negative-iterator.cpp b/clang-tools-extra/test/loop-convert/negative-iterator.cpp index 041bbee4f6d8..b48a1ee48d6e 100644 --- a/clang-tools-extra/test/loop-convert/negative-iterator.cpp +++ b/clang-tools-extra/test/loop-convert/negative-iterator.cpp @@ -1,7 +1,6 @@ -// RUN: rm -rf %t.cpp -// RUN: grep -Ev "//\s*[A-Z-]+:" %s > %t.cpp -// RUN: loop-convert . %t.cpp -- -I %S/Inputs \ -// RUN: && FileCheck -input-file=%t.cpp %s +// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp +// RUN: loop-convert . %t.cpp -- -I %S/Inputs +// RUN: FileCheck -input-file=%t.cpp %s #include "structures.h" diff --git a/clang-tools-extra/test/loop-convert/negative-multi-end-call.cpp b/clang-tools-extra/test/loop-convert/negative-multi-end-call.cpp index cc15ce56c0b9..c634fab96bb3 100644 --- a/clang-tools-extra/test/loop-convert/negative-multi-end-call.cpp +++ b/clang-tools-extra/test/loop-convert/negative-multi-end-call.cpp @@ -1,7 +1,6 @@ -// RUN: rm -rf %t.cpp -// RUN: grep -Ev "//\s*[A-Z-]+:" %s > %t.cpp -// RUN: loop-convert -A0 . %t.cpp -- -I %S/Inputs \ -// RUN: && FileCheck -input-file=%t.cpp %s +// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp +// RUN: loop-convert -A0 . %t.cpp -- -I %S/Inputs +// RUN: FileCheck -input-file=%t.cpp %s #include "structures.h" diff --git a/clang-tools-extra/test/loop-convert/negative-pseudoarray-extra.cpp b/clang-tools-extra/test/loop-convert/negative-pseudoarray-extra.cpp index 224a87bff169..0222af56f54e 100644 --- a/clang-tools-extra/test/loop-convert/negative-pseudoarray-extra.cpp +++ b/clang-tools-extra/test/loop-convert/negative-pseudoarray-extra.cpp @@ -1,7 +1,6 @@ -// RUN: rm -rf %t.cpp -// RUN: grep -Ev "//\s*[A-Z-]+:" %s > %t.cpp -// RUN: loop-convert -A1 . %t.cpp -- -I %S/Inputs \ -// RUN: && FileCheck -input-file=%t.cpp %s +// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp +// RUN: loop-convert -A1 . %t.cpp -- -I %S/Inputs +// RUN: FileCheck -input-file=%t.cpp %s #include "structures.h" diff --git a/clang-tools-extra/test/loop-convert/negative-pseudoarray.cpp b/clang-tools-extra/test/loop-convert/negative-pseudoarray.cpp index e5b3a1d44a10..af184f7d8abc 100644 --- a/clang-tools-extra/test/loop-convert/negative-pseudoarray.cpp +++ b/clang-tools-extra/test/loop-convert/negative-pseudoarray.cpp @@ -1,7 +1,6 @@ -// RUN: rm -rf %t.cpp -// RUN: grep -Ev "//\s*[A-Z-]+:" %s > %t.cpp -// RUN: loop-convert -A1 . %t.cpp -- -I %S/Inputs \ -// RUN: && FileCheck -input-file=%t.cpp %s +// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp +// RUN: loop-convert -A1 . %t.cpp -- -I %S/Inputs +// RUN: FileCheck -input-file=%t.cpp %s #include "structures.h" diff --git a/clang-tools-extra/test/loop-convert/negative.cpp b/clang-tools-extra/test/loop-convert/negative.cpp index 55975572c18d..9b284b45f9af 100644 --- a/clang-tools-extra/test/loop-convert/negative.cpp +++ b/clang-tools-extra/test/loop-convert/negative.cpp @@ -1,11 +1,9 @@ -// RUN: rm -rf %t.cpp -// RUN: grep -Ev "//\s*[A-Z-]+:" %s > %t.cpp -// RUN: grep -Ev "//\s*[A-Z-]+:" %S/Inputs/negative-header.h > \ +// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp +// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/negative-header.h > \ // RUN: %T/negative-header.h -// RUN: loop-convert . %t.cpp -- -I %S/Inputs/ \ -// RUN: && FileCheck -input-file=%t.cpp %s \ -// RUN: && FileCheck -input-file=%T/negative-header.h \ -// RUN: %S/Inputs/negative-header.h +// RUN: loop-convert . %t.cpp -- -I %S/Inputs/ +// RUN: FileCheck -input-file=%t.cpp %s +// RUN: FileCheck -input-file=%T/negative-header.h %S/Inputs/negative-header.h #include "negative-header.h" #include "structures.h" diff --git a/clang-tools-extra/test/loop-convert/nesting.cpp b/clang-tools-extra/test/loop-convert/nesting.cpp index 8e960a899dec..73f8173b0e79 100644 --- a/clang-tools-extra/test/loop-convert/nesting.cpp +++ b/clang-tools-extra/test/loop-convert/nesting.cpp @@ -1,7 +1,6 @@ -// RUN: rm -rf %t.cpp -// RUN: grep -Ev "//\s*[A-Z-]+:" %s > %t.cpp -// RUN: loop-convert . %t.cpp -- -I %S/Inputs \ -// RUN: && FileCheck -input-file=%t.cpp %s +// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp +// RUN: loop-convert . %t.cpp -- -I %S/Inputs +// RUN: FileCheck -input-file=%t.cpp %s #include "structures.h" diff --git a/clang-tools-extra/test/loop-convert/nocompile.cpp b/clang-tools-extra/test/loop-convert/nocompile.cpp index 32390102a8f7..e39cf896c1f0 100644 --- a/clang-tools-extra/test/loop-convert/nocompile.cpp +++ b/clang-tools-extra/test/loop-convert/nocompile.cpp @@ -1,8 +1,6 @@ -// RUN: rm -rf %t.cpp -// RUN: grep -Ev "//\s*[A-Z-]+:" %s > %t.cpp -// RUN: loop-convert . %t.cpp -- -I %S/Inputs \ -// RUN: || FileCheck -input-file=%t.cpp %s -// Note that this test expects the compilation to fail! +// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp +// RUN: not loop-convert . %t.cpp -- -I %S/Inputs +// RUN: FileCheck -input-file=%t.cpp %s void valid() { const int arr[5]; diff --git a/clang-tools-extra/test/loop-convert/pseudoarray.cpp b/clang-tools-extra/test/loop-convert/pseudoarray.cpp index b47616d02e44..13c19333acac 100644 --- a/clang-tools-extra/test/loop-convert/pseudoarray.cpp +++ b/clang-tools-extra/test/loop-convert/pseudoarray.cpp @@ -1,8 +1,6 @@ -// RUN: rm -rf %t.cpp -// RUN: grep -Ev "//\s*[A-Z-]+:" %s > %t.cpp -// RUN: loop-convert . %t.cpp -- -I %S/Inputs \ -// RUN: && FileCheck -input-file=%t.cpp %s -// RUN: rm -rf %t.cpp +// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp +// RUN: loop-convert . %t.cpp -- -I %S/Inputs +// RUN: FileCheck -input-file=%t.cpp %s #include "structures.h" const int N = 6; diff --git a/clang-tools-extra/test/loop-convert/single-iterator.cpp b/clang-tools-extra/test/loop-convert/single-iterator.cpp index 2359a3ac4126..9922225ab4ed 100644 --- a/clang-tools-extra/test/loop-convert/single-iterator.cpp +++ b/clang-tools-extra/test/loop-convert/single-iterator.cpp @@ -1,9 +1,6 @@ -// RUN: rm -rf %t.cpp -// RUN: grep -Ev "//\s*[A-Z-]+:" %s > %t.cpp -// RUN: loop-convert . %t.cpp -- -I %S/Inputs \ -// RUN: && FileCheck -input-file=%t.cpp %s -// RUN: grep -Ev "//\s*[A-Z-]+:" %s > %t.cpp -// RUN: rm -rf %t.cpp +// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp +// RUN: loop-convert . %t.cpp -- -I %S/Inputs +// RUN: FileCheck -input-file=%t.cpp %s #include "structures.h" diff --git a/clang-tools-extra/test/remove-cstr-calls/basic.cpp b/clang-tools-extra/test/remove-cstr-calls/basic.cpp index f0f5ed5b4ea1..d15746a0046c 100644 --- a/clang-tools-extra/test/remove-cstr-calls/basic.cpp +++ b/clang-tools-extra/test/remove-cstr-calls/basic.cpp @@ -1,7 +1,9 @@ -// RUN: echo '[{"directory":".","command":"clang++ -c %T/test.cpp","file":"%T/test.cpp"}]' > %T/compile_commands.json -// RUN: cp "%s" "%T/test.cpp" -// RUN: remove-cstr-calls "%T" "%T/test.cpp" -// RUN: cat "%T/test.cpp" | FileCheck %s +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c %t/test.cpp\",\"file\":\"%t/test.cpp\"}]" | sed -e 's/\\/\//g' > %t/compile_commands.json +// RUN: cp "%s" "%t/test.cpp" +// RUN: remove-cstr-calls "%t" "%t/test.cpp" +// RUN: cat "%t/test.cpp" | FileCheck %s // REQUIRES: shell // FIXME: implement a mode for refactoring tools that takes input from stdin // and writes output to stdout for easier testing of tools.