git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] t/unit-tests: convert trailer test to use clar

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 4, 2025, 17:59 UTC
Message-ID
<xmqqzfi0pthr.fsf@gitster.g>
In-Reply-To
<20250304113323.10564-2-kuforiji98@gmail.com>
Seyi Kuforiji <kuforiji98@gmail.com> writes:
Show 5 quoted lines
> diff --git a/t/unit-tests/u-trailer.c b/t/unit-tests/u-trailer.c
> new file mode 100644
> index 0000000000..3d60ea1603
> --- /dev/null
> +++ b/t/unit-tests/u-trailer.c

It is a bit sad (not your fault) that this is not shown as a rename+modification patch, as most of the logic seem to be straight out of the original.

Show 41 quoted lines
> +void test_trailer__no_newline_start(void)
> +{
> +	struct contents expected_contents[] = { 0 };
> +
> +	t_trailer_iterator("Fixes: x\n"
> +			   "Acked-by: x\n"
> +			   "Reviewed-by: x\n",
> +			   0,
> +			   expected_contents);
> +}
> +
> +void test_trailer__newline_start(void)
> +{
> +	struct contents expected_contents[] = {
> +		{
> +			.raw = "Fixes: x\n",
> +			.key = "Fixes",
> +			.val = "x",
> +		},
> +		{
> +			.raw = "Acked-by: x\n",
> +			.key = "Acked-by",
> +			.val = "x",
> +		},
> +		{
> +			.raw = "Reviewed-by: x\n",
> +			.key = "Reviewed-by",
> +			.val = "x",
> +		},
> +		{
> +			0
> +		},
> +	};
> +
> +	t_trailer_iterator("\n"
> +			   "Fixes: x\n"
> +			   "Acked-by: x\n"
> +			   "Reviewed-by: x\n",
> +			   3,
> +			   expected_contents);
> +}

This is inherited from the original, but the hardcoded "3" feels a bit brittle.

Would ARRAY_SIZE(expected_contents)-1 always match the expected number, I wonder? Even if it is, improving it is totally outside the scope of this topic. I am just mentioning this since I will forget if I don't ;-).

Previous: Seyi KuforijiNext: Seyi Kuforiji
Message 3 of 4 in “t/unit-tests: convert unit-tests to use clar”
  1. 0/2 t/unit-tests: convert unit-tests to use clarSeyi Kuforiji, Mar 4, 2025
  2. 1/2 t/unit-tests: convert trailer test to use clarSeyi Kuforiji, Mar 4, 2025
  3. Junio C HamanoMar 4, 2025
  4. 2/2 t/unit-tests: convert urlmatch-normalization test to clarSeyi Kuforiji, Mar 4, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.