Commit 88638f9b1841a83e82fc5f79bf00f90d40fb426f

Edward Thomson 2015-11-17T11:22:01

tests: use out-of-the-way config dir in sandbox Don't put the configuration in a subdir of the sandbox named `config`, lest some tests decide to create their own directory called `config`. Prefix with some underscores for uniqueness.

diff --git a/tests/clar_libgit2.c b/tests/clar_libgit2.c
index 1bf69c5..314d344 100644
--- a/tests/clar_libgit2.c
+++ b/tests/clar_libgit2.c
@@ -541,16 +541,23 @@ void cl_fake_home(void)
 
 void cl_sandbox_set_search_path_defaults(void)
 {
-	const char *sandbox_path = clar_sandbox_path();
+	git_buf path = GIT_BUF_INIT;
+
+	git_buf_joinpath(&path, clar_sandbox_path(), "__config");
+
+	if (!git_path_exists(path.ptr))
+		cl_must_pass(p_mkdir(path.ptr, 0777));
 
 	git_libgit2_opts(
-		GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, sandbox_path);
+		GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, path.ptr);
 	git_libgit2_opts(
-		GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_XDG, sandbox_path);
+		GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_XDG, path.ptr);
 	git_libgit2_opts(
-		GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_SYSTEM, sandbox_path);
+		GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_SYSTEM, path.ptr);
 	git_libgit2_opts(
-		GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_PROGRAMDATA, sandbox_path);
+		GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_PROGRAMDATA, path.ptr);
+
+	git_buf_free(&path);
 }
 
 #ifdef GIT_WIN32