diff options
| author | Russell Belfer <arrbee@arrbee.com> | 2012-02-01 12:30:35 -0800 |
|---|---|---|
| committer | Russell Belfer <arrbee@arrbee.com> | 2012-02-01 12:30:35 -0800 |
| commit | e8c96ed2a74a4fcd9789721b4ebfd78586b3a16f (patch) | |
| tree | 9cb7c7a096c76c8b0ec05289c42ffff2baef042c /tests-clar | |
| parent | 62a1f713de384e141045facf3c1a53d9642e8eb5 (diff) | |
| download | libgit2-e8c96ed2a74a4fcd9789721b4ebfd78586b3a16f.tar.gz | |
Add unit tests for recent bug fixes
Add unit tests to confirm ignore directory pattern matches and
to confirm that ignore and attribute files are loaded properly
into the attribute file cache.
Diffstat (limited to 'tests-clar')
| -rw-r--r-- | tests-clar/attr/repo.c | 5 | ||||
| -rw-r--r-- | tests-clar/status/ignore.c | 12 |
2 files changed, 17 insertions, 0 deletions
diff --git a/tests-clar/attr/repo.c b/tests-clar/attr/repo.c index 6fc36d2b..7a716042 100644 --- a/tests-clar/attr/repo.c +++ b/tests-clar/attr/repo.c @@ -1,6 +1,7 @@ #include "clar_libgit2.h" #include "fileops.h" #include "git2/attr.h" +#include "attr.h" static git_repository *g_repo = NULL; @@ -89,6 +90,10 @@ void test_attr_repo__get_one(void) git_buf_free(&b); } + + cl_git_pass(git_attr_cache__is_cached(g_repo, ".git/info/attributes")); + cl_git_pass(git_attr_cache__is_cached(g_repo, ".gitattributes")); + cl_git_pass(git_attr_cache__is_cached(g_repo, "sub/.gitattributes")); } void test_attr_repo__get_many(void) diff --git a/tests-clar/status/ignore.c b/tests-clar/status/ignore.c index 3a66b3a7..67aecba3 100644 --- a/tests-clar/status/ignore.c +++ b/tests-clar/status/ignore.c @@ -1,6 +1,7 @@ #include "clar_libgit2.h" #include "fileops.h" #include "git2/attr.h" +#include "attr.h" static git_repository *g_repo = NULL; @@ -29,6 +30,7 @@ void test_status_ignore__0(void) const char *path; int expected; } test_cases[] = { + /* patterns "sub" and "ign" from .gitignore */ { "file", 0 }, { "ign", 1 }, { "sub", 1 }, @@ -38,6 +40,12 @@ void test_status_ignore__0(void) { "sub/sub/file", 0 }, { "sub/sub/ign", 1 }, { "sub/sub/sub", 1 }, + /* pattern "dir/" from .gitignore */ + { "dir", 1 }, + { "dir/", 1 }, + { "sub/dir", 1 }, + { "sub/dir/", 1 }, + { "sub/sub/dir", 0 }, /* dir is not actually a dir, but a file */ { NULL, 0 } }, *one_test; @@ -46,4 +54,8 @@ void test_status_ignore__0(void) cl_git_pass(git_status_should_ignore(g_repo, one_test->path, &ignored)); cl_assert_(ignored == one_test->expected, one_test->path); } + + /* confirm that ignore files were cached */ + cl_git_pass(git_attr_cache__is_cached(g_repo, ".git/info/exclude")); + cl_git_pass(git_attr_cache__is_cached(g_repo, ".gitignore")); } |
