Re: [PATCH 3/2] test-lib: document test_seq's "-f" option
- From
Justin Tobler <jltobler@gmail.com>
- Date
- Jun 25, 2025, 00:02 UTC
- Message-ID
- <k7znp2shqtfpuwpuzmku7o6txi6lph5kjwo6tsrszh5fzv7i2x@2fmrwxxpsify>
- In-Reply-To
- <20250624101124.GB636332@coredump.intra.peff.net>
On 25/06/24 06:11AM, Jeff King wrote:
Show 25 quoted lines
> On Mon, Jun 23, 2025 at 11:25:20AM -0500, Justin Tobler wrote:
>
> > > diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
> > > index bee4a2ca34..8c176f4efc 100644
> > > --- a/t/test-lib-functions.sh
> > > +++ b/t/test-lib-functions.sh
> > > @@ -1454,6 +1454,13 @@ test_cmp_fspath () {
> > > # from 1.
> > >
> > > test_seq () {
> > > + local fmt="%d"
> > > + case "$1" in
> > > + -f)
> > > + fmt="$2"
> >
> > With the `-f` option, the default format string gets overwritten to what
> > is provided by the user. Makes sense.
> >
> > If we want, we could update the comment above this function to mention
> > this new option.
>
> Good point. I didn't even notice that comment!
>
> Perhaps we should squash this in? I don't think there's any need to keep
> it as a separate commit.Ya, that seems reasonable to me.
Show 27 quoted lines
> -- >8 --
> Subject: [PATCH] test-lib: document test_seq's "-f" option
>
> The previous commit added the "-f" option, but didn't mention it in the
> function's documentation.
>
> Suggested-by: Justin Tobler <jltobler@gmail.com>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
> t/test-lib-functions.sh | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
> index 8c176f4efc..6230746cc4 100644
> --- a/t/test-lib-functions.sh
> +++ b/t/test-lib-functions.sh
> @@ -1451,7 +1451,12 @@ test_cmp_fspath () {
> # test_seq 1 5 -- outputs 1 2 3 4 5 one line at a time
> #
> # or with one argument (end), in which case it starts counting
> -# from 1.
> +# from 1. In addition to the start/end arguments, you can pass an optional
> +# printf format. For example:
> +#
> +# test_seq -f "line %d" 1 5
> +#
> +# would print 5 lines, "line 1" through "line 5".At first I thought it might be nice to mention that only format strings with a single specifier are supported, but I think this can also be implied since the comment mentions the format string follows the printf format.
This looks good to me :)
-Justin
Show 6 quoted lines
>
> test_seq () {
> local fmt="%d"
> --
> 2.50.0.399.g566d3d7b27
>