git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] t7110: Replace `test -f` and `! test -f` with `test_path_is_file` and `test_path_is_missing` for improved debuggability when failing.
@ 2025-01-01 22:59 matteobagnolini
  2025-01-03 11:41 ` Patrick Steinhardt
  0 siblings, 1 reply; 8+ messages in thread
From: matteobagnolini @ 2025-01-01 22:59 UTC (permalink / raw)
  To: git; +Cc: matteobagnolini, John Cai, Junio C Hamano

`test -f` and `! test -f` do not provide clear error messages when they fail.
To enanche debuggability, use `test_path_is_file` and `test_path_is_missing`,
which instead provides more informative error messages.
Note that `! test -f` checks if a path is not a file, while
`test_path_is_missing` verifies that a path does not exist. In this specific
case the tests are meant to check the absence of the path, making
`test_path_is_missing` a valid replacement.

Signed-off-by: matteobagnolini <matteobagnolini2003@gmail.com>
---
 t/t7110-reset-merge.sh | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/t/t7110-reset-merge.sh b/t/t7110-reset-merge.sh
index 61669a2d21..9a335071af 100755
--- a/t/t7110-reset-merge.sh
+++ b/t/t7110-reset-merge.sh
@@ -270,13 +270,13 @@ test_expect_success '--merge is ok with added/deleted merge' '
 	git reset --hard third &&
 	rm -f file2 &&
 	test_must_fail git merge branch3 &&
-	! test -f file2 &&
-	test -f file3 &&
+	test_path_is_missing file2 &&
+	test_path_is_file file3 &&
 	git diff --exit-code file3 &&
 	git diff --exit-code branch3 file3 &&
 	git reset --merge HEAD &&
-	! test -f file3 &&
-	! test -f file2 &&
+	test_path_is_missing file3 &&
+	test_path_is_missing file2 &&
 	git diff --exit-code --cached
 '
 
@@ -284,8 +284,8 @@ test_expect_success '--keep fails with added/deleted merge' '
 	git reset --hard third &&
 	rm -f file2 &&
 	test_must_fail git merge branch3 &&
-	! test -f file2 &&
-	test -f file3 &&
+	test_path_is_missing file2 &&
+	test_path_is_file file3 &&
 	git diff --exit-code file3 &&
 	git diff --exit-code branch3 file3 &&
 	test_must_fail git reset --keep HEAD 2>err.log &&
-- 
2.39.2 (Apple Git-143)


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-01-03 19:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-01 22:59 [PATCH] t7110: Replace `test -f` and `! test -f` with `test_path_is_file` and `test_path_is_missing` for improved debuggability when failing matteobagnolini
2025-01-03 11:41 ` Patrick Steinhardt
2025-01-03 13:00   ` [PATCH v2] t7110: replace `test -f` with `test_path_is_*` helpers Matteo Bagnolini
2025-01-03 13:12     ` Patrick Steinhardt
2025-01-03 16:25       ` Junio C Hamano
2025-01-03 17:27         ` Matteo Bagnolini
2025-01-03 18:06           ` Junio C Hamano
2025-01-03 19:07             ` Matteo Bagnolini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).