]> git.proxmox.com Git - libgit2.git/blobdiff - tests/core/env.c
New upstream version 1.4.3+dfsg.1
[libgit2.git] / tests / core / env.c
index 1af0e6e5df15b40b7b64a3ff26535b61696da040..8ba9b91240a5d3bba0fbf03c425434f8d7f249b7 100644 (file)
@@ -1,7 +1,6 @@
 #include "clar_libgit2.h"
-#include "fileops.h"
+#include "futils.h"
 #include "sysdir.h"
-#include "path.h"
 
 #ifdef GIT_WIN32
 #define NUM_VARS 5
@@ -83,7 +82,7 @@ static void setenv_and_check(const char *name, const char *value)
 
 void test_core_env__0(void)
 {
-       git_buf path = GIT_BUF_INIT, found = GIT_BUF_INIT;
+       git_str path = GIT_STR_INIT, found = GIT_STR_INIT;
        char testfile[16], tidx = '0';
        char **val;
        const char *testname = "testfile";
@@ -103,16 +102,16 @@ void test_core_env__0(void)
                        continue;
                }
 
-               cl_git_pass(git_path_prettify(&path, *val, NULL));
+               cl_git_pass(git_fs_path_prettify(&path, *val, NULL));
 
                /* vary testfile name in each directory so accidentally leaving
                 * an environment variable set from a previous iteration won't
                 * accidentally make this test pass...
                 */
                testfile[testlen] = tidx++;
-               cl_git_pass(git_buf_joinpath(&path, path.ptr, testfile));
+               cl_git_pass(git_str_joinpath(&path, path.ptr, testfile));
                cl_git_mkfile(path.ptr, "find me");
-               git_buf_rtruncate_at_char(&path, '/');
+               git_str_rtruncate_at_char(&path, '/');
 
                cl_assert_equal_i(
                        GIT_ENOTFOUND, git_sysdir_find_global_file(&found, testfile));
@@ -137,7 +136,7 @@ void test_core_env__0(void)
                cl_git_pass(git_sysdir_find_global_file(&found, testfile));
 
                {
-                       int root = git_path_root(path.ptr);
+                       int root = git_fs_path_root(path.ptr);
                        char old;
 
                        if (root >= 0) {
@@ -162,14 +161,14 @@ void test_core_env__0(void)
                (void)p_rmdir(*val);
        }
 
-       git_buf_free(&path);
-       git_buf_free(&found);
+       git_str_dispose(&path);
+       git_str_dispose(&found);
 }
 
 
 void test_core_env__1(void)
 {
-       git_buf path = GIT_BUF_INIT;
+       git_str path = GIT_STR_INIT;
 
        cl_assert_equal_i(
                GIT_ENOTFOUND, git_sysdir_find_global_file(&path, "nonexistentfile"));
@@ -206,21 +205,21 @@ void test_core_env__1(void)
                GIT_ENOTFOUND, git_sysdir_find_system_file(&path, "nonexistentfile"));
 #endif
 
-       git_buf_free(&path);
+       git_str_dispose(&path);
 }
 
 static void check_global_searchpath(
-       const char *path, int position, const char *file, git_buf *temp)
+       const char *path, int position, const char *file, git_str *temp)
 {
-       git_buf out = GIT_BUF_INIT;
+       git_str out = GIT_STR_INIT;
 
        /* build and set new path */
        if (position < 0)
-               cl_git_pass(git_buf_join(temp, GIT_PATH_LIST_SEPARATOR, path, "$PATH"));
+               cl_git_pass(git_str_join(temp, GIT_PATH_LIST_SEPARATOR, path, "$PATH"));
        else if (position > 0)
-               cl_git_pass(git_buf_join(temp, GIT_PATH_LIST_SEPARATOR, "$PATH", path));
+               cl_git_pass(git_str_join(temp, GIT_PATH_LIST_SEPARATOR, "$PATH", path));
        else
-               cl_git_pass(git_buf_sets(temp, path));
+               cl_git_pass(git_str_sets(temp, path));
 
        cl_git_pass(git_libgit2_opts(
                GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, temp->ptr));
@@ -245,12 +244,12 @@ static void check_global_searchpath(
        cl_assert_equal_i(
                GIT_ENOTFOUND, git_sysdir_find_global_file(temp, file));
 
-       git_buf_free(&out);
+       git_str_dispose(&out);
 }
 
 void test_core_env__2(void)
 {
-       git_buf path = GIT_BUF_INIT, found = GIT_BUF_INIT;
+       git_str path = GIT_STR_INIT, found = GIT_STR_INIT;
        char testfile[16], tidx = '0';
        char **val;
        const char *testname = "alternate";
@@ -270,15 +269,15 @@ void test_core_env__2(void)
                        continue;
                }
 
-               cl_git_pass(git_path_prettify(&path, *val, NULL));
+               cl_git_pass(git_fs_path_prettify(&path, *val, NULL));
 
                /* vary testfile name so any sloppiness is resetting variables or
                 * deleting files won't accidentally make a test pass.
                 */
                testfile[testlen] = tidx++;
-               cl_git_pass(git_buf_joinpath(&path, path.ptr, testfile));
+               cl_git_pass(git_str_joinpath(&path, path.ptr, testfile));
                cl_git_mkfile(path.ptr, "find me");
-               git_buf_rtruncate_at_char(&path, '/');
+               git_str_rtruncate_at_char(&path, '/');
 
                /* default should be NOTFOUND */
                cl_assert_equal_i(
@@ -290,32 +289,32 @@ void test_core_env__2(void)
                check_global_searchpath(path.ptr,  1, testfile, &found);
 
                /* cleanup */
-               cl_git_pass(git_buf_joinpath(&path, path.ptr, testfile));
+               cl_git_pass(git_str_joinpath(&path, path.ptr, testfile));
                (void)p_unlink(path.ptr);
                (void)p_rmdir(*val);
        }
 
-       git_buf_free(&path);
-       git_buf_free(&found);
+       git_str_dispose(&path);
+       git_str_dispose(&found);
 }
 
 void test_core_env__substitution(void)
 {
-  git_buf buf = GIT_BUF_INIT, expected = GIT_BUF_INIT;
+  git_str buf = GIT_STR_INIT, expected = GIT_STR_INIT;
 
   /* Set it to something non-default so we have controllable values */
   cl_git_pass(git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, "/tmp/a"));
   cl_git_pass(git_libgit2_opts(GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, &buf));
   cl_assert_equal_s("/tmp/a", buf.ptr);
 
-  git_buf_clear(&buf);
-  cl_git_pass(git_buf_join(&buf, GIT_PATH_LIST_SEPARATOR, "$PATH", "/tmp/b"));
+  git_str_clear(&buf);
+  cl_git_pass(git_str_join(&buf, GIT_PATH_LIST_SEPARATOR, "$PATH", "/tmp/b"));
   cl_git_pass(git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, buf.ptr));
   cl_git_pass(git_libgit2_opts(GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, &buf));
 
-  cl_git_pass(git_buf_join(&expected, GIT_PATH_LIST_SEPARATOR, "/tmp/a", "/tmp/b"));
+  cl_git_pass(git_str_join(&expected, GIT_PATH_LIST_SEPARATOR, "/tmp/a", "/tmp/b"));
   cl_assert_equal_s(expected.ptr, buf.ptr);
 
-  git_buf_free(&expected);
-  git_buf_free(&buf);
+  git_str_dispose(&expected);
+  git_str_dispose(&buf);
 }