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

[GSoC][PATCH v3 0/4] t: port reftable/readwrite_test.c to the unit testing framework

From
CPChandra Pratap <chandrapratap3519@gmail.com>
Date
Aug 13, 2024, 14:34 UTC
Message-ID
<20240813144440.4602-1-chandrapratap3519@gmail.com>
In-Reply-To
<20240809111312.4401-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/readwrite_test.c to the unit testing framework and improve upon the ported test. The first patch in the series 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 v3:
- Order the header files alphabetically in
  t/unit-tests/t-reftable-readwrite.c in patch 1.
- use check_char() and check_int() instead of check() at two
  instances in patch 1.
- #include 'reftable/basics.h' in patch 2 when introducing
  free_names() in the test file.
CI/PR: https://github.com/gitgitgadget/git/pull/1770

Chandra Pratap(4): t: move reftable/readwrite_test.c to the unit testing framework t-reftable-readwrite: use free_names() instead of a for loop t-reftable-readwrite: use 'for' in place of infinite 'while' loops t-reftable-readwrite: add test for known error

Makefile | 2 +- reftable/reftable-tests.h | 1 - t/helper/test-reftable.c | 1 - reftable/readwrite_test.c => t/unit-tests/t-reftable-readwrite.c | 441 +++++++++++++++++++++++----------------- 4 files changed, 219 insertions(+), 226 deletions(-)

Range-diff against v2:
1:  0ebe76c331 ! 1:  03b946434e t: move reftable/readwrite_test.c to the unit testing framework
    @@ t/unit-tests/t-reftable-readwrite.c: license that can be found in the LICENSE fi
     -#include "reftable-tests.h"
     -#include "reftable-writer.h"
     +#include "test-lib.h"
    -+#include "reftable/reader.h"
     +#include "reftable/blocksource.h"
    ++#include "reftable/reader.h"
     +#include "reftable/reftable-error.h"
     +#include "reftable/reftable-writer.h"
    @@ t/unit-tests/t-reftable-readwrite.c: static void write_table(char ***names, stru
     -		EXPECT(buf->buf[off] == 'r');
     +		if (!off)
     +			off = header_size((hash_id == GIT_SHA256_FORMAT_ID) ? 2 : 1);
    -+		check(buf->buf[off] == 'r');
    ++		check_char(buf->buf[off], ==, 'r');
      	}
     -	EXPECT(stats->log_stats.blocks > 0);
    -+	check(stats->log_stats.blocks > 0);
    ++	check_int(stats->log_stats.blocks, >, 0);
      	reftable_writer_free(w);
      }
2:  a148702451 ! 2:  e23a515736 t-reftable-readwrite: use free_names() instead of a for loop
    @@ Commit message
         Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
      ## t/unit-tests/t-reftable-readwrite.c ##
    +@@ t/unit-tests/t-reftable-readwrite.c: license that can be found in the LICENSE file or at
    + */
    +
    + #include "test-lib.h"
    ++#include "reftable/basics.h"
    + #include "reftable/blocksource.h"
    + #include "reftable/reader.h"
    + #include "reftable/reftable-error.h"
     @@ t/unit-tests/t-reftable-readwrite.c: static void t_table_read_api(void)
      	struct reftable_reader rd = { 0 };
      	struct reftable_block_source source = { 0 };
3:  ee15af6631 = 3:  9194a4055a t-reftable-readwrite: use 'for' in place of infinite 'while' loops
4:  3f571c09e2 = 4:  d34b01fad8 t-reftable-readwrite: add test for known error
Previous: Chandra PratapNext: Chandra Pratap
Message 22 of 30 in “t: port reftable/readwrite_test.c to the unit testing framework”
  1. Chandra PratapAug 7, 2024
  2. 1/5 t: move reftable/readwrite_test.c to the unit testing frameworkChandra Pratap, Aug 7, 2024
  3. 2/5 t-reftable-readwrite: use free_names() instead of a for loopChandra Pratap, Aug 7, 2024
  4. 3/5 t-reftable-readwrite: use 'for' in place of infinite 'while' loopsChandra Pratap, Aug 7, 2024
  5. 4/5 t-reftable-readwrite: add test for known errorChandra Pratap, Aug 7, 2024
  6. 5/5 t-reftable-readwrite: add tests for print functionsChandra Pratap, Aug 7, 2024
  7. Patrick SteinhardtAug 8, 2024
  8. Patrick SteinhardtAug 8, 2024
  9. Chandra PratapAug 8, 2024
  10. Junio C HamanoAug 9, 2024
  11. [GSoC][PATCH v2 0/4] t: port reftable/readwrite_test.c to the unit testing frameworkChandra Pratap, Aug 9, 2024
  12. 1/4 t: move reftable/readwrite_test.c to the unit testing frameworkChandra Pratap, Aug 9, 2024
  13. Junio C HamanoAug 9, 2024
  14. Chandra PratapAug 12, 2024
  15. 2/4 t-reftable-readwrite: use free_names() instead of a for loopChandra Pratap, Aug 9, 2024
  16. Junio C HamanoAug 9, 2024
  17. Chandra PratapAug 10, 2024
  18. Junio C HamanoAug 10, 2024
  19. 3/4 t-reftable-readwrite: use 'for' in place of infinite 'while' loopsChandra Pratap, Aug 9, 2024
  20. Junio C HamanoAug 9, 2024
  21. 4/4 t-reftable-readwrite: add test for known errorChandra Pratap, Aug 9, 2024
  22. [GSoC][PATCH v3 0/4] t: port reftable/readwrite_test.c to the unit testing frameworkChandra Pratap, Aug 13, 2024
  23. 1/4 t: move reftable/readwrite_test.c to the unit testing frameworkChandra Pratap, Aug 13, 2024
  24. Josh SteadmonAug 13, 2024
  25. Chandra PratapAug 14, 2024
  26. Patrick SteinhardtAug 14, 2024
  27. 2/4 t-reftable-readwrite: use free_names() instead of a for loopChandra Pratap, Aug 13, 2024
  28. 3/4 t-reftable-readwrite: use 'for' in place of infinite 'while' loopsChandra Pratap, Aug 13, 2024
  29. 4/4 t-reftable-readwrite: add test for known errorChandra Pratap, Aug 13, 2024
  30. Junio C HamanoAug 13, 2024

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.