]> granicus.if.org Git - clang/commitdiff
clang-format: Use pipes instead of temporary files for most lit tests.
authorNico Weber <nicolasweber@gmx.de>
Mon, 19 Oct 2015 16:21:29 +0000 (16:21 +0000)
committerNico Weber <nicolasweber@gmx.de>
Mon, 19 Oct 2015 16:21:29 +0000 (16:21 +0000)
This makes the format tests look more like most other FileCheck tests in clang.

The multiple-inputs tests still use temp files, to make sure that the file
input code in clang-format stays tested.

Stop stripping out the comment lines in style-on-command-line.cpp as they don't
get in the way and it makes the test simpler. Also remove 2>&1s on the tests in
that file that don't need it.

http://reviews.llvm.org/D13852

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250706 91177308-0d34-0410-b5e6-96231b3b80d8

test/Format/basic.cpp
test/Format/cursor.cpp
test/Format/disable-format.cpp
test/Format/incomplete.cpp
test/Format/language-detection.cpp
test/Format/line-ranges.cpp
test/Format/ranges.cpp
test/Format/style-on-command-line.cpp
test/Format/xmloutput.cpp

index a12866b9c1e41f3456b6009be89d8e4b998eb19f..e92291d04d4c1bb7e2754bae1927a3f7ee4f2b87 100644 (file)
@@ -1,6 +1,5 @@
-// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
-// RUN: clang-format -style=LLVM -i %t.cpp
-// RUN: FileCheck -strict-whitespace -input-file=%t.cpp %s
+// RUN: grep -Ev "// *[A-Z-]+:" %s | clang-format -style=LLVM \
+// RUN:   | FileCheck -strict-whitespace %s
 
 // CHECK: {{^int\ \*i;}}
  int   *  i  ;
index c7d576ba6e6442a5ff81affb23a8cafc3d55408d..b0a2fbdffc3281935130e3adf7c081a408c2881e 100644 (file)
@@ -1,6 +1,5 @@
-// RUN: grep -Ev "// *[A-Z-]+:" %s > %t2.cpp
-// RUN: clang-format -style=LLVM %t2.cpp -cursor=6 > %t.cpp
-// RUN: FileCheck -strict-whitespace -input-file=%t.cpp %s
+// RUN: grep -Ev "// *[A-Z-]+:" %s | clang-format -style=LLVM -cursor=6 \
+// RUN:   | FileCheck -strict-whitespace %s
 // CHECK: {{^\{ "Cursor": 4, }}
 // CHECK: {{^int\ \i;$}}
  int    i;
index 59484b3df16d221b8654ca089b9dabc686cfabf5..a1e8cd150887b38566e64fa8775629529838e80b 100644 (file)
@@ -1,6 +1,5 @@
-// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
-// RUN: clang-format -style=none -i %t.cpp
-// RUN: FileCheck -strict-whitespace -input-file=%t.cpp %s
+// RUN: grep -Ev "// *[A-Z-]+:" %s | clang-format -style=none \
+// RUN:   | FileCheck -strict-whitespace %s
 
 // CHECK: int   i;
 int   i;
index bd2c74ca3c17afd140f2e8ea07475cbed716b41d..8a65fad657cd76c633a4e88ffc822e103f75df86 100644 (file)
@@ -1,6 +1,5 @@
-// RUN: grep -Ev "// *[A-Z-]+:" %s > %t2.cpp
-// RUN: clang-format -style=LLVM %t2.cpp -cursor=0 > %t.cpp
-// RUN: FileCheck -strict-whitespace -input-file=%t.cpp %s
+// RUN: grep -Ev "// *[A-Z-]+:" %s | clang-format -style=LLVM -cursor=0 \
+// RUN:   | FileCheck -strict-whitespace %s
 // CHECK: {{"IncompleteFormat": true}}
 // CHECK: {{^int\ \i;$}}
  int    i;
index bec444dc9ddafc3dd411da3bfc22f7778c35a05b..2a53be71dafa108a9f3555573b0b5f32bce3ebc4 100644 (file)
@@ -1,7 +1,9 @@
-// RUN: grep -Ev "// *[A-Z0-9_]+:" %s > %t.js
-// RUN: grep -Ev "// *[A-Z0-9_]+:" %s > %t.cpp
-// RUN: clang-format -style=llvm %t.js | FileCheck -strict-whitespace -check-prefix=CHECK1 %s
-// RUN: clang-format -style=llvm %t.cpp | FileCheck -strict-whitespace -check-prefix=CHECK2 %s
+// RUN: grep -Ev "// *[A-Z0-9_]+:" %s \
+// RUN:   | clang-format -style=llvm -assume-filename=foo.js \
+// RUN:   | FileCheck -strict-whitespace -check-prefix=CHECK1 %s
+// RUN: grep -Ev "// *[A-Z0-9_]+:" %s \
+// RUN:   | clang-format -style=llvm -assume-filename=foo.cpp \
+// RUN:   | FileCheck -strict-whitespace -check-prefix=CHECK2 %s
 // CHECK1: {{^a >>>= b;$}}
 // CHECK2: {{^a >> >= b;$}}
 a >>>= b;
