From: Junio C Hamano <gitster@pobox.com>
To: Seyi Kuforiji <kuforiji98@gmail.com>
Cc: git@vger.kernel.org, ps@pks.im, phillip.wood@dunelm.org.uk
Subject: Re: [PATCH 1/2] t/unit-tests: match functions signature with trailing code
Date: Tue, 07 Jan 2025 10:41:00 -0800 [thread overview]
Message-ID: <xmqqv7uqsc03.fsf@gitster.g> (raw)
In-Reply-To: <xmqq7c76trpa.fsf@gitster.g> (Junio C. Hamano's message of "Tue, 07 Jan 2025 10:16:33 -0800")
Junio C Hamano <gitster@pobox.com> writes:
> A quick peek at [PATCH 2/2] tells me that this is not even something
> that would make it easier to port the existing tests by allowing
> more straight line-by-line copies or something. The patch splits
> many in-line test pieces in the "main" into separate functions, and
> it does so in a rather unusual format, e.g.,
>
> void test_hash__multi_character(void) TEST_HASH_STR("abc",
> "a9993e364706816aba3e25717850c26c9cd0d89d",
> "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad")
>
> where TEST_HASH_STR() expands to the function body that starts with
> a "{" and ends with a "}". It can well be written more like
>
> void test_hash__multi_character(void)
> {
> TEST_HASH_STR("abc",
> "a9993e364706816aba3e25717850c26c9cd0d89d",
> "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad");
> }
>
> and we do not need this step at all if we did so. Such a construct
> would be a lot friendlier to the editors that auto-indent, too.
>
> So, I do not quite see much value in this particular change.
Having said that, if this were more like that you write a series of
DEF_HASH_TEST(multi_character, "abc", "a9993e...", "ba7816bf...")
and they expand to
void test_hash__multi_character(void)
{
const char *expected[] = {"a9993e...", "ba7816bf..."};
check_hash_data("abc", strlen("abc"), expected);
}
then a preparatory step like this patch _might_ be justifiable. You
may want to avoid having to write too many boilerplate, and a
special rule to find "DEF_HASH_TEST(name, ...)" and it might make
sense to add support to extract the name of the test function being
defined by the macro automatically.
Not that I think such a sequence of DEF_HASH_TEST(), one per line,
is an improvement at all (it also is unfriendly to editors that
auto-indent the same way as your original version). I just wanted
to say that a change to the pattern to pick up the function name may
be justifiable if it were so.
Thanks.
next prev parent reply other threads:[~2025-01-07 18:41 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-07 9:19 [PATCH 0/2] t/unit-tests: convert hash tests to use clar Seyi Kuforiji
2025-01-07 9:19 ` [PATCH 1/2] t/unit-tests: match functions signature with trailing code Seyi Kuforiji
2025-01-07 18:16 ` Junio C Hamano
2025-01-07 18:41 ` Junio C Hamano [this message]
2025-01-08 6:14 ` Patrick Steinhardt
2025-01-08 8:31 ` Seyi Chamber
2025-01-08 15:27 ` Junio C Hamano
2025-01-08 16:15 ` Patrick Steinhardt
2025-01-07 9:19 ` [PATCH 2/2] t/unit-tests: convert hash to use clar test framework Seyi Kuforiji
2025-01-08 12:03 ` [PATCH v2 0/1] " Seyi Kuforiji
2025-01-08 12:03 ` [PATCH v2 1/1] " Seyi Kuforiji
2025-01-08 15:35 ` Junio C Hamano
2025-01-09 7:30 ` Seyi Chamber
2025-01-08 15:28 ` [PATCH v2 0/1] " Junio C Hamano
2025-01-09 7:21 ` Seyi Chamber
2025-01-09 14:09 ` [PATCH v3] " Seyi Kuforiji
2025-01-09 15:10 ` Patrick Steinhardt
2025-01-09 16:14 ` 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=xmqqv7uqsc03.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=kuforiji98@gmail.com \
--cc=phillip.wood@dunelm.org.uk \
--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).