git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chandra Pratap <chandrapratap3519@gmail.com>
To: git@vger.kernel.org
Cc: Patrick Steinhardt <ps@pks.im>,
	Christian Couder <chriscool@tuxfamily.org>,
	Chandra Pratap <chandrapratap3519@gmail.com>
Subject: [GSoC][PATCH v5 0/7] t: port reftable/pq_test.c to the unit testing framework
Date: Tue, 23 Jul 2024 19:47:10 +0530	[thread overview]
Message-ID: <20240723143032.4261-1-chandrapratap3519@gmail.com> (raw)
In-Reply-To: <20240614095136.12052-1-chandrapratap3519@gmail.com>

The reftable library comes with self tests, which are exercised
as part of the usual end-to-end tests and are designed to
observe the end-user visible effects of Git commands. What it
exercises, however, is a better match for the unit-testing
framework, merged at 8bf6fbd0 (Merge branch 'js/doc-unit-tests',
2023-12-09), which is designed to observe how low level
implementation details, at the level of sequences of individual
function calls, behave.

Hence, port reftable/pq_test.c to the unit testing framework and
improve upon the ported test. The first two patches in the series
are preparatory cleanup, the third patch moves the test to the unit
testing framework, and the rest of the patches 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 v5:
- Rebase the branch on top of the  latest master branch
- Rename tests according to unit-tests' conventions
- remove 'pq_test_main()' from reftable/reftable-test.h

CI/PR for v5: https://github.com/gitgitgadget/git/pull/1745

Chandra Pratap(7):
reftable: remove unncessary curly braces in reftable/pq.c
reftable: change the type of array indices to 'size_t' in reftable/pq.c
t: move reftable/pq_test.c to the unit testing framework
t-reftable-pq: make merged_iter_pqueue_check() static
t-reftable-pq: make merged_iter_pqueue_check() callable by reference
t-reftable-pq: add test for index based comparison
t-reftable-pq: add tests for merged_iter_pqueue_top()

Makefile                     |   2 +-
reftable/pq.c                |  29 +++-----
reftable/pq.h                |   1 -
reftable/pq_test.c           |  74 ---------------------
reftable/reftable-tests.h    |   1 -
t/helper/test-reftable.c     |   1 -
t/unit-tests/t-reftable-pq.c | 155 +++++++++++++++++++++++++++++++++++++++++++
7 files changed, 166 insertions(+), 97 deletions(-)

