git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 3/3] config tests: fix harmless but broken "rm -r" cleanup

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jun 30, 2022, 10:18 UTC
Message-ID
<patch-v2-3.3-d3f65326701-20220630T101646Z-avarab@gmail.com>
In-Reply-To
<cover-v2-0.3-00000000000-20220630T101646Z-avarab@gmail.com>

The "test_when_finished" cleanup phase added in 4179b4897f2 (config: allow overriding of global and system configuration, 2021-04-19) has never worked as intended, firstly the ".config/git" is a directory, so we'd need the "-r" flag, but more importantly the $HOME variable wasn't properly quoted.

We'd thus end up trying to remove the "trash" part of "trash directory", which wouldn't fail with "-f", since "rm -f" won't fail on non-existing files.

It's possible that this would have caused an actual failure if someone had a $HOME with a space character in it, such that our "rm -f" would fail to remove an existing directory, but in practice that probably never happened.

Let's fix both the quoting issue, and the other issue cleanup issue in 4179b4897f2, which is that we were attempting to clean up ~/.config/git, but weren't cleaing up ~/.gitconfig.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t1300-config.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/t/t1300-config.sh b/t/t1300-config.sh
index d3d9adbb3db..c6661e61af5 100755
--- a/t/t1300-config.sh
+++ b/t/t1300-config.sh
@@ -2083,12 +2083,13 @@ test_expect_success '--show-scope with --show-origin' '
 '
 
 test_expect_success 'override global and system config' '
-	test_when_finished rm -f "$HOME"/.config/git &&
-
+	test_when_finished rm -f \"\$HOME\"/.gitconfig &&
 	cat >"$HOME"/.gitconfig <<-EOF &&
 	[home]
 		config = true
 	EOF
+
+	test_when_finished rm -rf \"\$HOME\"/.config/git &&
 	mkdir -p "$HOME"/.config/git &&
 	cat >"$HOME"/.config/git/config <<-EOF &&
 	[xdg]
-- 
2.37.0.880.gf07d56b18ba
Previous: Ævar Arnfjörð BjarmasonNext: Junio C Hamano
Message 11 of 12 in “tests: fix tests broken if a " " is in the checkout dir's path”
  1. 0/3 tests: fix tests broken if a " " is in the checkout dir's pathÆvar Arnfjörð Bjarmason, Jun 21, 2022
  2. 1/3 tests: add missing double quotes to included library pathsÆvar Arnfjörð Bjarmason, Jun 21, 2022
  3. Junio C HamanoJun 21, 2022
  4. 2/3 test-lib.sh: fix prepend_var() quoting issueÆvar Arnfjörð Bjarmason, Jun 21, 2022
  5. 3/3 config tests: fix harmless but broken "rm -r" cleanupÆvar Arnfjörð Bjarmason, Jun 21, 2022
  6. Junio C HamanoJun 21, 2022
  7. Junio C HamanoJun 22, 2022
  8. 0/3 tests: fix tests broken if a " " is in the checkout dir's pathÆvar Arnfjörð Bjarmason, Jun 30, 2022
  9. 1/3 tests: add missing double quotes to included library pathsÆvar Arnfjörð Bjarmason, Jun 30, 2022
  10. 2/3 test-lib.sh: fix prepend_var() quoting issueÆvar Arnfjörð Bjarmason, Jun 30, 2022
  11. 3/3 config tests: fix harmless but broken "rm -r" cleanupÆvar Arnfjörð Bjarmason, Jun 30, 2022
  12. Junio C HamanoJun 30, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.