diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2018-10-07 12:00:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-07 12:00:48 +0100 |
commit | 838a2f2918b6d9fad8768d2498575ff5d75c35f0 (patch) | |
tree | 272ff8657d54d37f4a8ed61baebebc6d2ba68845 | |
parent | 0cd976c831ff32b1303bfca5ce4939af3a812473 (diff) | |
parent | ad2737185d1b09e90154c18d5d7b98e1fb4bbafe (diff) | |
download | libgit2-838a2f2918b6d9fad8768d2498575ff5d75c35f0.tar.gz |
Merge pull request #4828 from csware/git_futils_rmdir_r_failing
Add some more tests for git_futils_rmdir_r and some cleanup
-rw-r--r-- | tests/core/rmdir.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/core/rmdir.c b/tests/core/rmdir.c index 0ec5d6144..e00ec5c72 100644 --- a/tests/core/rmdir.c +++ b/tests/core/rmdir.c @@ -27,10 +27,24 @@ void test_core_rmdir__initialize(void) git_buf_dispose(&path); } +void test_core_rmdir__cleanup(void) +{ + if (git_path_exists(empty_tmp_dir)) + cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_REMOVE_FILES)); +} + /* make sure empty dir can be deleted recusively */ void test_core_rmdir__delete_recursive(void) { + git_buf path = GIT_BUF_INIT; + cl_git_pass(git_buf_joinpath(&path, empty_tmp_dir, "/one")); + cl_assert(git_path_exists(git_buf_cstr(&path))); + cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_EMPTY_HIERARCHY)); + + cl_assert(!git_path_exists(git_buf_cstr(&path))); + + git_buf_dispose(&path); } /* make sure non-empty dir cannot be deleted recusively */ @@ -47,9 +61,17 @@ void test_core_rmdir__fail_to_delete_non_empty_dir(void) cl_must_pass(p_unlink(file.ptr)); cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_EMPTY_HIERARCHY)); + cl_assert(!git_path_exists(empty_tmp_dir)); + git_buf_dispose(&file); } +void test_core_rmdir__keep_base(void) +{ + cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_SKIP_ROOT)); + cl_assert(git_path_exists(empty_tmp_dir)); +} + void test_core_rmdir__can_skip_non_empty_dir(void) { git_buf file = GIT_BUF_INIT; |