Skip to content

Commit ad27371

Browse files
pks-tcsware
authored andcommitted
tests: sanitize file hierarchy after running rmdir tests
Currently, we do not clean up after ourselves after tests in core::rmdir have created new files in the directory hierarchy. This may leave stale files and/or directories after having run tests, confusing subsequent tests that expect a pristine test environment. Most importantly, it may cause the test initialization to fail which expects being able to re-create the testing hierarchy before each test in case where another test hasn't cleaned up after itself. Fix the issue by adding a cleanup function that removes the temporary testing hierarchy after each test if it still exists.
1 parent e886ab4 commit ad27371

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tests/core/rmdir.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ 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
{

0 commit comments

Comments
 (0)