attr tests: make explicit our dir/file match tests
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
diff --git a/tests/attr/ignore.c b/tests/attr/ignore.c
index a55b123..27fed25 100644
--- a/tests/attr/ignore.c
+++ b/tests/attr/ignore.c
@@ -207,7 +207,6 @@ void test_attr_ignore__gitignore_in_subdir(void)
assert_is_ignored(false, "dir1/file");
assert_is_ignored(false, "dir1/dir2/file");
assert_is_ignored(false, "dir1/dir2/dir3/file");
- assert_is_ignored(false, "dir1/dir2/dir3/dir1");
assert_is_ignored(true, "dir1/dir2/dir3/dir1/file");
assert_is_ignored(true, "dir1/dir2/dir3/dir1/subdir/foo");
@@ -217,26 +216,39 @@ void test_attr_ignore__gitignore_in_subdir(void)
assert_is_ignored(false, "dir1/file");
assert_is_ignored(false, "dir1/dir2/file");
assert_is_ignored(false, "dir1/dir2/dir3/file");
- assert_is_ignored(false, "dir1/dir2/dir3/dir1");
assert_is_ignored(true, "dir1/dir2/dir3/dir1/file");
assert_is_ignored(true, "dir1/dir2/dir3/dir1/subdir/foo");
}
}
-void test_attr_ignore__depth_file_not_ignored_when_folder_specified(void)
+/* Ensure that files do not match folder cases */
+void test_attr_ignore__dont_ignore_files_for_folder(void)
{
cl_git_rmfile("attr/.gitignore");
- cl_must_pass(p_mkdir("attr/dir1", 0777));
- cl_must_pass(p_mkdir("attr/dir1/dir2", 0777));
- cl_must_pass(p_mkdir("attr/dir1/dir2/dir3", 0777));
+ cl_git_mkfile("attr/dir/.gitignore", "test/\n");
- cl_git_mkfile("attr/dir1/dir2/dir3/.gitignore", "dir1/\n");
+ /* Create "test" as a file; ensure it is not ignored. */
+ cl_git_mkfile("attr/dir/test", "This is a file.");
- assert_is_ignored(false, "dir1/dir2/dir3/dir1");
+ assert_is_ignored(false, "dir/test");
+ if (cl_repo_get_bool(g_repo, "core.ignorecase"))
+ assert_is_ignored(false, "dir/TeSt");
- if (cl_repo_get_bool(g_repo, "core.ignorecase")) {
- assert_is_ignored(false, "dir1/dir2/dir3/DiR1");
- }
-}
+ /* Create "test" as a directory; ensure it is ignored. */
+ cl_git_rmfile("attr/dir/test");
+ cl_must_pass(p_mkdir("attr/dir/test", 0777));
+
+ assert_is_ignored(true, "dir/test");
+ if (cl_repo_get_bool(g_repo, "core.ignorecase"))
+ assert_is_ignored(true, "dir/TeSt");
+ /* Remove "test" entirely; ensure it is not ignored.
+ * (As it doesn't exist, it is not a directory.)
+ */
+ cl_must_pass(p_rmdir("attr/dir/test"));
+
+ assert_is_ignored(false, "dir/test");
+ if (cl_repo_get_bool(g_repo, "core.ignorecase"))
+ assert_is_ignored(false, "dir/TeSt");
+}