Range-diff against v4:
<rebase commits>
  1:  d3c5605ea2 = 382:  acd9d26aaf reftable: remove unncessary curly braces in reftable/pq.c
  2:  3c333e7770 = 383:  2e0986207b reftable: change the type of array indices to 'size_t' in reftable/pq.c
  3:  bf547f705a ! 384:  df06b6d604 t: move reftable/pq_test.c to the unit testing framework
    @@ Commit message
         t: move reftable/pq_test.c to the unit testing framework

         reftable/pq_test.c exercises a priority queue defined by
    -    reftable/pq.{c, h}. Migrate reftable/pq_test.c to the unit
    -    testing framework. Migration involves refactoring the tests
    -    to use the unit testing framework instead of reftable's test
    -    framework.
    +    reftable/pq.{c, h}. Migrate reftable/pq_test.c to the unit testing
    +    framework. Migration involves refactoring the tests to use the unit
    +    testing framework instead of reftable's test framework, and
    +    renaming the tests to align with unit-tests' standards.

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

      ## Makefile ##
    -@@ Makefile: THIRD_PARTY_SOURCES += sha1dc/%
    - UNIT_TEST_PROGRAMS += t-ctype
    - UNIT_TEST_PROGRAMS += t-mem-pool
    +@@ Makefile: UNIT_TEST_PROGRAMS += t-oidmap
    + UNIT_TEST_PROGRAMS += t-oidtree
      UNIT_TEST_PROGRAMS += t-prio-queue
    + UNIT_TEST_PROGRAMS += t-reftable-basics
     +UNIT_TEST_PROGRAMS += t-reftable-pq
    + UNIT_TEST_PROGRAMS += t-reftable-record
      UNIT_TEST_PROGRAMS += t-strbuf
      UNIT_TEST_PROGRAMS += t-strcmp-offset
    - UNIT_TEST_PROGRAMS += t-trailer
    -@@ Makefile: REFTABLE_TEST_OBJS += reftable/basics_test.o
    +@@ Makefile: REFTABLE_OBJS += reftable/writer.o
      REFTABLE_TEST_OBJS += reftable/block_test.o
      REFTABLE_TEST_OBJS += reftable/dump.o
      REFTABLE_TEST_OBJS += reftable/merged_test.o
     -REFTABLE_TEST_OBJS += reftable/pq_test.o
    - REFTABLE_TEST_OBJS += reftable/record_test.o
      REFTABLE_TEST_OBJS += reftable/readwrite_test.o
      REFTABLE_TEST_OBJS += reftable/stack_test.o
    + REFTABLE_TEST_OBJS += reftable/test_framework.o
    +
    + ## reftable/reftable-tests.h ##
    +@@ reftable/reftable-tests.h: license that can be found in the LICENSE file or at
    + int basics_test_main(int argc, const char **argv);
    + int block_test_main(int argc, const char **argv);
    + int merged_test_main(int argc, const char **argv);
    +-int pq_test_main(int argc, const char **argv);
    + int record_test_main(int argc, const char **argv);
    + int readwrite_test_main(int argc, const char **argv);
    + int stack_test_main(int argc, const char **argv);

      ## t/helper/test-reftable.c ##
     @@ t/helper/test-reftable.c: int cmd__reftable(int argc, const char **argv)
    - 	record_test_main(argc, argv);
    + 	/* test from simple to complex. */
      	block_test_main(argc, argv);
      	tree_test_main(argc, argv);
     -	pq_test_main(argc, argv);
    @@ t/unit-tests/t-reftable-pq.c: license that can be found in the LICENSE file or a
      	}
      }

    - static void test_pq(void)
    +-static void test_pq(void)
    ++static void t_pq(void)
      {
     -	struct merged_iter_pqueue pq = { NULL };
     +	struct merged_iter_pqueue pq = { 0 };
    @@ t/unit-tests/t-reftable-pq.c: static void test_pq(void)
      {
     -	RUN_TEST(test_pq);
     -	return 0;
    -+	TEST(test_pq(), "pq works");
    ++	TEST(t_pq(), "pq works");
     +
     +	return test_done();
      }
  4:  7dd3a2b27f = 385:  40745ab18e t-reftable-pq: make merged_iter_pqueue_check() static
  5:  c803e7adfc ! 386:  ee8432ac4a t-reftable-pq: make merged_iter_pqueue_check() callable by reference
    @@ t/unit-tests/t-reftable-pq.c: license that can be found in the LICENSE file or a
      	}
      }

    -@@ t/unit-tests/t-reftable-pq.c: static void test_pq(void)
    +@@ t/unit-tests/t-reftable-pq.c: static void t_pq(void)
      		};

      		merged_iter_pqueue_add(&pq, &e);
  6:  0b03f3567d ! 387:  94a77f5a60 t-reftable-pq: add test for index based comparison
    @@ t/unit-tests/t-reftable-pq.c: static void merged_iter_pqueue_check(const struct
      	}
      }

    --static void test_pq(void)
    -+static void test_pq_record(void)
    +-static void t_pq(void)
    ++static void t_pq_record(void)
      {
      	struct merged_iter_pqueue pq = { 0 };
      	struct reftable_record recs[54];
    -@@ t/unit-tests/t-reftable-pq.c: static void test_pq(void)
    +@@ t/unit-tests/t-reftable-pq.c: static void t_pq(void)
      	merged_iter_pqueue_release(&pq);
      }

    -+static void test_pq_index(void)
    ++static void t_pq_index(void)
     +{
     +	struct merged_iter_pqueue pq = { 0 };
     +	struct reftable_record recs[14];
    @@ t/unit-tests/t-reftable-pq.c: static void test_pq(void)
     +
      int cmd_main(int argc, const char *argv[])
      {
    --	TEST(test_pq(), "pq works");
    -+	TEST(test_pq_record(), "pq works with record-based comparison");
    -+	TEST(test_pq_index(), "pq works with index-based comparison");
    +-	TEST(t_pq(), "pq works");
    ++	TEST(t_pq_record(), "pq works with record-based comparison");
    ++	TEST(t_pq_index(), "pq works with index-based comparison");

      	return test_done();
      }
  7:  0cdfa6221e ! 388:  9a76f87bd1 t-reftable-pq: add tests for merged_iter_pqueue_top()
    @@ t/unit-tests/t-reftable-pq.c: static void merged_iter_pqueue_check(const struct
     +	return !reftable_record_cmp(a->rec, b->rec) && (a->index == b->index);
     +}
     +
    - static void test_pq_record(void)
    + static void t_pq_record(void)
      {
      	struct merged_iter_pqueue pq = { 0 };
    -@@ t/unit-tests/t-reftable-pq.c: static void test_pq_record(void)
    +@@ t/unit-tests/t-reftable-pq.c: static void t_pq_record(void)
      	} while (i != 1);

      	while (!merged_iter_pqueue_is_empty(pq)) {
    @@ t/unit-tests/t-reftable-pq.c: static void test_pq_record(void)
      		check(reftable_record_type(e.rec) == BLOCK_TYPE_REF);
      		if (last)
      			check_int(strcmp(last, e.rec->u.ref.refname), <, 0);
    -@@ t/unit-tests/t-reftable-pq.c: static void test_pq_index(void)
    +@@ t/unit-tests/t-reftable-pq.c: static void t_pq_index(void)
      	}

      	for (i = N - 1; !merged_iter_pqueue_is_empty(pq); i--) {
    @@ t/unit-tests/t-reftable-pq.c: static void test_pq_index(void)
      		check(reftable_record_type(e.rec) == BLOCK_TYPE_REF);
      		check_int(e.index, ==, i);
      		if (last)
    -@@ t/unit-tests/t-reftable-pq.c: static void test_pq_index(void)
    +@@ t/unit-tests/t-reftable-pq.c: static void t_pq_index(void)
      	merged_iter_pqueue_release(&pq);
      }

    -+static void test_merged_iter_pqueue_top(void)
    ++static void t_merged_iter_pqueue_top(void)
     +{
     +	struct merged_iter_pqueue pq = { 0 };
     +	struct reftable_record recs[14];
    @@ t/unit-tests/t-reftable-pq.c: static void test_pq_index(void)
     +
      int cmd_main(int argc, const char *argv[])
      {
    - 	TEST(test_pq_record(), "pq works with record-based comparison");
    - 	TEST(test_pq_index(), "pq works with index-based comparison");
    -+	TEST(test_merged_iter_pqueue_top(), "merged_iter_pqueue_top works");
    + 	TEST(t_pq_record(), "pq works with record-based comparison");
    + 	TEST(t_pq_index(), "pq works with index-based comparison");
    ++	TEST(t_merged_iter_pqueue_top(), "merged_iter_pqueue_top works");

      	return test_done();
      }


  parent reply	other threads:[~2024-07-23 14:33 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-06  7:40 [GSoC][PATCH 0/6] t: port reftable/pq_test.c to the unit testing Chandra Pratap
2024-06-06  7:40 ` [GSoC][PATCH 1/6] reftable: clean up reftable/pq.c Chandra Pratap
2024-06-06  8:51   ` Christian Couder
2024-06-06 10:07     ` Chandra Pratap
2024-06-06 16:23       ` Christian Couder
2024-06-06  7:40 ` [GSoC][PATCH 2/6] t: move reftable/pq_test.c to the unit testing framework Chandra Pratap
2024-06-06 11:48   ` Patrick Steinhardt
2024-06-06  7:40 ` [GSoC][PATCH 3/6] t-reftable-pq: make merged_iter_pqueue_check() static Chandra Pratap
2024-06-06  7:40 ` [GSoC][PATCH 4/6] t-reftable-pq: make merged_iter_pqueue_check() callable by reference Chandra Pratap
2024-06-06 11:48   ` Patrick Steinhardt
2024-06-06  7:40 ` [GSoC][PATCH 5/6] t-reftable-pq: add test for index based comparison Chandra Pratap
2024-06-06 11:48   ` Patrick Steinhardt
2024-06-06  7:40 ` [GSoC][PATCH 6/6] t-reftable-pq: add tests for merged_iter_pqueue_top() Chandra Pratap
2024-06-06 11:49   ` Patrick Steinhardt
2024-06-06 15:23 ` [GSoC][PATCH v2 0/6] t: port reftable/pq_test.c to the unit testing Chandra Pratap
2024-06-06 15:23   ` [GSoC][PATCH v2 1/6] reftable: clean up reftable/pq.c Chandra Pratap
2024-06-10  7:36     ` Patrick Steinhardt
2024-06-06 15:23   ` [GSoC][PATCH v2 2/6] t: move reftable/pq_test.c to the unit testing framework Chandra Pratap
2024-06-06 15:23   ` [GSoC][PATCH v2 3/6] t-reftable-pq: make merged_iter_pqueue_check() static Chandra Pratap
2024-06-06 15:23   ` [GSoC][PATCH v2 4/6] t-reftable-pq: make merged_iter_pqueue_check() callable by reference Chandra Pratap
2024-06-06 15:23   ` [GSoC][PATCH v2 5/6] t-reftable-pq: add test for index based comparison Chandra Pratap
2024-06-06 15:23   ` [GSoC][PATCH v2 6/6] t-reftable-pq: add tests for merged_iter_pqueue_top() Chandra Pratap
2024-06-11  8:19   ` [GSoC][PATCH v3 0/7] t: port reftable/pq_test.c to the unit testing framework Chandra Pratap
2024-06-11  8:19     ` [PATCH v3 1/7] reftable: remove unncessary curly braces in reftable/pq.c Chandra Pratap
2024-06-11  8:19     ` [PATCH v3 2/7] reftable: change the type of array indices to 'size_t' " Chandra Pratap
2024-06-11  9:02       ` Patrick Steinhardt
2024-06-11  8:19     ` [PATCH v3 3/7] t: move reftable/pq_test.c to the unit testing framework Chandra Pratap
2024-06-11  8:19     ` [PATCH v3 4/7] t-reftable-pq: make merged_iter_pqueue_check() static Chandra Pratap
2024-06-11  8:19     ` [PATCH v3 5/7] t-reftable-pq: make merged_iter_pqueue_check() callable by reference Chandra Pratap
2024-06-11  8:19     ` [PATCH v3 6/7] t-reftable-pq: add test for index based comparison Chandra Pratap
2024-06-11  8:19     ` [PATCH v3 7/7] t-reftable-pq: add tests for merged_iter_pqueue_top() Chandra Pratap
2024-06-14  9:48     ` [GSoC][PATCH v4 0/7] t: port reftable/pq_test.c to the unit testing framework Chandra Pratap
2024-06-14  9:48       ` [PATCH v4 1/7] reftable: remove unncessary curly braces in reftable/pq.c Chandra Pratap
2024-06-14  9:48       ` [PATCH v4 2/7] reftable: change the type of array indices to 'size_t' " Chandra Pratap
2024-06-14  9:48       ` [PATCH v4 3/7] t: move reftable/pq_test.c to the unit testing framework Chandra Pratap
2024-06-14  9:48       ` [PATCH v4 4/7] t-reftable-pq: make merged_iter_pqueue_check() static Chandra Pratap
2024-06-14  9:48       ` [PATCH v4 5/7] t-reftable-pq: make merged_iter_pqueue_check() callable by reference Chandra Pratap
2024-06-14  9:48       ` [PATCH v4 6/7] t-reftable-pq: add test for index based comparison Chandra Pratap
2024-06-14  9:48       ` [PATCH v4 7/7] t-reftable-pq: add tests for merged_iter_pqueue_top() Chandra Pratap
2024-06-14 17:40       ` [GSoC][PATCH v4 0/7] t: port reftable/pq_test.c to the unit testing framework Junio C Hamano
2024-07-23 14:17       ` Chandra Pratap [this message]
2024-07-23 14:17         ` [PATCH v5 1/7] reftable: remove unncessary curly braces in reftable/pq.c Chandra Pratap
2024-07-23 14:17         ` [PATCH v5 2/7] reftable: change the type of array indices to 'size_t' " Chandra Pratap
2024-07-23 14:17         ` [PATCH v5 3/7] t: move reftable/pq_test.c to the unit testing framework Chandra Pratap
2024-07-23 14:17         ` [PATCH v5 4/7] t-reftable-pq: make merged_iter_pqueue_check() static Chandra Pratap
2024-07-23 14:17         ` [PATCH v5 5/7] t-reftable-pq: make merged_iter_pqueue_check() callable by reference Chandra Pratap
2024-07-23 14:17         ` [PATCH v5 6/7] t-reftable-pq: add test for index based comparison Chandra Pratap
2024-07-24  9:03           ` Patrick Steinhardt
2024-07-24 16:15             ` Junio C Hamano
2024-07-25  5:10               ` Patrick Steinhardt
2024-07-23 14:17         ` [PATCH v5 7/7] t-reftable-pq: add tests for merged_iter_pqueue_top() Chandra Pratap
2024-07-23 17:09         ` [GSoC][PATCH v5 0/7] t: port reftable/pq_test.c to the unit testing framework Junio C Hamano
2024-07-24  5:12           ` Chandra Pratap
2024-07-24  7:17             ` Christian Couder
2024-07-24  7:51               ` Chandra Pratap
2024-07-24  8:56               ` Patrick Steinhardt
2024-07-24 16:06                 ` Junio C Hamano
2024-07-25  9:25         ` [GSoC][PATCH v6 " Chandra Pratap
2024-07-25  9:25           ` [PATCH v6 1/7] reftable: remove unncessary curly braces in reftable/pq.c Chandra Pratap
2024-07-25 13:29             ` Kristoffer Haugsbakk
2024-07-25  9:25           ` [PATCH v6 2/7] reftable: change the type of array indices to 'size_t' " Chandra Pratap
2024-07-25  9:25           ` [PATCH v6 3/7] t: move reftable/pq_test.c to the unit testing framework Chandra Pratap
2024-07-25  9:25           ` [PATCH v6 4/7] t-reftable-pq: make merged_iter_pqueue_check() static Chandra Pratap
2024-07-25  9:25           ` [PATCH v6 5/7] t-reftable-pq: make merged_iter_pqueue_check() callable by reference Chandra Pratap
2024-07-25  9:25           ` [PATCH v6 6/7] t-reftable-pq: add test for index based comparison Chandra Pratap
2024-07-30  6:03             ` Patrick Steinhardt
2024-07-25  9:25           ` [PATCH v6 7/7] t-reftable-pq: add tests for merged_iter_pqueue_top() Chandra Pratap
2024-07-30  6:04             ` Patrick Steinhardt
2024-08-01 10:59           ` [GSoC][PATCH v7 0/7] t: port reftable/pq_test.c to the unit testing framework Chandra Pratap
2024-08-01 10:59             ` [PATCH v7 1/7] reftable: remove unnecessary curly braces in reftable/pq.c Chandra Pratap
2024-08-01 10:59             ` [PATCH v7 2/7] reftable: change the type of array indices to 'size_t' " Chandra Pratap
2024-08-01 10:59             ` [PATCH v7 3/7] t: move reftable/pq_test.c to the unit testing framework Chandra Pratap
2024-08-01 10:59             ` [PATCH v7 4/7] t-reftable-pq: make merged_iter_pqueue_check() static Chandra Pratap
2024-08-01 10:59             ` [PATCH v7 5/7] t-reftable-pq: make merged_iter_pqueue_check() callable by reference Chandra Pratap
2024-08-01 10:59             ` [PATCH v7 6/7] t-reftable-pq: add test for index based comparison Chandra Pratap
2024-08-01 10:59             ` [PATCH v7 7/7] t-reftable-pq: add tests for merged_iter_pqueue_top() Chandra Pratap
2024-08-01 11:43             ` [GSoC][PATCH v7 0/7] t: port reftable/pq_test.c to the unit testing framework Patrick Steinhardt
2024-08-01 16:07               ` 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=20240723143032.4261-1-chandrapratap3519@gmail.com \
    --to=chandrapratap3519@gmail.com \
    --cc=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --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).