summaryrefslogtreecommitdiff
path: root/tests/clar_libgit2.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-05-15 10:56:28 -0700
committerRussell Belfer <rb@github.com>2014-05-15 10:56:28 -0700
commit8487e23797cef0284b592b5ef93eaacbac7196dc (patch)
treeda883f84114eceaf6e69f7b87e16e7aac45bbdad /tests/clar_libgit2.c
parent4af0ef9690e9fdfc81afbeed7039d02a5f191001 (diff)
downloadlibgit2-rb/restore-search-paths.tar.gz
Better search path sandboxingrb/restore-search-paths
There are a number of tests that modify the global or system search paths during the tests. This adds a helper function to make it easier to restore those paths and makes sure that they are getting restored in a manner that preserves test isolation.
Diffstat (limited to 'tests/clar_libgit2.c')
-rw-r--r--tests/clar_libgit2.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/clar_libgit2.c b/tests/clar_libgit2.c
index b2730f4d1..0a4c3e8e5 100644
--- a/tests/clar_libgit2.c
+++ b/tests/clar_libgit2.c
@@ -518,3 +518,16 @@ void cl_fake_home(void)
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, path.ptr));
git_buf_free(&path);
}
+
+void cl_sandbox_set_search_path_defaults(void)
+{
+ const char *sandbox_path = clar_sandbox_path();
+
+ git_libgit2_opts(
+ GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, sandbox_path);
+ git_libgit2_opts(
+ GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_XDG, sandbox_path);
+ git_libgit2_opts(
+ GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_SYSTEM, sandbox_path);
+}
+