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

Re: [PATCH 4/5] t/unit-tests: convert oidtree test to use clar

From
Pphillip.wood123@gmail.com <phillip.wood123@gmail.com>
Date
Feb 21, 2025, 14:48 UTC
Message-ID
<2d60f5ae-7985-4400-a4d1-0931dac0653e@gmail.com>
In-Reply-To
<20250220082959.10854-5-kuforiji98@gmail.com>
Hi Seyi
On 20/02/2025 08:29, Seyi Kuforiji wrote:
Show 10 quoted lines
> Adapt oidtree test script to clar framework by using clar assertions
> where necessary. `cl_parse_any_oid` handles the necessary checks needed
> for the test to run smoothly.
> 
> Introduce 'test_oidtree__initialize` handles the to set up of the global
> oidtree variable and `test_oidtree__cleanup` frees the oidtree when all
> tests are completed.
> 
> This streamlines the test suite, making individual tests self-contained
> and reducing redundant code.
My comments on the commit message for the last patch apply here as well.
Show 10 quoted lines
> -	if (!check_int(get_oid_arbitrary_hex(hex_iter->expected_hexes.v[hex_iter->i],
> -					     &expected), ==, 0))
> -		; /* the data is bogus and cannot be used */
> -	else if (!check(oideq(oid, &expected)))
> -		test_msg("expected: %s\n       got: %s\n     query: %s",
> -			 oid_to_hex(&expected), oid_to_hex(oid), hex_iter->query);
> +	cl_assert(hex_iter->i < hex_iter->expected_hexes.nr);
>   
> +	cl_parse_any_oid(hex_iter->expected_hexes.v[hex_iter->i],
> +			 &expected);

using cl_parse_any_oid() means that it is safe to dispense with the check on the return value because we now do that check in cl_parse_oid().

> +	cl_assert_equal_s(oid_to_hex(oid), oid_to_hex(&expected));

This is nice - we'll get a message containing the two oid's if they don't match. We should use the same trick in patch 2.

As with the last patch we now bail out after the first error, we should mention that in the commit message.

> -	if (!check_int(hex_iter.i, ==, hex_iter.expected_hexes.nr))
> -		test_msg("error: could not find some 'object_id's for query ('%s')", query);
> +	cl_assert_equal_i(hex_iter.i, hex_iter.expected_hexes.nr);

Using cl_failf() here would enable us to keep the message so that if the test fails we can see which query it was that failed.

Apart from that last point this is looking good
Best Wishes
Phillip
Previous: Seyi KuforijiNext: Seyi Kuforiji
Message 15 of 30 in “t/unit-tests: convert unit-tests to use clar”
  1. 0/5 t/unit-tests: convert unit-tests to use clarSeyi Kuforiji, Feb 20, 2025
  2. 1/5 t/unit-tests: implement oid helper functions in unit-tests.{c,h}Seyi Kuforiji, Feb 20, 2025
  3. Phillip WoodFeb 20, 2025
  4. Patrick SteinhardtFeb 21, 2025
  5. Patrick SteinhardtFeb 21, 2025
  6. phillip.wood123@gmail.comFeb 21, 2025
  7. 2/5 t/unit-tests: convert oid-array test to use clarSeyi Kuforiji, Feb 20, 2025
  8. Phillip WoodFeb 20, 2025
  9. Seyi ChamberFeb 24, 2025
  10. phillip.wood123@gmail.comFeb 24, 2025
  11. 3/5 t/unit-tests: convert oidmap test to use clarSeyi Kuforiji, Feb 20, 2025
  12. phillip.wood123@gmail.comFeb 21, 2025
  13. Seyi ChamberFeb 24, 2025
  14. 4/5 t/unit-tests: convert oidtree test to use clarSeyi Kuforiji, Feb 20, 2025
  15. phillip.wood123@gmail.comFeb 21, 2025
  16. 5/5 t/unit-tests: remove lib-oid.{c,h,o}Seyi Kuforiji, Feb 20, 2025
  17. phillip.wood123@gmail.comFeb 21, 2025
  18. 0/4 t/unit-tests: convert unit-tests to use clarSeyi Kuforiji, Feb 24, 2025
  19. 1/4 t/unit-tests: implement clar specific oid helper functionsSeyi Kuforiji, Feb 24, 2025
  20. Junio C HamanoFeb 24, 2025
  21. Seyi ChamberFeb 25, 2025
  22. Patrick SteinhardtFeb 25, 2025
  23. 2/4 t/unit-tests: convert oid-array test to use clar test frameworkSeyi Kuforiji, Feb 24, 2025
  24. 3/4 t/unit-tests: convert oidmap test to use clar test frameworkSeyi Kuforiji, Feb 24, 2025
  25. 4/4 t/unit-tests: convert oidtree test to use clar test frameworkSeyi Kuforiji, Feb 24, 2025
  26. 0/4 t/unit-tests: convert unit-tests to use clarSeyi Kuforiji, Feb 25, 2025
  27. 1/4 t/unit-tests: implement clar specific oid helper functionsSeyi Kuforiji, Feb 25, 2025
  28. 2/4 t/unit-tests: convert oid-array test to use clar test frameworkSeyi Kuforiji, Feb 25, 2025
  29. 3/4 t/unit-tests: convert oidmap test to use clar test frameworkSeyi Kuforiji, Feb 25, 2025
  30. 4/4 t/unit-tests: convert oidtree test to use clar test frameworkSeyi Kuforiji, Feb 25, 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.