summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNika Layzell <nika@thelayzells.com>2018-03-17 18:14:03 -0400
committerNika Layzell <nika@thelayzells.com>2018-06-14 22:43:27 -0700
commit939d8d579dcf722ca56578203df7c3134ba23ac1 (patch)
treec5d9ca8b8925bc8b945a11e110e86ae32d04a3f9
parentb88cbf8c28b6965e6f57d8f044aeab437914c23d (diff)
downloadlibgit2-939d8d579dcf722ca56578203df7c3134ba23ac1.tar.gz
mailmap: Support path fixtures in cl_git_repository_init()
-rw-r--r--tests/clar.h1
-rw-r--r--tests/clar/fixtures.h27
-rw-r--r--tests/clar_libgit2.c12
3 files changed, 23 insertions, 17 deletions
diff --git a/tests/clar.h b/tests/clar.h
index 5c674d70f..dfb88d76d 100644
--- a/tests/clar.h
+++ b/tests/clar.h
@@ -72,6 +72,7 @@ void cl_trace_register(cl_trace_cb *cb, void *payload);
const char *cl_fixture(const char *fixture_name);
void cl_fixture_sandbox(const char *fixture_name);
void cl_fixture_cleanup(const char *fixture_name);
+const char *cl_fixture_basename(const char *fixture_name);
#endif
/**
diff --git a/tests/clar/fixtures.h b/tests/clar/fixtures.h
index f7b8d96af..77033d365 100644
--- a/tests/clar/fixtures.h
+++ b/tests/clar/fixtures.h
@@ -20,19 +20,6 @@ fixture_path(const char *base, const char *fixture_name)
return _path;
}
-static const char *
-fixture_basename(const char *fixture_name)
-{
- const char *p;
-
- for (p = fixture_name; *p; p++) {
- if (p[0] == '/' && p[1] && p[1] != '/')
- fixture_name = p+1;
- }
-
- return fixture_name;
-}
-
#ifdef CLAR_FIXTURE_PATH
const char *cl_fixture(const char *fixture_name)
{
@@ -44,8 +31,20 @@ void cl_fixture_sandbox(const char *fixture_name)
fs_copy(cl_fixture(fixture_name), _clar_path);
}
+const char *cl_fixture_basename(const char *fixture_name)
+{
+ const char *p;
+
+ for (p = fixture_name; *p; p++) {
+ if (p[0] == '/' && p[1] && p[1] != '/')
+ fixture_name = p+1;
+ }
+
+ return fixture_name;
+}
+
void cl_fixture_cleanup(const char *fixture_name)
{
- fs_rm(fixture_path(_clar_path, fixture_basename(fixture_name)));
+ fs_rm(fixture_path(_clar_path, cl_fixture_basename(fixture_name)));
}
#endif
diff --git a/tests/clar_libgit2.c b/tests/clar_libgit2.c
index 92404b5d7..b50633a6c 100644
--- a/tests/clar_libgit2.c
+++ b/tests/clar_libgit2.c
@@ -171,13 +171,17 @@ static git_repository *_cl_repo = NULL;
git_repository *cl_git_sandbox_init(const char *sandbox)
{
+ /* Get the name of the sandbox folder which will be created
+ */
+ const char *basename = cl_fixture_basename(sandbox);
+
/* Copy the whole sandbox folder from our fixtures to our test sandbox
* area. After this it can be accessed with `./sandbox`
*/
cl_fixture_sandbox(sandbox);
_cl_sandbox = sandbox;
- cl_git_pass(p_chdir(sandbox));
+ cl_git_pass(p_chdir(basename));
/* If this is not a bare repo, then rename `sandbox/.gitted` to
* `sandbox/.git` which must be done since we cannot store a folder
@@ -200,7 +204,7 @@ git_repository *cl_git_sandbox_init(const char *sandbox)
cl_git_pass(p_chdir(".."));
/* Now open the sandbox repository and make it available for tests */
- cl_git_pass(git_repository_open(&_cl_repo, sandbox));
+ cl_git_pass(git_repository_open(&_cl_repo, basename));
/* Adjust configs after copying to new filesystem */
cl_git_pass(git_repository_reinit_filesystem(_cl_repo, 0));
@@ -222,7 +226,9 @@ git_repository *cl_git_sandbox_reopen(void)
git_repository_free(_cl_repo);
_cl_repo = NULL;
- cl_git_pass(git_repository_open(&_cl_repo, _cl_sandbox));
+ cl_git_pass(git_repository_open(
+ &_cl_repo,
+ cl_fixture_basename(_cl_sandbox)));
}
return _cl_repo;