mbox series

[GSoC,v3,0/4] t: port reftable/basics_test.c to the unit testing

Message ID 20240529171439.18271-1-chandrapratap3519@gmail.com (mailing list archive)
Headers show
Series t: port reftable/basics_test.c to the unit testing | expand

Message

Chandra Pratap May 29, 2024, 4:59 p.m. UTC
In the recent codebase update (commit 8bf6fbd, 2023-12-09), a new unit
testing framework written entirely in C was introduced to the Git project
aimed at simplifying testing and reducing test run times.
Currently, tests for the reftable refs-backend are performed by a custom
testing framework defined by reftable/test_framework.{c, h}. Port
reftable/basics_test.c to the unit testing framework and improve upon
the ported test.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>

---
Changes in v3:
- Split up the 4th patch of the previous series into 2 sub-patches

CI/PR for v3: https://github.com/gitgitgadget/git/pull/1736

range-diff against v2:

1:  3ab1b415f4 = 1:  3ab1b415f4 t: move reftable/basics_test.c to the unit testing framework
2:  51fec8a376 = 2:  0143bbd2e4 t: move tests from reftable/stack_test.c to the new unit test
3:  e0e9adfdf6 = 3:  2f1d02e945 t: move tests from reftable/record_test.c to the new unit test
-:  ---------- > 4:  14606ac8db t: add test for put_be16()
4:  81b8975b4c ! 5:  2e741bab6d t: add test for put_be16() and improve test-case for parse_names()
    @@ Metadata
     Author: Chandra Pratap <chandrapratap3519@gmail.com>

      ## Commit message ##
    -    t: add test for put_be16() and improve test-case for parse_names()
    +    t: improve the test-case for parse_names()

    -    put_be16() is a function defined in reftable/basics.{c, h} for which
    -    there are no tests in the current setup. Add a test for the same and
    -    improve the existing test-case for parse_names().
    +    In the existing test-case for parse_names(), the fact that empty
    +    lines should be ignored is not obvious because the empty line is
    +    immediately followed by end-of-string. This can be mistaken as the
    +    empty line getting replaced by NULL. Improve this by adding a
    +    non-empty line after the empty one to demonstrate the intended behavior.

         Mentored-by: Patrick Steinhardt <ps@pks.im>
         Mentored-by: Christian Couder <chriscool@tuxfamily.org>
    @@ t/unit-tests/t-reftable-basics.c: static void test_parse_names_normal(void)
      	free_names(out);
      }

    -@@ t/unit-tests/t-reftable-basics.c: static void test_common_prefix(void)
    - 	strbuf_release(&b);
    - }
    -
    --static void test_u24_roundtrip(void)
    -+static void test_be_roundtrip(void)
    - {
    - 	uint32_t in = 0x112233;
    - 	uint8_t dest[3];
    - 	uint32_t out;
    -+	/* test put_be24 and get_be24 roundtrip */
    - 	put_be24(dest, in);
    - 	out = get_be24(dest);
    - 	check_int(in, ==, out);
    -+	/* test put_be16 and get_be16 roundtrip */
    -+	in = 0xfef1;
    -+	put_be16(dest, in);
    -+	out = get_be16(dest);
    -+	check_int(in, ==, out);
    - }
    -
    - int cmd_main(int argc, const char *argv[])
    -@@ t/unit-tests/t-reftable-basics.c: int cmd_main(int argc, const char *argv[])
    - 	TEST(test_binsearch(), "binary search with binsearch works");
    - 	TEST(test_names_length(), "names_length retuns size of a NULL-terminated string array");
    - 	TEST(test_names_equal(), "names_equal compares NULL-terminated string arrays");
    --	TEST(test_u24_roundtrip(), "put_be24 and get_be24 work");
    -+	TEST(test_be_roundtrip(), "put_be24, get_be24 and put_be16 work");
    -
    - 	return test_done();
    - }

Comments

Patrick Steinhardt May 30, 2024, 4:35 a.m. UTC | #1
On Wed, May 29, 2024 at 10:29:26PM +0530, Chandra Pratap wrote:
> In the recent codebase update (commit 8bf6fbd, 2023-12-09), a new unit
> testing framework written entirely in C was introduced to the Git project
> aimed at simplifying testing and reducing test run times.
> Currently, tests for the reftable refs-backend are performed by a custom
> testing framework defined by reftable/test_framework.{c, h}. Port
> reftable/basics_test.c to the unit testing framework and improve upon
> the ported test.
> 
> Mentored-by: Patrick Steinhardt <ps@pks.im>
> Mentored-by: Christian Couder <chriscool@tuxfamily.org>
> Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>

This version looks good to me, thanks!

Patrick
Christian Couder May 30, 2024, 7:52 a.m. UTC | #2
On Thu, May 30, 2024 at 6:36 AM Patrick Steinhardt <ps@pks.im> wrote:
>
> On Wed, May 29, 2024 at 10:29:26PM +0530, Chandra Pratap wrote:
> > In the recent codebase update (commit 8bf6fbd, 2023-12-09), a new unit
> > testing framework written entirely in C was introduced to the Git project
> > aimed at simplifying testing and reducing test run times.
> > Currently, tests for the reftable refs-backend are performed by a custom
> > testing framework defined by reftable/test_framework.{c, h}. Port
> > reftable/basics_test.c to the unit testing framework and improve upon
> > the ported test.
> >
> > Mentored-by: Patrick Steinhardt <ps@pks.im>
> > Mentored-by: Christian Couder <chriscool@tuxfamily.org>
> > Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
>
> This version looks good to me, thanks!

It looks good to me too.
Junio C Hamano May 30, 2024, 2:33 p.m. UTC | #3
Christian Couder <christian.couder@gmail.com> writes:

> On Thu, May 30, 2024 at 6:36 AM Patrick Steinhardt <ps@pks.im> wrote:
>>
>> On Wed, May 29, 2024 at 10:29:26PM +0530, Chandra Pratap wrote:
>> > In the recent codebase update (commit 8bf6fbd, 2023-12-09), a new unit
>> > testing framework written entirely in C was introduced to the Git project
>> > aimed at simplifying testing and reducing test run times.
>> > Currently, tests for the reftable refs-backend are performed by a custom
>> > testing framework defined by reftable/test_framework.{c, h}. Port
>> > reftable/basics_test.c to the unit testing framework and improve upon
>> > the ported test.
>> >
>> > Mentored-by: Patrick Steinhardt <ps@pks.im>
>> > Mentored-by: Christian Couder <chriscool@tuxfamily.org>
>> > Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
>>
>> This version looks good to me, thanks!
>
> It looks good to me too.

Thanks, all.  Queued.