From: Junio C Hamano <gitster@pobox.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org,
Christian Couder <christian.couder@gmail.com>,
Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Subject: Re: [PATCH] SoC 2024: clarify `test_path_is_*` conversion microproject
Date: Mon, 04 Mar 2024 09:02:03 -0800 [thread overview]
Message-ID: <xmqqo7buq6b8.fsf@gitster.g> (raw)
In-Reply-To: <84995a068640c72c8f17406ffa0441c7fdba4bdc.1709543804.git.ps@pks.im> (Patrick Steinhardt's message of "Mon, 4 Mar 2024 10:16:55 +0100")
Patrick Steinhardt <ps@pks.im> writes:
> One of our proposed microprojects is to convert instances of `test -e`
> and related functions to instead use `test_path_exists` or similar. This
> conversion is only feasible when `test -e` is not used as part of a
> control statement, as the replacement is used to _assert_ a condition
> instead of merely testing for it.
>
> Clarify the microproject's description accordingly.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> SoC-2024-Microprojects.md | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/SoC-2024-Microprojects.md b/SoC-2024-Microprojects.md
> index 644c0a6..782441f 100644
> --- a/SoC-2024-Microprojects.md
> +++ b/SoC-2024-Microprojects.md
> @@ -41,7 +41,10 @@ to search, so that we can remove this microproject idea.
> Find one test script that verifies the presence/absence of
> files/directories with 'test -(e|f|d|...)' and replace them with the
> appropriate `test_path_is_file`, `test_path_is_dir`, etc. helper
> -functions.
> +functions. Note that this conversion does not directly apply to control
> +flow constructs like `if test -e ./path; then ...; fi` because the
> +replacements are intended to assert the condition instead of merely
> +testing for it.
Thanks for picking it up. Of course there is one case in which we
should use test_path_* helpers to replace such an if...then...fi
construct; e.g., c431a235 (t9146: replace test -d/-e/-f with
appropriate test_path_is_* function, 2024-02-14) did exactly that.
I am not sure how best to express that in the already crowded
description above, though. Rewriting the existing test this way
Find one test script that uses 'test [!] -(e|f|d|...)' to
assert the presence/absense of files/directories to make the
test fail directly with the exit status of such "test"
commands, and replace them with the appropriate helper
functions like `test_path_is_file`, that give more
informative error messages when they fail.
would exclude use of "test -e" as a conditional in control statements,
so we could mention what c431a235 did as an exception to the rule,
perhaps like
Note that the above excludes "test -f" and friends used as a
condition in control statements such as "if test -e path
...", but as an exception, if such a "if" statement just
open-codes what these helpers do, replacing it is warranted.
But that does not read very well, even to myself. Sigh....
Thanks.
next prev parent reply other threads:[~2024-03-04 17:02 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-29 15:04 [GSoC][PATCH 0/1] microproject: Use test_path_is_* functions in test scripts shejialuo
2024-02-29 15:04 ` [PATCH 1/1] [GSoC][PATCH] t3070: refactor test -e command shejialuo
2024-02-29 17:58 ` Eric Sunshine
2024-02-29 19:06 ` Junio C Hamano
2024-03-04 9:16 ` [PATCH] SoC 2024: clarify `test_path_is_*` conversion microproject Patrick Steinhardt
2024-03-04 13:42 ` Christian Couder
2024-03-04 17:02 ` Junio C Hamano [this message]
2024-03-04 9:17 ` [PATCH 1/1] [GSoC][PATCH] t3070: refactor test -e command Patrick Steinhardt
2024-03-01 2:50 ` shejialuo
2024-03-01 3:46 ` [PATCH V2 0/1] [GSoC][PATCH] t9117: prefer test_path_* helper functions shejialuo
2024-03-01 3:46 ` [PATCH 1/1] " shejialuo
2024-03-01 4:44 ` Eric Sunshine
2024-03-01 11:29 ` shejialuo
2024-03-01 5:09 ` Junio C Hamano
2024-03-01 11:36 ` shejialuo
2024-03-01 13:03 ` [PATCH v3 0/1] " shejialuo
2024-03-01 13:03 ` [PATCH v3 1/1] [PATCH] " shejialuo
2024-03-04 9:24 ` Patrick Steinhardt
2024-03-04 9:54 ` [PATCH v4 0/1] Change commit message shejialuo
2024-03-04 9:54 ` [PATCH v4 1/1] [PATCH] t9117: prefer test_path_* helper functions shejialuo
2024-03-04 9:59 ` Patrick Steinhardt
2024-03-04 11:45 ` shejialuo
2024-03-04 17:50 ` Junio C Hamano
2024-03-04 17:22 ` Junio C Hamano
2024-03-05 11:42 ` shejialuo
2024-03-04 17:19 ` [PATCH v4 0/1] Change commit message Junio C Hamano
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=xmqqo7buq6b8.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=kaartic.sivaraam@gmail.com \
--cc=ps@pks.im \
/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).