]> git.proxmox.com Git - libgit2.git/commitdiff
test: Don't be so picky with failed lookups
authorVicent Marti <tanoku@gmail.com>
Tue, 16 Oct 2012 17:34:29 +0000 (19:34 +0200)
committerVicent Marti <tanoku@gmail.com>
Tue, 16 Oct 2012 17:37:21 +0000 (19:37 +0200)
Not found means not found, and the other way around.

src/fileops.c
tests-clar/core/env.c

index 763537a4634299bdadb8330f8fbdf2eeff5a8727..6abab8836e96a0ee2f88bcde1232e8a1993ec64c 100644 (file)
@@ -418,14 +418,14 @@ int git_futils_find_global_file(git_buf *path, const char *filename)
                        root.path[0] == L'%') /* i.e. no expansion happened */
                {
                        giterr_set(GITERR_OS, "Cannot locate the user's profile directory");
-                       return -1;
+                       return GIT_ENOTFOUND;
                }
        } else {
                if (win32_expand_path(&root, L"%USERPROFILE%\\") < 0 ||
                        root.path[0] == L'%') /* i.e. no expansion happened */
                {
                        giterr_set(GITERR_OS, "Cannot locate the user's profile directory");
-                       return -1;
+                       return GIT_ENOTFOUND;
                }
        }
 
@@ -440,7 +440,7 @@ int git_futils_find_global_file(git_buf *path, const char *filename)
        if (home == NULL) {
                giterr_set(GITERR_OS, "Global file lookup failed. "
                        "Cannot locate the user's home directory");
-               return -1;
+               return GIT_ENOTFOUND;
        }
 
        if (git_buf_joinpath(path, home, filename) < 0)
index a2a65be72619fb49639513e560f9accd5cabf15d..0e0ddf3b64c160f49be816a305d66fe64b200211 100644 (file)
@@ -87,7 +87,7 @@ void test_core_env__1(void)
 {
        git_buf path = GIT_BUF_INIT;
 
-       cl_assert(git_futils_find_global_file(&path, "nonexistentfile") == GIT_ENOTFOUND);
+       cl_must_fail(git_futils_find_global_file(&path, "nonexistentfile"));
 
 #ifdef GIT_WIN32
        cl_git_pass(cl_setenv("USERPROFILE", "doesnotexist"));
@@ -95,7 +95,7 @@ void test_core_env__1(void)
        cl_git_pass(cl_setenv("HOME", "doesnotexist"));
 #endif
 
-       cl_assert(git_futils_find_global_file(&path, "nonexistentfile") == GIT_ENOTFOUND);
+       cl_must_fail(git_futils_find_global_file(&path, "nonexistentfile"));
 
 #ifdef GIT_WIN32
        cl_git_pass(cl_setenv("USERPROFILE", NULL));
@@ -103,14 +103,12 @@ void test_core_env__1(void)
        cl_git_pass(cl_setenv("HOME", NULL));
 #endif
 
-       cl_assert(git_futils_find_global_file(&path, "nonexistentfile") == -1);
-
-       cl_assert(git_futils_find_system_file(&path, "nonexistentfile") == GIT_ENOTFOUND);
+       cl_must_fail(git_futils_find_global_file(&path, "nonexistentfile"));
+       cl_must_fail(git_futils_find_system_file(&path, "nonexistentfile"));
 
 #ifdef GIT_WIN32
        cl_git_pass(cl_setenv("PROGRAMFILES", NULL));
-
-       cl_assert(git_futils_find_system_file(&path, "nonexistentfile") == -1);
+       cl_must_fail(git_futils_find_system_file(&path, "nonexistentfile"));
 #endif
 
        git_buf_free(&path);