Skip to content

Commit 838a2f2

Browse files
authored
Merge pull request libgit2#4828 from csware/git_futils_rmdir_r_failing
Add some more tests for git_futils_rmdir_r and some cleanup
2 parents 0cd976c + ad27371 commit 838a2f2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/core/rmdir.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,24 @@ void test_core_rmdir__initialize(void)
2727
git_buf_dispose(&path);
2828
}
2929

30+
void test_core_rmdir__cleanup(void)
31+
{
32+
if (git_path_exists(empty_tmp_dir))
33+
cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_REMOVE_FILES));
34+
}
35+
3036
/* make sure empty dir can be deleted recusively */
3137
void test_core_rmdir__delete_recursive(void)
3238
{
39+
git_buf path = GIT_BUF_INIT;
40+
cl_git_pass(git_buf_joinpath(&path, empty_tmp_dir, "/one"));
41+
cl_assert(git_path_exists(git_buf_cstr(&path)));
42+
3343
cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_EMPTY_HIERARCHY));
44+
45+
cl_assert(!git_path_exists(git_buf_cstr(&path)));
46+
47+
git_buf_dispose(&path);
3448
}
3549

3650
/* make sure non-empty dir cannot be deleted recusively */
@@ -47,9 +61,17 @@ void test_core_rmdir__fail_to_delete_non_empty_dir(void)
4761
cl_must_pass(p_unlink(file.ptr));
4862
cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_EMPTY_HIERARCHY));
4963

64+
cl_assert(!git_path_exists(empty_tmp_dir));
65+
5066
git_buf_dispose(&file);
5167
}
5268

69+
void test_core_rmdir__keep_base(void)
70+
{
71+
cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_SKIP_ROOT));
72+
cl_assert(git_path_exists(empty_tmp_dir));
73+
}
74+
5375
void test_core_rmdir__can_skip_non_empty_dir(void)
5476
{
5577
git_buf file = GIT_BUF_INIT;

0 commit comments

Comments
 (0)