Skip to content

Commit 410855f

Browse files
committed
sysdir: add failing test for variable substitution
When given $PATH as part of a search path, we guess again instead of substituting what the user already set.
1 parent c5e6ba2 commit 410855f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/core/env.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,3 +298,24 @@ void test_core_env__2(void)
298298
git_buf_free(&path);
299299
git_buf_free(&found);
300300
}
301+
302+
void test_core_env__substitution(void)
303+
{
304+
git_buf buf = GIT_BUF_INIT, expected = GIT_BUF_INIT;
305+
306+
/* Set it to something non-default so we have controllable values */
307+
cl_git_pass(git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, "/tmp/a"));
308+
cl_git_pass(git_libgit2_opts(GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, &buf));
309+
cl_assert_equal_s("/tmp/a", buf.ptr);
310+
311+
git_buf_clear(&buf);
312+
cl_git_pass(git_buf_join(&buf, GIT_PATH_LIST_SEPARATOR, "$PATH", "/tmp/b"));
313+
cl_git_pass(git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, buf.ptr));
314+
cl_git_pass(git_libgit2_opts(GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, &buf));
315+
316+
cl_git_pass(git_buf_join(&expected, GIT_PATH_LIST_SEPARATOR, "/tmp/a", "/tmp/b"));
317+
cl_assert_equal_s(expected.ptr, buf.ptr);
318+
319+
git_buf_free(&expected);
320+
git_buf_free(&buf);
321+
}

0 commit comments

Comments
 (0)