From: Taylor Blau <me@ttaylorr.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
Jeff King <peff@peff.net>
Subject: Re: [PATCH v4] test-lib-functions: use test-tool for [de]packetize()
Date: Fri, 16 Jul 2021 12:53:17 -0400 [thread overview]
Message-ID: <YPG5few/PeStqe/2@nand.local> (raw)
In-Reply-To: <patch-1.1-546974eed59-20210716T153909Z-avarab@gmail.com>
On Fri, Jul 16, 2021 at 05:41:33PM +0200, Ævar Arnfjörð Bjarmason wrote:
> I ejected changing/adding test code for this v4. This keeps the
> compatibility wrappers and just narrowly changes the things that need
> a packetize_raw() to use that new helper.
>
> I left the simpler packetize() case as a "printf", it could also use
> the test tool, but in case someone cares about process overhead on say
> Windows this entire change should be strictly better than the status
> quo.
Thanks, this version of the series looks much better to me.
> +static void pack_raw_stdin(void)
> +{
> + struct strbuf sb = STRBUF_INIT;
> +
> + if (strbuf_read(&sb, 0, 0) < 0)
> + die_errno("failed to read from stdin");
> + packet_write(1, sb.buf, sb.len);
> + strbuf_release(&sb);
> +}
> +
Looks good to me.
> -# convert function arguments or stdin (if not arguments given) to pktline
> -# representation. If multiple arguments are given, they are separated by
> -# whitespace and put in a single packet. Note that data containing NULs must be
> -# given on stdin, and that empty input becomes an empty packet, not a flush
> -# packet (for that you can just print 0000 yourself).
> +# These functions are historical wrappers around "test-tool pkt-line"
> +# for older tests. Use "test-tool pkt-line" itself in new tests.
Nice. This keeps the diff relatively minimal. I don't really have a
strong opinion on saying "packetize" or "test-tool pkt-line pack" in the
future. Arguably the latter is more direct, but it's also more of a
mouthful.
I'm fine to take the approach you have here, and adjust the guidance in
the future depending on if people really do start preferring one over
the other in new tests.
> packetize () {
> if test $# -gt 0
> then
> packet="$*"
> printf '%04x%s' "$((4 + ${#packet}))" "$packet"
> else
> - perl -e '
> - my $packet = do { local $/; <STDIN> };
> - printf "%04x%s", 4 + length($packet), $packet;
> - '
> + test-tool pkt-line pack
> fi
> }
For what it's worth, I would be happy to remove the printf shortcut
entirely. Some quick grepping indicates only 22 uses of the word
"packetize" in our whole test suite (one of them being the function
declaration itself). And of the 21 callers, only 10 pass at least one
argument:
git grep -Ew 'packetize [^()&]+' -- t
So I would be fine with adding 10 more new processes to the test suite
in the name of simplifying this declaration. I don't feel strongly,
though, since the conditional here does not really add that much
complexity.
Thanks,
Taylor
next prev parent reply other threads:[~2021-07-16 16:53 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-07 10:21 [PATCH 0/5] tests: migrate to "test-tool pkt-line" Ævar Arnfjörð Bjarmason
2021-07-07 10:21 ` [PATCH 1/5] serve tests: add missing "extra delim" test Ævar Arnfjörð Bjarmason
2021-07-07 10:21 ` [PATCH 2/5] serve tests: use test_cmp in "protocol violations" test Ævar Arnfjörð Bjarmason
2021-07-07 10:21 ` [PATCH 3/5] tests: replace [de]packetize() shell+perl test-tool pkt-line Ævar Arnfjörð Bjarmason
2021-07-07 10:21 ` [PATCH 4/5] tests: replace remaining packetize() with "test-tool pkt-line" Ævar Arnfjörð Bjarmason
2021-07-07 10:21 ` [PATCH 5/5] test-lib-functions.sh: remove unused [de]packetize() functions Ævar Arnfjörð Bjarmason
2021-07-12 16:44 ` [PATCH v2 0/5] tests: migrate to "test-tool pkt-line" Ævar Arnfjörð Bjarmason
2021-07-12 16:44 ` [PATCH v2 1/5] serve tests: add missing "extra delim" test Ævar Arnfjörð Bjarmason
2021-07-12 16:44 ` [PATCH v2 2/5] serve tests: use test_cmp in "protocol violations" test Ævar Arnfjörð Bjarmason
2021-07-12 16:44 ` [PATCH v2 3/5] tests: replace [de]packetize() shell+perl test-tool pkt-line Ævar Arnfjörð Bjarmason
2021-07-13 20:50 ` Jeff King
2021-07-13 23:41 ` Ævar Arnfjörð Bjarmason
2021-07-14 1:12 ` Jeff King
2021-07-12 16:44 ` [PATCH v2 4/5] tests: replace remaining packetize() with "test-tool pkt-line" Ævar Arnfjörð Bjarmason
2021-07-13 20:58 ` Jeff King
2021-07-13 23:52 ` Ævar Arnfjörð Bjarmason
2021-07-14 1:16 ` Jeff King
2021-07-12 16:44 ` [PATCH v2 5/5] test-lib-functions.sh: remove unused [de]packetize() functions Ævar Arnfjörð Bjarmason
2021-07-12 20:41 ` [PATCH v2 0/5] tests: migrate to "test-tool pkt-line" Junio C Hamano
2021-07-13 21:00 ` Jeff King
2021-07-14 0:54 ` [PATCH v3 " Ævar Arnfjörð Bjarmason
2021-07-14 0:54 ` [PATCH v3 1/5] serve tests: add missing "extra delim" test Ævar Arnfjörð Bjarmason
2021-07-14 0:54 ` [PATCH v3 2/5] serve tests: use test_cmp in "protocol violations" test Ævar Arnfjörð Bjarmason
2021-07-14 0:54 ` [PATCH v3 3/5] tests: replace [de]packetize() shell+perl test-tool pkt-line Ævar Arnfjörð Bjarmason
2021-07-14 4:04 ` Taylor Blau
2021-07-14 16:22 ` Junio C Hamano
2021-07-14 0:54 ` [PATCH v3 4/5] tests: replace remaining packetize() with "test-tool pkt-line" Ævar Arnfjörð Bjarmason
2021-07-14 0:54 ` [PATCH v3 5/5] test-lib-functions.sh: remove unused [de]packetize() functions Ævar Arnfjörð Bjarmason
2021-07-16 15:41 ` [PATCH v4] test-lib-functions: use test-tool for [de]packetize() Ævar Arnfjörð Bjarmason
2021-07-16 16:53 ` Taylor Blau [this message]
2021-07-16 19:08 ` Jeff King
2021-07-16 19:03 ` Jeff King
2021-07-19 18:54 ` 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=YPG5few/PeStqe/2@nand.local \
--to=me@ttaylorr.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/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).