diff options
author | Russell Belfer <rb@github.com> | 2013-12-04 21:22:57 -0800 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-12-11 10:57:49 -0800 |
commit | dab89f9b6821b67dd07c8bd4dbb53e25a3e687c7 (patch) | |
tree | c7f4f4738dfb249b7534635226128d2e20dac6a5 /tests | |
parent | 96869a4edb2872934e0e167a726ab240f4270fea (diff) | |
download | libgit2-dab89f9b6821b67dd07c8bd4dbb53e25a3e687c7.tar.gz |
Further EUSER and error propagation fixes
This continues auditing all the places where GIT_EUSER is being
returned and making sure to clear any existing error using the
new giterr_user_cancel helper. As a result, places that relied
on intercepting GIT_EUSER but having the old error preserved also
needed to be cleaned up to correctly stash and then retrieve the
actual error.
Additionally, as I encountered places where error codes were not
being propagated correctly, I tried to fix them up. A number of
those fixes are included in the this commit as well.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/path.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/core/path.c b/tests/core/path.c index cf2d5e944..3858e30dd 100644 --- a/tests/core/path.c +++ b/tests/core/path.c @@ -350,15 +350,24 @@ void test_core_path__10_fromurl(void) typedef struct { int expect_idx; + int cancel_after; char **expect; } check_walkup_info; static int check_one_walkup_step(void *ref, git_buf *path) { check_walkup_info *info = (check_walkup_info *)ref; + + if (!info->cancel_after) { + cl_assert_equal_s(info->expect[info->expect_idx], "[CANCEL]"); + return -1; + } + info->cancel_after--; + cl_assert(info->expect[info->expect_idx] != NULL); cl_assert_equal_s(info->expect[info->expect_idx], path->ptr); info->expect_idx++; + return 0; } @@ -381,6 +390,7 @@ void test_core_path__11_walkup(void) check_walkup_info info; info.expect = expect; + info.cancel_after = -1; for (i = 0, j = 0; expect[i] != NULL; i++, j++) { @@ -400,6 +410,42 @@ void test_core_path__11_walkup(void) git_buf_free(&p); } +void test_core_path__11a_walkup_cancel(void) +{ + git_buf p = GIT_BUF_INIT; + int cancel[] = { 3, 2, 1, 0 }; + char *expect[] = { + "/a/b/c/d/e/", "/a/b/c/d/", "/a/b/c/", "[CANCEL]", NULL, + "/a/b/c/d/e", "/a/b/c/d/", "[CANCEL]", NULL, + "/a/b/c/d/e", "[CANCEL]", NULL, + "[CANCEL]", NULL, + NULL + }; + char *root[] = { NULL, NULL, "/", "", NULL }; + int i, j; + check_walkup_info info; + + info.expect = expect; + + for (i = 0, j = 0; expect[i] != NULL; i++, j++) { + + git_buf_sets(&p, expect[i]); + + info.cancel_after = cancel[j]; + info.expect_idx = i; + + cl_assert_equal_i( + GIT_EUSER, + git_path_walk_up(&p, root[j], check_one_walkup_step, &info) + ); + + /* skip to next run of expectations */ + while (expect[i] != NULL) i++; + } + + git_buf_free(&p); +} + void test_core_path__12_offset_to_path_root(void) { cl_assert(git_path_root("non/rooted/path") == -1); |