index 370445aed1e1dadaff897f29b4187841f2dfae82..9099022b428c30b27b7520edb36ee202f8ed6e27 100644 (file)
@@ -1,6 +1,6 @@
-// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
-// RUN: clang-format -style=LLVM -lines=1:1 -lines=5:5 -i %t.cpp
-// RUN: FileCheck -strict-whitespace -input-file=%t.cpp %s
+// RUN: grep -Ev "// *[A-Z-]+:" %s \
+// RUN:   | clang-format -style=LLVM -lines=1:1 -lines=5:5 \
+// RUN:   | FileCheck -strict-whitespace %s
 // CHECK: {{^int\ \*i;$}}
   int*i;
 
index c7fdd4b97a43e2733575c4fbcf37c110914d7c9e..ace528a9166ce57b8f21cdf315fafaf33def9b2c 100644 (file)
@@ -1,6 +1,6 @@
-// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
-// RUN: clang-format -style=LLVM -offset=2 -length=0 -offset=28 -length=0 -i %t.cpp
-// RUN: FileCheck -strict-whitespace -input-file=%t.cpp %s
+// RUN: grep -Ev "// *[A-Z-]+:" %s \
+// RUN:   | clang-format -style=LLVM -offset=2 -length=0 -offset=28 -length=0 \
+// RUN:   | FileCheck -strict-whitespace %s
 // CHECK: {{^int\ \*i;$}}
   int*i;
 
index 3f4f77ad0c31ff48be720f2336b33bcb77241f8e..08da60a988d163062542882982a81aba183010dc 100644 (file)
@@ -1,17 +1,16 @@
-// RUN: grep -Ev "// *[A-Z0-9_]+:" %s > %t.cpp
-// RUN: clang-format -style="{BasedOnStyle: Google, IndentWidth: 8}" %t.cpp | FileCheck -strict-whitespace -check-prefix=CHECK1 %s
-// RUN: clang-format -style="{BasedOnStyle: LLVM, IndentWidth: 7}" %t.cpp | FileCheck -strict-whitespace -check-prefix=CHECK2 %s
-// RUN: clang-format -style="{BasedOnStyle: invalid, IndentWidth: 7}" -fallback-style=LLVM %t.cpp 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK3 %s
-// RUN: clang-format -style="{lsjd}" %t.cpp -fallback-style=LLVM 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK4 %s
+// RUN: clang-format -style="{BasedOnStyle: Google, IndentWidth: 8}" %s | FileCheck -strict-whitespace -check-prefix=CHECK1 %s
+// RUN: clang-format -style="{BasedOnStyle: LLVM, IndentWidth: 7}" %s | FileCheck -strict-whitespace -check-prefix=CHECK2 %s
+// RUN: clang-format -style="{BasedOnStyle: invalid, IndentWidth: 7}" -fallback-style=LLVM %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK3 %s
+// RUN: clang-format -style="{lsjd}" %s -fallback-style=LLVM 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK4 %s
 // RUN: printf "BasedOnStyle: google\nIndentWidth: 5\n" > %T/.clang-format
-// RUN: clang-format -style=file %t.cpp 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK5 %s
+// RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s | FileCheck -strict-whitespace -check-prefix=CHECK5 %s
 // RUN: printf "\n" > %T/.clang-format
-// RUN: clang-format -style=file -fallback-style=webkit %t.cpp 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK6 %s
+// RUN: clang-format -style=file -fallback-style=webkit -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK6 %s
 // RUN: rm %T/.clang-format
 // RUN: printf "BasedOnStyle: google\nIndentWidth: 6\n" > %T/_clang-format
-// RUN: clang-format -style=file %t.cpp 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK7 %s
-// RUN: clang-format -style="{BasedOnStyle: LLVM, PointerBindsToType: true}" %t.cpp | FileCheck -strict-whitespace -check-prefix=CHECK8 %s
-// RUN: clang-format -style="{BasedOnStyle: WebKit, PointerBindsToType: false}" %t.cpp | FileCheck -strict-whitespace -check-prefix=CHECK9 %s
+// RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s | FileCheck -strict-whitespace -check-prefix=CHECK7 %s
+// RUN: clang-format -style="{BasedOnStyle: LLVM, PointerBindsToType: true}" %s | FileCheck -strict-whitespace -check-prefix=CHECK8 %s
+// RUN: clang-format -style="{BasedOnStyle: WebKit, PointerBindsToType: false}" %s | FileCheck -strict-whitespace -check-prefix=CHECK9 %s
 void f() {
 // CHECK1: {{^        int\* i;$}}
 // CHECK2: {{^       int \*i;$}}
index d3c5254fc3146451693c108b8c56441368a0be8b..3d84a2f5e4c29bbd8015c41d8358bae214d25883 100644 (file)
@@ -1,5 +1,5 @@
-// RUN: clang-format -output-replacements-xml -sort-includes %s > %t.xml
-// RUN: FileCheck -strict-whitespace -input-file=%t.xml %s
+// RUN: clang-format -output-replacements-xml -sort-includes %s \
+// RUN:   | FileCheck -strict-whitespace %s
 
 // CHECK: <?xml
 // CHECK-NEXT: {{<replacements.*incomplete_format='false'}}