================
@@ -164,6 +164,40 @@ TEST_F(MatchFilePathTest, Path) {
EXPECT_FALSE(match("foo\\", R"(foo*\)"));
}
+TEST_F(MatchFilePathTest, DoubleAsterisk) {
+ EXPECT_TRUE(match("a/b/c/d.cpp", "**b**"));
+ EXPECT_TRUE(match("a/b/c/d.cpp", "**/b/**"));
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "**d_*"));
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "**/d_*"));
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "**d_**"));
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "**/d_**"));
+
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "**/b/c/**"));
+
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "a/**/b/c/d_e.cpp"));
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "a/**/c/d_e.cpp"));
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "a/**/b/**/d_e.cpp"));
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "**/b/**/d_e.cpp"));
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "a/**/**/b/**"));
+
+ EXPECT_FALSE(match("a/b/c/d_e.cpp", "**/d"));
+ EXPECT_FALSE(match("a/b/c/d_e.cpp", "**/b/d"));
+ EXPECT_FALSE(match("a/b/c/d_e.cpp", "**/b/d/**"));
+ EXPECT_FALSE(match("a/b/c/d_e.cpp", "**/b/c/"));
+
+ // Multiple consecutive asterisks are treated as **
+ EXPECT_TRUE(match("a/b/c/d.cpp", "***b****"));
+ EXPECT_TRUE(match("a/b/c/d.cpp", "****/b/***"));
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "***d_**"));
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "****/d_*"));
+ EXPECT_TRUE(match("a/b/c/d_e.cpp", "***/b/c/*****"));
+
+ EXPECT_FALSE(match("a/b/c/d_e.cpp", "*****/d"));
+ EXPECT_FALSE(match("a/b/c/d_e.cpp", "***/b/d"));
+ EXPECT_FALSE(match("a/b/c/d_e.cpp", "*****/b/d/***"));
+ EXPECT_FALSE(match("a/b/c/d_e.cpp", "***/b/c"));
----------------
ameerj wrote:
> How did you manage before clang-format gained the .clang-format-ignore
> functionality?
PAL has not used clang-format at all, my contributions have been an effort to
support the PAL formatting style so we can start to use the tool.
> > * Simplifying Subdirectory Exclusion: `**` allows for easy exclusion of
> > entire subdirectories. Currently you need to specify each depth level in a
> > subdirectory individually.
>
> We have `DisableFormat` for that.
I was not aware of `DisableFormat`, it's not as intuitive as having everything
in the ignore file but it can be a compromise if you're completely opposed to
adding the `**` change.
> > * Pattern-Based File Ignoring: `**` simplifies ignoring specific file
> > patterns that may appear at any level within a directory tree, which is
> > especially useful when the exact depth of these files can vary
>
> I was conscious of this use case, but you can do something like `find . -name
> dont-format-me >> .clang-format-ignore` even though it's less than ideal.
Like you said, this is not ideal as it relies on anyone adding/moving files
that may need to be ignored to regenerate the clang-format-ignore file.
`**` could handle these cases without a need for manual intervention.
> If we were to add `**` to match gitignore, we should also handle it at the
> beginning and the end of a pathname.
Are you seeing a gap in the unit tests I have? I think I have these cases
covered but can add more specific unit tests if you have an example.
https://github.com/llvm/llvm-project/pull/110560
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits