[clang] [clang-format] Support globstar in .clang-format-ignore (PR #121404)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 31 17:31:23 PST 2024
================
@@ -164,6 +164,41 @@ TEST_F(MatchFilePathTest, Path) {
EXPECT_FALSE(match("foo\\", R"(foo*\)"));
}
+TEST_F(MatchFilePathTest, Globstar) {
+ EXPECT_TRUE(match("/", "**"));
+ EXPECT_TRUE(match("foo", "**"));
+ EXPECT_TRUE(match("/foo", "**"));
+ EXPECT_TRUE(match("foo/", "**"));
+ EXPECT_TRUE(match("foo/bar", "**"));
+
+ EXPECT_TRUE(match("/", "**/"));
+ EXPECT_TRUE(match("foo/", "**/"));
+ EXPECT_TRUE(match("/foo/", "**/"));
+ EXPECT_TRUE(match("foo/bar/", "**/"));
+
+ EXPECT_TRUE(match("/", "/**"));
+ EXPECT_TRUE(match("/foo", "/**"));
+ EXPECT_TRUE(match("/foo/", "/**"));
+ EXPECT_TRUE(match("/foo/bar", "/**"));
+
+ EXPECT_TRUE(match("foo", "**/foo"));
+ EXPECT_TRUE(match("/foo", "**/foo"));
+ EXPECT_TRUE(match("foo/bar", "**/bar"));
+ EXPECT_TRUE(match("/foo/bar", "**/foo/bar"));
+ EXPECT_TRUE(match("foo/bar/baz", "**/bar/baz"));
+
+ EXPECT_TRUE(match("abc/foo", "abc/**"));
+ EXPECT_TRUE(match("abc/foo/", "abc/**"));
+ EXPECT_TRUE(match("abc/foo/bar", "abc/**"));
+
+ EXPECT_TRUE(match("a/b", "a/**/b"));
+ EXPECT_TRUE(match("a/x/b", "a/**/b"));
+ EXPECT_TRUE(match("a/x/y/b", "a/**/b"));
+
+ EXPECT_FALSE(match("a/x/b", "a**/b"));
+ EXPECT_FALSE(match("a/x/y/b", "a/**b"));
----------------
leijurv wrote:
This leaves me curious what `a/**b` should match, such as `a/x/b`, `a/b`, `a/xb`, `a/x/yb`?
https://github.com/llvm/llvm-project/pull/121404
More information about the cfe-commits
mailing list