Commit 232fc469 by Patrick Steinhardt

tests: always unlink created config files

While our tests in config::include create a plethora of configuration
files, most of them do not get removed at the end of each test. This can
cause weird interactions with tests that are being run at a later stage
if these later tests try to create files or directories with the same
name as any of the created configuration files.

Fix the issue by unlinking all created files at the end of these tests.

(cherry picked from commit bf662f7c)
parent 21a2318b
...@@ -32,6 +32,7 @@ void test_config_include__absolute(void) ...@@ -32,6 +32,7 @@ void test_config_include__absolute(void)
git_buf_free(&buf); git_buf_free(&buf);
git_config_free(cfg); git_config_free(cfg);
cl_git_pass(p_unlink("config-include-absolute"));
} }
void test_config_include__homedir(void) void test_config_include__homedir(void)
...@@ -51,6 +52,8 @@ void test_config_include__homedir(void) ...@@ -51,6 +52,8 @@ void test_config_include__homedir(void)
git_config_free(cfg); git_config_free(cfg);
cl_sandbox_set_search_path_defaults(); cl_sandbox_set_search_path_defaults();
cl_git_pass(p_unlink("config-include-homedir"));
} }
/* We need to pretend that the variables were defined where the file was included */ /* We need to pretend that the variables were defined where the file was included */
...@@ -75,6 +78,8 @@ void test_config_include__ordering(void) ...@@ -75,6 +78,8 @@ void test_config_include__ordering(void)
git_buf_free(&buf); git_buf_free(&buf);
git_config_free(cfg); git_config_free(cfg);
cl_git_pass(p_unlink("included"));
cl_git_pass(p_unlink("including"));
} }
/* We need to pretend that the variables were defined where the file was included */ /* We need to pretend that the variables were defined where the file was included */
...@@ -87,8 +92,8 @@ void test_config_include__depth(void) ...@@ -87,8 +92,8 @@ void test_config_include__depth(void)
cl_git_fail(git_config_open_ondisk(&cfg, "a")); cl_git_fail(git_config_open_ondisk(&cfg, "a"));
p_unlink("a"); cl_git_pass(p_unlink("a"));
p_unlink("b"); cl_git_pass(p_unlink("b"));
} }
void test_config_include__missing(void) void test_config_include__missing(void)
...@@ -106,6 +111,7 @@ void test_config_include__missing(void) ...@@ -106,6 +111,7 @@ void test_config_include__missing(void)
git_buf_free(&buf); git_buf_free(&buf);
git_config_free(cfg); git_config_free(cfg);
cl_git_pass(p_unlink("including"));
} }
void test_config_include__missing_homedir(void) void test_config_include__missing_homedir(void)
...@@ -126,6 +132,7 @@ void test_config_include__missing_homedir(void) ...@@ -126,6 +132,7 @@ void test_config_include__missing_homedir(void)
git_config_free(cfg); git_config_free(cfg);
cl_sandbox_set_search_path_defaults(); cl_sandbox_set_search_path_defaults();
cl_git_pass(p_unlink("including"));
} }
#define replicate10(s) s s s s s s s s s s #define replicate10(s) s s s s s s s s s s
...@@ -150,4 +157,8 @@ void test_config_include__depth2(void) ...@@ -150,4 +157,8 @@ void test_config_include__depth2(void)
git_buf_free(&buf); git_buf_free(&buf);
git_config_free(cfg); git_config_free(cfg);
cl_git_pass(p_unlink("top-level"));
cl_git_pass(p_unlink("middle"));
cl_git_pass(p_unlink("bottom"));
} }
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