Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-04-19 01:29:58 +0400
committerRussell Belfer <rb@github.com>2014-04-19 01:29:58 +0400
commite3a2a04ceff1d3657629fd6a7245d9a9fc53f24b (patch)
treefda2ccea16cfb9295ecad38ad16de9ec2eeee65e /tests/attr
parent50e46d6018ede64e3e4b177baa4ad8156d928fbd (diff)
Preload attribute files that may contain macros
There was a latent bug where files that use macro definitions could be parsed before the macro definitions were loaded. Because of attribute file caching, preloading files that are going to be used doesn't add a significant amount of overhead, so let's always preload any files that could contain macros before we assemble the actual vector of files to scan for attributes.
Diffstat (limited to 'tests/attr')
-rw-r--r--tests/attr/repo.c103
1 files changed, 64 insertions, 39 deletions
diff --git a/tests/attr/repo.c b/tests/attr/repo.c
index 71dc7a5b5..9aab7ed96 100644
--- a/tests/attr/repo.c
+++ b/tests/attr/repo.c
@@ -23,49 +23,74 @@ void test_attr_repo__cleanup(void)
g_repo = NULL;
}
+static struct attr_expected get_one_test_cases[] = {
+ { "root_test1", "repoattr", EXPECT_TRUE, NULL },
+ { "root_test1", "rootattr", EXPECT_TRUE, NULL },
+ { "root_test1", "missingattr", EXPECT_UNDEFINED, NULL },
+ { "root_test1", "subattr", EXPECT_UNDEFINED, NULL },
+ { "root_test1", "negattr", EXPECT_UNDEFINED, NULL },
+ { "root_test2", "repoattr", EXPECT_TRUE, NULL },
+ { "root_test2", "rootattr", EXPECT_FALSE, NULL },
+ { "root_test2", "missingattr", EXPECT_UNDEFINED, NULL },
+ { "root_test2", "multiattr", EXPECT_FALSE, NULL },
+ { "root_test3", "repoattr", EXPECT_TRUE, NULL },
+ { "root_test3", "rootattr", EXPECT_UNDEFINED, NULL },
+ { "root_test3", "multiattr", EXPECT_STRING, "3" },
+ { "root_test3", "multi2", EXPECT_UNDEFINED, NULL },
+ { "sub/subdir_test1", "repoattr", EXPECT_TRUE, NULL },
+ { "sub/subdir_test1", "rootattr", EXPECT_TRUE, NULL },
+ { "sub/subdir_test1", "missingattr", EXPECT_UNDEFINED, NULL },
+ { "sub/subdir_test1", "subattr", EXPECT_STRING, "yes" },
+ { "sub/subdir_test1", "negattr", EXPECT_FALSE, NULL },
+ { "sub/subdir_test1", "another", EXPECT_UNDEFINED, NULL },
+ { "sub/subdir_test2.txt", "repoattr", EXPECT_TRUE, NULL },
+ { "sub/subdir_test2.txt", "rootattr", EXPECT_TRUE, NULL },
+ { "sub/subdir_test2.txt", "missingattr", EXPECT_UNDEFINED, NULL },
+ { "sub/subdir_test2.txt", "subattr", EXPECT_STRING, "yes" },
+ { "sub/subdir_test2.txt", "negattr", EXPECT_FALSE, NULL },
+ { "sub/subdir_test2.txt", "another", EXPECT_STRING, "zero" },
+ { "sub/subdir_test2.txt", "reposub", EXPECT_TRUE, NULL },
+ { "sub/sub/subdir.txt", "another", EXPECT_STRING, "one" },
+ { "sub/sub/subdir.txt", "reposubsub", EXPECT_TRUE, NULL },
+ { "sub/sub/subdir.txt", "reposub", EXPECT_UNDEFINED, NULL },
+ { "does-not-exist", "foo", EXPECT_STRING, "yes" },
+ { "sub/deep/file", "deepdeep", EXPECT_TRUE, NULL },
+ { "sub/sub/d/no", "test", EXPECT_STRING, "a/b/d/*" },
+ { "sub/sub/d/yes", "test", EXPECT_UNDEFINED, NULL },
+};
+
void test_attr_repo__get_one(void)
{
- struct attr_expected test_cases[] = {
- { "root_test1", "repoattr", EXPECT_TRUE, NULL },
- { "root_test1", "rootattr", EXPECT_TRUE, NULL },
- { "root_test1", "missingattr", EXPECT_UNDEFINED, NULL },
- { "root_test1", "subattr", EXPECT_UNDEFINED, NULL },
- { "root_test1", "negattr", EXPECT_UNDEFINED, NULL },
- { "root_test2", "repoattr", EXPECT_TRUE, NULL },
- { "root_test2", "rootattr", EXPECT_FALSE, NULL },
- { "root_test2", "missingattr", EXPECT_UNDEFINED, NULL },
- { "root_test2", "multiattr", EXPECT_FALSE, NULL },
- { "root_test3", "repoattr", EXPECT_TRUE, NULL },
- { "root_test3", "rootattr", EXPECT_UNDEFINED, NULL },
- { "root_test3", "multiattr", EXPECT_STRING, "3" },
- { "root_test3", "multi2", EXPECT_UNDEFINED, NULL },
- { "sub/subdir_test1", "repoattr", EXPECT_TRUE, NULL },
- { "sub/subdir_test1", "rootattr", EXPECT_TRUE, NULL },
- { "sub/subdir_test1", "missingattr", EXPECT_UNDEFINED, NULL },
- { "sub/subdir_test1", "subattr", EXPECT_STRING, "yes" },
- { "sub/subdir_test1", "negattr", EXPECT_FALSE, NULL },
- { "sub/subdir_test1", "another", EXPECT_UNDEFINED, NULL },
- { "sub/subdir_test2.txt", "repoattr", EXPECT_TRUE, NULL },
- { "sub/subdir_test2.txt", "rootattr", EXPECT_TRUE, NULL },
- { "sub/subdir_test2.txt", "missingattr", EXPECT_UNDEFINED, NULL },
- { "sub/subdir_test2.txt", "subattr", EXPECT_STRING, "yes" },
- { "sub/subdir_test2.txt", "negattr", EXPECT_FALSE, NULL },
- { "sub/subdir_test2.txt", "another", EXPECT_STRING, "zero" },
- { "sub/subdir_test2.txt", "reposub", EXPECT_TRUE, NULL },
- { "sub/sub/subdir.txt", "another", EXPECT_STRING, "one" },
- { "sub/sub/subdir.txt", "reposubsub", EXPECT_TRUE, NULL },
- { "sub/sub/subdir.txt", "reposub", EXPECT_UNDEFINED, NULL },
- { "does-not-exist", "foo", EXPECT_STRING, "yes" },
- { "sub/deep/file", "deepdeep", EXPECT_TRUE, NULL },
- { "sub/sub/d/no", "test", EXPECT_STRING, "a/b/d/*" },
- { "sub/sub/d/yes", "test", EXPECT_UNDEFINED, NULL },
- { NULL, NULL, 0, NULL }
- }, *scan;
-
- for (scan = test_cases; scan->path != NULL; scan++) {
+ int i;
+
+ for (i = 0; i < (int)ARRAY_SIZE(get_one_test_cases); ++i) {
+ struct attr_expected *scan = &get_one_test_cases[i];
+ const char *value;
+
+ cl_git_pass(git_attr_get(&value, g_repo, 0, scan->path, scan->attr));
+ attr_check_expected(
+ scan->expected, scan->expected_str, scan->attr, value);
+ }
+
+ cl_assert(git_attr_cache__is_cached(
+ g_repo, GIT_ATTR_FILE__FROM_FILE, ".git/info/attributes"));
+ cl_assert(git_attr_cache__is_cached(
+ g_repo, GIT_ATTR_FILE__FROM_FILE, ".gitattributes"));
+ cl_assert(git_attr_cache__is_cached(
+ g_repo, GIT_ATTR_FILE__FROM_FILE, "sub/.gitattributes"));
+}
+
+void test_attr_repo__get_one_start_deep(void)
+{
+ int i;
+
+ for (i = (int)ARRAY_SIZE(get_one_test_cases) - 1; i >= 0; --i) {
+ struct attr_expected *scan = &get_one_test_cases[i];
const char *value;
+
cl_git_pass(git_attr_get(&value, g_repo, 0, scan->path, scan->attr));
- attr_check_expected(scan->expected, scan->expected_str, scan->attr, value);
+ attr_check_expected(
+ scan->expected, scan->expected_str, scan->attr, value);
}
cl_assert(git_attr_cache__is_cached(