git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vinayak Dev <vinayakdev.sci@gmail.com>
To: gitster@pobox.com
Cc: git@vger.kernel.org, Vinayak Dev <vinayakdev.sci@gmail.com>
Subject: [PATCH] t4014: replace "test -f" with "test_path_is_file"
Date: Thu,  5 Oct 2023 13:47:00 +0530	[thread overview]
Message-ID: <20231005081700.50473-1-vinayakdev.sci@gmail.com> (raw)

From: Vinayak Dev <vinayakdev.sci@gmail.com>

Many tests in the codebase use test -[e|f|d].. commands
to check for various conditions. However, the test command
upon failure simply exits with a non-zero exit code(usually 1).
Therefore, replace instances of "test -f" from t/t4014-format-patch.sh
with the function test_path_is_file() defined in t/test-lib-functions.sh
that exits with a debugging-friendly diagnostic message upon failure.

Signed-off-by: Vinayak Dev <vinayakdev.sci@gmail.com>
---
 t/t4014-format-patch.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 0a4ab36c3a..5f7d0836d6 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -763,7 +763,7 @@ test_expect_success 'format-patch from a subdirectory (1)' '
 		false
 		;;
 	esac &&
-	test -f "$filename"
+	test_path_is_file "$filename"
 '
 
 test_expect_success 'format-patch from a subdirectory (2)' '
@@ -782,7 +782,7 @@ test_expect_success 'format-patch from a subdirectory (2)' '
 		;;
 	esac &&
 	basename=$(expr "$filename" : ".*/\(.*\)") &&
-	test -f "sub/$basename"
+	test_path_is_file "sub/$basename"
 '
 
 test_expect_success 'format-patch from a subdirectory (3)' '
@@ -794,7 +794,7 @@ test_expect_success 'format-patch from a subdirectory (3)' '
 		git format-patch -1 -o "$TRASH_DIRECTORY"
 	) &&
 	basename=$(expr "$filename" : ".*/\(.*\)") &&
-	test -f "$basename"
+	test_path_is_file "$basename"
 '
 
 test_expect_success 'format-patch --in-reply-to' '

base-commit: d0e8084c65cbf949038ae4cc344ac2c2efd77415
-- 
2.42.0


             reply	other threads:[~2023-10-05 16:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-05  8:17 Vinayak Dev [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-10-05  7:11 [PATCH] t4014: replace "test -f" with "test_path_is_file" Vinayak Dev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231005081700.50473-1-vinayakdev.sci@gmail.com \
    --to=vinayakdev.sci@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).