diff options
author | Russell Belfer <rb@github.com> | 2012-05-24 15:08:55 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2012-05-24 15:08:55 -0700 |
commit | 9cde607c95ecb3b5e49ff939fa8de44641fec589 (patch) | |
tree | 6c8f9b2921cd7660a17dcf34cecbb63bf9038fc2 | |
parent | 349fb6d7acd2d57fb5c0039e7f1228cff1702b13 (diff) | |
download | libgit2-env-expansion.tar.gz |
Clean up system file finding tests on Win32env-expansion
-rw-r--r-- | src/fileops.c | 2 | ||||
-rw-r--r-- | tests-clar/core/env.c | 29 |
2 files changed, 11 insertions, 20 deletions
diff --git a/src/fileops.c b/src/fileops.c index 0e7d43bab..cd4b3c42a 100644 --- a/src/fileops.c +++ b/src/fileops.c @@ -415,7 +415,7 @@ int git_futils_find_system_file(git_buf *path, const char *filename) { #ifdef GIT_WIN32 struct win32_path root; - + if (win32_expand_path(&root, L"%PROGRAMFILES%\\Git\\etc\\") < 0 || win32_find_file(path, &root, filename) < 0) { giterr_set(GITERR_OS, "Cannot find the system's Program Files directory"); diff --git a/tests-clar/core/env.c b/tests-clar/core/env.c index abe7bf87c..0d58e560b 100644 --- a/tests-clar/core/env.c +++ b/tests-clar/core/env.c @@ -53,26 +53,24 @@ static int cl_setenv(const char *name, const char *value) #endif static char *env_home = NULL; -#ifdef GIT_WIN32 static char *env_userprofile = NULL; -#endif void test_core_env__initialize(void) { - env_home = cl_getenv("HOME"); #ifdef GIT_WIN32 env_userprofile = cl_getenv("USERPROFILE"); +#else + env_home = cl_getenv("HOME"); #endif } void test_core_env__cleanup(void) { - cl_setenv("HOME", env_home); #ifdef GIT_WIN32 cl_setenv("USERPROFILE", env_userprofile); - - git__free(env_home); git__free(env_userprofile); +#else + cl_setenv("HOME", env_home); #endif } @@ -102,32 +100,25 @@ void test_core_env__0(void) */ cl_git_pass(git_path_prettify(&path, *val, NULL)); - cl_git_pass(cl_setenv("HOME", path.ptr)); - - /* do a quick check that it was set correctly */ - check = cl_getenv("HOME"); - cl_assert_equal_s(path.ptr, check); #ifdef GIT_WIN32 - git__free(check); - cl_git_pass(cl_setenv("USERPROFILE", path.ptr)); /* do a quick check that it was set correctly */ check = cl_getenv("USERPROFILE"); cl_assert_equal_s(path.ptr, check); git__free(check); +#else + cl_git_pass(cl_setenv("HOME", path.ptr)); + + /* do a quick check that it was set correctly */ + check = cl_getenv("HOME"); + cl_assert_equal_s(path.ptr, check); #endif cl_git_pass(git_buf_puts(&path, "/testfile")); cl_git_mkfile(path.ptr, "find me"); cl_git_pass(git_futils_find_global_file(&found, "testfile")); - -#ifdef GIT_WIN32 - /* do another check with HOME unset */ - cl_git_pass(cl_setenv("HOME", NULL)); - cl_git_pass(git_futils_find_global_file(&found, "testfile")); -#endif } } |