Commit ad273718 by Patrick Steinhardt Committed by Sven Strickroth

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.
parent e886ab46
...@@ -27,6 +27,12 @@ void test_core_rmdir__initialize(void) ...@@ -27,6 +27,12 @@ void test_core_rmdir__initialize(void)
git_buf_dispose(&path); 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 */ /* make sure empty dir can be deleted recusively */
void test_core_rmdir__delete_recursive(void) void test_core_rmdir__delete_recursive(void)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment