summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-05-04 11:16:52 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2015-05-04 11:16:52 +0200
commitcfc2e56d59db3d0d2b58aeffc4ef4640b7f846b5 (patch)
treec701b88b8d94a83b9961040d68517ab348aa009b /tests
parent72f8da9175c823036077445915309e250d802b3b (diff)
parentbe3f104967ad21e949f72ef10a6b5ec00795ffaa (diff)
downloadlibgit2-cfc2e56d59db3d0d2b58aeffc4ef4640b7f846b5.tar.gz
Merge pull request #3087 from ethomson/pr/3054
Performance Improvements to Status on Windows
Diffstat (limited to 'tests')
-rw-r--r--tests/attr/lookup.c6
-rw-r--r--tests/core/dirent.c59
-rw-r--r--tests/diff/drivers.c2
3 files changed, 54 insertions, 13 deletions
diff --git a/tests/attr/lookup.c b/tests/attr/lookup.c
index 030ea075d..71e87cbae 100644
--- a/tests/attr/lookup.c
+++ b/tests/attr/lookup.c
@@ -13,7 +13,7 @@ void test_attr_lookup__simple(void)
cl_assert_equal_s(cl_fixture("attr/attr0"), file->entry->path);
cl_assert(file->rules.length == 1);
- cl_git_pass(git_attr_path__init(&path, "test", NULL));
+ cl_git_pass(git_attr_path__init(&path, "test", NULL, GIT_DIR_FLAG_UNKNOWN));
cl_assert_equal_s("test", path.path);
cl_assert_equal_s("test", path.basename);
cl_assert(!path.is_dir);
@@ -36,7 +36,7 @@ static void run_test_cases(git_attr_file *file, struct attr_expected *cases, int
int error;
for (c = cases; c->path != NULL; c++) {
- cl_git_pass(git_attr_path__init(&path, c->path, NULL));
+ cl_git_pass(git_attr_path__init(&path, c->path, NULL, GIT_DIR_FLAG_UNKNOWN));
if (force_dir)
path.is_dir = 1;
@@ -133,7 +133,7 @@ void test_attr_lookup__match_variants(void)
cl_assert_equal_s(cl_fixture("attr/attr1"), file->entry->path);
cl_assert(file->rules.length == 10);
- cl_git_pass(git_attr_path__init(&path, "/testing/for/pat0", NULL));
+ cl_git_pass(git_attr_path__init(&path, "/testing/for/pat0", NULL, GIT_DIR_FLAG_UNKNOWN));
cl_assert_equal_s("pat0", path.basename);
run_test_cases(file, cases, 0);
diff --git a/tests/core/dirent.c b/tests/core/dirent.c
index f17260362..d95e44196 100644
--- a/tests/core/dirent.c
+++ b/tests/core/dirent.c
@@ -67,10 +67,23 @@ static void check_counts(walk_data *d)
}
}
+static int update_count(name_data *data, const char *name)
+{
+ name_data *n;
+
+ for (n = data; n->name; n++) {
+ if (!strcmp(n->name, name)) {
+ n->count++;
+ return 0;
+ }
+ }
+
+ return GIT_ERROR;
+}
+
static int one_entry(void *state, git_buf *path)
{
walk_data *d = (walk_data *) state;
- name_data *n;
if (state != state_loc)
return GIT_ERROR;
@@ -78,14 +91,7 @@ static int one_entry(void *state, git_buf *path)
if (path != &d->path)
return GIT_ERROR;
- for (n = d->names; n->name; n++) {
- if (!strcmp(n->name, path->ptr)) {
- n->count++;
- return 0;
- }
- }
-
- return GIT_ERROR;
+ return update_count(d->names, path->ptr);
}
@@ -234,3 +240,38 @@ void test_core_dirent__empty_dir(void)
cl_must_pass(p_rmdir("empty_dir"));
}
+
+static void handle_next(git_path_diriter *diriter, walk_data *walk)
+{
+ const char *fullpath, *filename;
+ size_t fullpath_len, filename_len;
+
+ cl_git_pass(git_path_diriter_fullpath(&fullpath, &fullpath_len, diriter));
+ cl_git_pass(git_path_diriter_filename(&filename, &filename_len, diriter));
+
+ cl_assert_equal_strn(fullpath, "sub/", 4);
+ cl_assert_equal_s(fullpath+4, filename);
+
+ update_count(walk->names, fullpath);
+}
+
+/* test directory iterator */
+void test_core_dirent__diriter_with_fullname(void)
+{
+ git_path_diriter diriter = GIT_PATH_DIRITER_INIT;
+ int error;
+
+ cl_set_cleanup(&dirent_cleanup__cb, &sub);
+ setup(&sub);
+
+ cl_git_pass(git_path_diriter_init(&diriter, sub.path.ptr, 0));
+
+ while ((error = git_path_diriter_next(&diriter)) == 0)
+ handle_next(&diriter, &sub);
+
+ cl_assert_equal_i(error, GIT_ITEROVER);
+
+ git_path_diriter_free(&diriter);
+
+ check_counts(&sub);
+}
diff --git a/tests/diff/drivers.c b/tests/diff/drivers.c
index 8b12368ea..e3a0014db 100644
--- a/tests/diff/drivers.c
+++ b/tests/diff/drivers.c
@@ -186,7 +186,7 @@ void test_diff_drivers__builtins(void)
g_repo = cl_git_sandbox_init("userdiff");
- cl_git_pass(git_path_dirload("userdiff/files", 9, 0, 0, &files));
+ cl_git_pass(git_path_dirload(&files, "userdiff/files", 9, 0));
opts.interhunk_lines = 1;
opts.context_lines = 1;