All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Marcelo Machado Lage <marcelomlage@usp.br>
Cc: git@vger.kernel.org, Vinicius Lira de Freitas <vinilira@usp.br>,
	Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] t9811: replace 'test -f' and '! test -f' with 'test_path_*'
Date: Fri, 3 Jul 2026 10:19:51 +0200	[thread overview]
Message-ID: <akdwp_a2EuhVoGVW@pks.im> (raw)
In-Reply-To: <20260702140704.65805-1-marcelomlage@usp.br>

On Thu, Jul 02, 2026 at 11:07:04AM -0300, Marcelo Machado Lage wrote:
> Replace the basic shell commands 'test -f', with more modern test
> helpers 'test_path_is_file' and 'test_path_is_missing'.

Nit: it might make sense to briefly mention why we do this exercise.
Like, what does `test_path_is_file` et al give us over `test -f`?

> diff --git a/t/t9811-git-p4-label-import.sh b/t/t9811-git-p4-label-import.sh
> index 7614dfbd95..93d6b4c479 100755
> --- a/t/t9811-git-p4-label-import.sh
> +++ b/t/t9811-git-p4-label-import.sh
> @@ -62,9 +62,9 @@ test_expect_success 'basic p4 labels' '
>  
>  		cd main &&
>  		git checkout TAG_F1_ONLY &&
> -		! test -f f2 &&
> +		test_path_is_missing f2 &&
>  		git checkout TAG_WITH\$_SHELL_CHAR &&
> -		test -f f1 && test -f f2 && test -f file_with_\$metachar &&
> +		test_path_is_file f1 && test_path_is_file f2 && test_path_is_file file_with_\$metachar &&

While at it we could split this line into three lines -- it's getting
overly long, and we typically don't chain multiple commands on one line
nowadays.

> @@ -135,9 +135,9 @@ test_expect_success 'export git tags to p4' '
>  		p4 labels ... | grep LIGHTWEIGHT_TAG &&
>  		p4 label -o GIT_TAG_1 | grep "tag created in git:xyzzy" &&
>  		p4 sync ...@GIT_TAG_1 &&
> -		! test -f main/f10 &&
> +		test_path_is_missing main/f10 &&

This is a stronger guarantee compared to before, as we only checked
whether the path is not a file. Now we verify that it doesn't exist at
all, which would be equivalent to `test -e`. That's a strict improvement
though, but may be worth pointing out in the commit message so that the
reviewer is not surprised.

> @@ -168,9 +168,9 @@ test_expect_success 'export git tags to p4 with deletion' '
>  		cd "$cli" &&
>  		p4 sync ... &&
>  		p4 sync ...@GIT_TAG_ON_DELETED &&
> -		test -f main/deleted_file &&
> +		test_path_is_file main/deleted_file &&
>  		p4 sync ...@GIT_TAG_AFTER_DELETION &&
> -		! test -f main/deleted_file &&
> +		test_path_is_missing main/deleted_file &&

Same here.

Other than that the patch looks good to me, thanks!

Patrick

  reply	other threads:[~2026-07-03  8:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02 14:07 [PATCH] t9811: replace 'test -f' and '! test -f' with 'test_path_*' Marcelo Machado Lage
2026-07-03  8:19 ` Patrick Steinhardt [this message]
2026-07-03 20:48   ` Junio C Hamano
2026-07-06 15:00   ` Marcelo Machado Lage
2026-07-07 14:51     ` Patrick Steinhardt
2026-07-11 16:04 ` [PATCH v2 0/2] t9811: reformat and modernize tests Marcelo Machado Lage
2026-07-11 16:04   ` [PATCH v2 1/2] t9811: break long && chains into multiple lines Marcelo Machado Lage
2026-07-11 16:04   ` [PATCH v2 2/2] t9811: replace 'test -f' and '! test -f' with 'test_path_*' Marcelo Machado Lage
2026-07-13 11:10   ` [PATCH v2 0/2] t9811: reformat and modernize tests Patrick Steinhardt

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=akdwp_a2EuhVoGVW@pks.im \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=marcelomlage@usp.br \
    --cc=vinilira@usp.br \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.