Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang-format][NFC] Use FileCheck for clang-format-ignore lit test #77977

Merged
merged 1 commit into from
Jan 14, 2024

Conversation

owenca
Copy link
Contributor

@owenca owenca commented Jan 12, 2024

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Jan 12, 2024

@llvm/pr-subscribers-clang-format

Author: Owen Pan (owenca)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/77977.diff

1 Files Affected:

  • (modified) clang/test/Format/clang-format-ignore.cpp (+25-21)
diff --git a/clang/test/Format/clang-format-ignore.cpp b/clang/test/Format/clang-format-ignore.cpp
index 5a2267b302d22f..fb49fa9dd52c65 100644
--- a/clang/test/Format/clang-format-ignore.cpp
+++ b/clang/test/Format/clang-format-ignore.cpp
@@ -6,41 +6,45 @@
 // RUN: echo "level*/*.c*" >> .clang-format-ignore
 // RUN: echo "*/*2/foo.*" >> .clang-format-ignore
 // RUN: touch foo.cc
-// RUN: clang-format -verbose .clang-format-ignore foo.cc 2> %t.stderr
-// RUN: not grep Formatting %t.stderr
+// RUN: clang-format -verbose .clang-format-ignore foo.cc 2>&1 \
+// RUN:   | FileCheck %s -allow-empty
 
 // RUN: cd level1
 // RUN: touch bar.cc baz.c
-// RUN: clang-format -verbose bar.cc baz.c 2> %t.stderr
-// RUN: not grep Formatting %t.stderr
+// RUN: clang-format -verbose bar.cc baz.c 2>&1 | FileCheck %s -allow-empty
 
 // RUN: cd level2
 // RUN: touch foo.c foo.js
-// RUN: clang-format -verbose foo.c foo.js 2> %t.stderr
-// RUN: not grep Formatting %t.stderr
+// RUN: clang-format -verbose foo.c foo.js 2>&1 | FileCheck %s -allow-empty
+
+// CHECK-NOT: Formatting
 
 // RUN: touch .clang-format-ignore
-// RUN: clang-format -verbose foo.c foo.js 2> %t.stderr
-// RUN: grep -Fx "Formatting [1/2] foo.c" %t.stderr
-// RUN: grep -Fx "Formatting [2/2] foo.js" %t.stderr
+// RUN: clang-format -verbose foo.c foo.js 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK2 -match-full-lines
+// CHECK2: Formatting [1/2] foo.c
+// CHECK2-NEXT: Formatting [2/2] foo.js
 
 // RUN: echo "*.js" > .clang-format-ignore
-// RUN: clang-format -verbose foo.c foo.js 2> %t.stderr
-// RUN: grep -Fx "Formatting [1/2] foo.c" %t.stderr
-// RUN: not grep -F foo.js %t.stderr
+// RUN: clang-format -verbose foo.c foo.js 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK3 -match-full-lines
+// CHECK3: Formatting [1/2] foo.c
+// CHECK3-NOT: foo.js
 
 // RUN: cd ../..
-// RUN: clang-format -verbose *.cc level1/*.c* level1/level2/foo.* 2> %t.stderr
-// RUN: grep -x "Formatting \[1/5] .*foo\.c" %t.stderr
-// RUN: not grep -F foo.js %t.stderr
+// RUN: clang-format -verbose *.cc level1/*.c* level1/level2/foo.* 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK4 -match-full-lines
+// CHECK4: {{Formatting \[1/5] .*foo\.c}}
+// CHECK4-NOT: foo.js
 
 // RUN: rm .clang-format-ignore
-// RUN: clang-format -verbose *.cc level1/*.c* level1/level2/foo.* 2> %t.stderr
-// RUN: grep -x "Formatting \[1/5] .*foo\.cc" %t.stderr
-// RUN: grep -x "Formatting \[2/5] .*bar\.cc" %t.stderr
-// RUN: grep -x "Formatting \[3/5] .*baz\.c" %t.stderr
-// RUN: grep -x "Formatting \[4/5] .*foo\.c" %t.stderr
-// RUN: not grep -F foo.js %t.stderr
+// RUN: clang-format -verbose *.cc level1/*.c* level1/level2/foo.* 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK5 -match-full-lines
+// CHECK5: {{Formatting \[1/5] .*foo\.cc}}
+// CHECK5-NEXT: {{Formatting \[2/5] .*bar\.cc}}
+// CHECK5-NEXT: {{Formatting \[3/5] .*baz\.c}}
+// CHECK5-NEXT: {{Formatting \[4/5] .*foo\.c}}
+// CHECK5-NOT: foo.js
 
 // RUN: cd ..
 // RUN: rm -r %t.dir

@owenca owenca merged commit d3ac676 into llvm:main Jan 14, 2024
5 checks passed
@owenca owenca deleted the FileCheck branch January 14, 2024 09:41
justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this pull request Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants