summaryrefslogtreecommitdiff
path: root/tests/submodule/submodule_helpers.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-04-01 16:46:25 -0700
committerRussell Belfer <rb@github.com>2014-04-01 16:46:25 -0700
commit8f4e5275e4f7f287b6782e70ff96c5de8fa4059e (patch)
treef824e2dd961803f2f620b294f98c82233de5fd8c /tests/submodule/submodule_helpers.c
parent8061d519b33c95a8858752e7d70d40fe8bae90f9 (diff)
downloadlibgit2-8f4e5275e4f7f287b6782e70ff96c5de8fa4059e.tar.gz
More tests and fix submodule index refresh
There was a little bug where the submodule cache thought that the index date was out of date even when it wasn't that was resulting in some extra scans of index data even when not needed. Mostly this commit adds a bunch of new tests including adding and removing submodules in the index and in the HEAD and seeing if we can automatically pick them up when refreshing.
Diffstat (limited to 'tests/submodule/submodule_helpers.c')
-rw-r--r--tests/submodule/submodule_helpers.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/tests/submodule/submodule_helpers.c b/tests/submodule/submodule_helpers.c
index 546f0913a..50aa97568 100644
--- a/tests/submodule/submodule_helpers.c
+++ b/tests/submodule/submodule_helpers.c
@@ -126,20 +126,26 @@ git_repository *setup_fixture_submod2(void)
return repo;
}
-void assert_submodule_exists(git_repository *repo, const char *name)
+void assert__submodule_exists(
+ git_repository *repo, const char *name,
+ const char *msg, const char *file, int line)
{
git_submodule *sm;
- cl_git_pass(git_submodule_lookup(&sm, repo, name));
- cl_assert(sm);
+ int error = git_submodule_lookup(&sm, repo, name);
+ if (error)
+ cl_git_report_failure(error, file, line, msg);
+ cl_assert_at_line(sm != NULL, file, line);
git_submodule_free(sm);
}
-void refute_submodule_exists(
- git_repository *repo, const char *name, int expected_error)
+void refute__submodule_exists(
+ git_repository *repo, const char *name, int expected_error,
+ const char *msg, const char *file, int line)
{
git_submodule *sm;
- cl_assert_equal_i(
- expected_error, git_submodule_lookup(&sm, repo, name));
+ clar__assert_equal(
+ file, line, msg, 1, "%i",
+ expected_error, (int)(git_submodule_lookup(&sm, repo, name)));
}
unsigned int get_submodule_status(git_repository *repo, const char *name)
@@ -154,3 +160,19 @@ unsigned int get_submodule_status(git_repository *repo, const char *name)
return status;
}
+
+static int print_submodules(git_submodule *sm, const char *name, void *p)
+{
+ unsigned int loc = 0;
+ GIT_UNUSED(p);
+ git_submodule_location(&loc, sm);
+ fprintf(stderr, "# submodule %s (at %s) flags %x\n",
+ name, git_submodule_path(sm), loc);
+ return 0;
+}
+
+void dump_submodules(git_repository *repo)
+{
+ git_submodule_foreach(repo, print_submodules, NULL);
+}
+