[clang] [clang-format] Add .clang-format.ignore for ignoring files (PR #76327)

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 26 01:33:05 PST 2023


================
@@ -0,0 +1,31 @@
+// RUN: rm -rf %t.dir
+// RUN: mkdir -p %t.dir/level1/level2
+
+// RUN: cd %t.dir
+// RUN: printf "%%s\n" "\*" "level*/*.c*" "*/*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: 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: 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: touch .clang-format-ignore
+// RUN: clang-format -verbose foo.c foo.js 2> %t.stderr
+// RUN: grep "Formatting \[1/2] foo.c" %t.stderr
+// RUN: grep "Formatting \[2/2] foo.js" %t.stderr
+
+// RUN: printf "%%s\n" "*.js" > .clang-format-ignore
----------------
owenca wrote:

```suggestion
// RUN: echo "*.js" > .clang-format-ignore
```

https://github.com/llvm/llvm-project/pull/76327


More information about the cfe-commits mailing list