summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2017-10-31 09:52:33 +0100
committerCarlos Martín Nieto <cmn@dwim.me>2017-10-31 09:52:33 +0100
commitc44b91705c4fa3c8996e4d98d3ba23b1ecc4034b (patch)
tree41d610af15269597fa5cf982a811daea398d9841
parentf7d837c835a55a98a85d10f2e600a7a5ae2281c6 (diff)
downloadlibgit2-c44b91705c4fa3c8996e4d98d3ba23b1ecc4034b.tar.gz
tests: resolve the real path for the sandbox in includeIf tests
We put our repository in the temporary directory which makes macOS map the path into a virtual path. `realpath(3)` can resolve it and we do so during repository opening, but that makes its path have a different prefix from the sandbox path clar thinks we have. Resolve the sandbox path before putting it into the test config files so the paths match as expected.
-rw-r--r--tests/config/conditionals.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/tests/config/conditionals.c b/tests/config/conditionals.c
index 83dd45c34..3a87de21f 100644
--- a/tests/config/conditionals.c
+++ b/tests/config/conditionals.c
@@ -50,6 +50,7 @@ static void assert_condition_includes(const char *keyword, const char *path, boo
void test_config_conditionals__gitdir(void)
{
git_buf path = GIT_BUF_INIT;
+ char *sandbox_path;
assert_condition_includes("gitdir", ROOT_PREFIX "/", true);
assert_condition_includes("gitdir", "empty_standard_repo", true);
@@ -61,31 +62,38 @@ void test_config_conditionals__gitdir(void)
assert_condition_includes("gitdir", "empty_stand", false);
assert_condition_includes("gitdir", "~/empty_standard_repo", false);
- git_buf_joinpath(&path, clar_sandbox_path(), "/");
+ sandbox_path = p_realpath(clar_sandbox_path(), NULL);
+
+ git_buf_joinpath(&path, sandbox_path, "/");
assert_condition_includes("gitdir", path.ptr, true);
- git_buf_joinpath(&path, clar_sandbox_path(), "/*");
+ git_buf_joinpath(&path, sandbox_path, "/*");
assert_condition_includes("gitdir", path.ptr, true);
- git_buf_joinpath(&path, clar_sandbox_path(), "empty_standard_repo");
+ git_buf_joinpath(&path, sandbox_path, "empty_standard_repo");
assert_condition_includes("gitdir", path.ptr, true);
- git_buf_joinpath(&path, clar_sandbox_path(), "Empty_Standard_Repo");
+ git_buf_joinpath(&path, sandbox_path, "Empty_Standard_Repo");
assert_condition_includes("gitdir", path.ptr, false);
+ git__free(sandbox_path);
git_buf_free(&path);
}
void test_config_conditionals__gitdir_i(void)
{
git_buf path = GIT_BUF_INIT;
+ char *sandbox_path;
+
+ sandbox_path = p_realpath(clar_sandbox_path(), NULL);
- git_buf_joinpath(&path, clar_sandbox_path(), "empty_standard_repo");
+ git_buf_joinpath(&path, sandbox_path, "empty_standard_repo");
assert_condition_includes("gitdir/i", path.ptr, true);
- git_buf_joinpath(&path, clar_sandbox_path(), "EMPTY_STANDARD_REPO");
+ git_buf_joinpath(&path, sandbox_path, "EMPTY_STANDARD_REPO");
assert_condition_includes("gitdir/i", path.ptr, true);
+ git__free(sandbox_path);
git_buf_free(&path);
}