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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
diff --git a/tests/config/conditionals.c b/tests/config/conditionals.c
index 83dd45c..3a87de2 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);
}