Skip to contentSkip to conversation

t/unit-tests: convert unit-tests to use clar

PATCH Superseded Seyi Kuforiji 4 participants 26 messages Jun 2, 2025 – Jun 5, 2025

Subsystems (3)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover t/unit-tests: convert unit-tests to use clar

Hello,

This small patch series marks the final batch of our existing unit test files transitioned to the Clar testing framework. It covers all the reftable-related test files, and is part of our ongoing effort to standardize our testing framework to enhance its maintainability.

Changes in v3:
- some code refactoring based on review, which includes initial creation of reftable helper functions to t/unit-tests/lib-reftable-clar-test.{c,h} files in the initial commit

Thanks
Seyi

Seyi Kuforiji (10):
t/unit-tests: implement clar specific reftable test helper functions t/unit-tests: convert reftable basics test to use clar test framework t/unit-tests: convert reftable block test to use clar t/unit-tests: convert reftable merged test to use clar t/unit-tests: convert reftable pq test to use clar t/unit-tests: convert reftable table test to use clar t/unit-tests: convert reftable readwrite test to use clar t/unit-tests: convert reftable record test to use clar t/unit-tests: convert reftable stack test to use clar t/unit-tests: finalize migration of reftable-related tests

 Makefile                                      |  22 +-
 t/Makefile                                    |   1 -
 t/meson.build                                 |  42 +-
 t/unit-tests/lib-reftable.c                   |  35 +-
 t/unit-tests/lib-reftable.h                   |  15 +-
 t/unit-tests/t-reftable-basics.c              | 219 ------
 t/unit-tests/u-reftable-basics.c              | 227 ++++++
 ...{t-reftable-block.c => u-reftable-block.c} | 164 ++--
 ...-reftable-merged.c => u-reftable-merged.c} | 160 ++--
 .../{t-reftable-pq.c => u-reftable-pq.c}      |  59 +-
 ...ble-readwrite.c => u-reftable-readwrite.c} | 384 ++++-----
 ...-reftable-record.c => u-reftable-record.c} | 217 +++---
 ...{t-reftable-stack.c => u-reftable-stack.c} | 726 +++++++-----------
 ...{t-reftable-table.c => u-reftable-table.c} |  71 +-
 14 files changed, 1021 insertions(+), 1321 deletions(-)
 delete mode 100644 t/unit-tests/t-reftable-basics.c
 create mode 100644 t/unit-tests/u-reftable-basics.c
 rename t/unit-tests/{t-reftable-block.c => u-reftable-block.c} (74%)
 rename t/unit-tests/{t-reftable-merged.c => u-reftable-merged.c} (77%)
 rename t/unit-tests/{t-reftable-pq.c => u-reftable-pq.c} (64%)
 rename t/unit-tests/{t-reftable-readwrite.c => u-reftable-readwrite.c} (69%)
 rename t/unit-tests/{t-reftable-record.c => u-reftable-record.c} (63%)
 rename t/unit-tests/{t-reftable-stack.c => u-reftable-stack.c} (59%)
 rename t/unit-tests/{t-reftable-table.c => u-reftable-table.c} (76%)

Range-diff against v2:
1: d85c5694ca ! 1: 53a64f5551 t/unit-tests: implement reftable test helper functions in unit-test.{c,h}
@@ Metadata
Author: Seyi Kuforiji <[email protected]>

## Commit message ##
- t/unit-tests: implement reftable test helper functions in unit-test.{c,h}
+ t/unit-tests: implement clar specific reftable test helper functions

Helper functions defined in t/unit-tests/lib-reftable.{c,h} are
- required for the reftable-related test files to run efficeintly. In the
- current implementation these functions are designed to conform with our
+ required for the reftable-related test files to run. In the current
+ implementation these functions are designed to conform with our
homegrown unit-testing structure. So in other to convert the reftable test files, there is need for a clar specific implementation of these helper functions.

- type cast `for (size_t i = 0; i < (size_t)stats->ref_stats.blocks;
- i++)`, implement equivalent helper functions in unit-test.{c,h} to use
- clar. These functions conform with the clar testing framework and become
- available for all reftable-related test files implemented using the clar
- testing framework, which requires them. This will be used by subsequent
- commits.
+ Implement equivalent helper functions in lib-reftable-clar.{c,h} to
+ use clar. These functions conform with the clar testing framework and
+ become available for all reftable-related test files implemented using
+ the clar testing framework, which requires them. This will be used by
+ subsequent commits.

- ## t/unit-tests/unit-test.c ##
+ ## Makefile ##
+@@ Makefile: CLAR_TEST_OBJS = $(patsubst %,$(UNIT_TEST_DIR)/%.o,$(CLAR_TEST_SUITES))
+ CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/clar/clar.o
+ CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
+ CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-oid.o
++CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable-clar.o
+
+ UNIT_TEST_PROGRAMS += t-reftable-basics
+ UNIT_TEST_PROGRAMS += t-reftable-block
+
+ ## t/meson.build ##
+@@ t/meson.build: clar_test_suites = [
+ clar_sources = [
+ 'unit-tests/clar/clar.c',
+ 'unit-tests/unit-test.c',
+- 'unit-tests/lib-oid.c'
++ 'unit-tests/lib-oid.c',
++ 'unit-tests/lib-reftable-clar.c'
+ ]
+
+ clar_decls_h = custom_target(
+
+ ## t/unit-tests/lib-reftable-clar.c (new) ##
@@
- #include "unit-test.h"
- #include "hex.h"
- #include "parse-options.h"
++#include "unit-test.h"
++#include "lib-reftable-clar.h"
++#include "hex.h"
++#include "parse-options.h"
+#include "reftable/constants.h"
+#include "reftable/writer.h"
- #include "strbuf.h"
- #include "string-list.h"
- #include "strvec.h"
-
++#include "strbuf.h"
++#include "string-list.h"
++#include "strvec.h"
++
+void cl_reftable_set_hash(uint8_t *p, int i, enum reftable_hash id) +{
+ memset(p, (uint8_t)i, hash_size(id));
@@ t/unit-tests/unit-test.c
+ struct reftable_writer *writer;
+ int ret = reftable_writer_new(&writer, &strbuf_writer_write, &strbuf_writer_flush,
+ buf, opts);
-+ cl_assert(ret == 0);
++ cl_assert(!ret);
+ return writer;
+}
+
@@ t/unit-tests/unit-test.c
+ }
+
+ writer = cl_reftable_strbuf_writer(buf, &opts);
-+ reftable_writer_set_limits(writer, min, max);
++ ret = reftable_writer_set_limits(writer, min, max);
++ cl_assert_equal_i(ret, 0);
+
+ if (nrefs) {
+ ret = reftable_writer_add_refs(writer, refs, nrefs);
@@ t/unit-tests/unit-test.c
+
+ reftable_writer_free(writer);
+}
-+
- static const char * const unit_test_usage[] = {
- N_("unit-test [<options>]"),
- NULL,

- ## t/unit-tests/unit-test.h ##
+ ## t/unit-tests/lib-reftable-clar.h (new) ##
@@
- #include "git-compat-util.h"
- #include "clar/clar.h"
- #include "clar-decls.h"
++#include "git-compat-util.h"
++#include "clar/clar.h"
++#include "clar-decls.h"
+#include "git-compat-util.h"
+#include "reftable/reftable-writer.h"
- #include "strbuf.h"
-
++#include "strbuf.h"
++
+struct reftable_buf;
+
+void cl_reftable_set_hash(uint8_t *p, int i, enum reftable_hash id);
+
+struct reftable_writer *cl_reftable_strbuf_writer(struct reftable_buf *buf,
-+ struct reftable_write_options *opts);
++ struct reftable_write_options *opts);
+
+void cl_reftable_write_to_buf(struct reftable_buf *buf,
+ struct reftable_ref_record *refs,
@@ t/unit-tests/unit-test.h
+ struct reftable_log_record *logs,
+ size_t nlogs,
+ struct reftable_write_options *opts);
-+
- #define cl_failf(fmt, ...) do { \
- char desc[4096]; \
- snprintf(desc, sizeof(desc), fmt, __VA_ARGS__); \
2: d24faa0176 ! 2: fec29d94d8 t/unit-tests: convert reftable basics test to use clar test framework

    @@ Makefile: CLAR_TEST_SUITES += u-oid-array
      CLAR_TEST_SUITES += u-reftable-tree
      CLAR_TEST_SUITES += u-strbuf
      CLAR_TEST_SUITES += u-strcmp-offset
    -@@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/clar/clar.o
    - CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
    +@@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
      CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-oid.o
    + CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable-clar.o
      
     -UNIT_TEST_PROGRAMS += t-reftable-basics
      UNIT_TEST_PROGRAMS += t-reftable-block
    @@ t/unit-tests/u-reftable-basics.c (new)
     +*/
     +
     +#include "unit-test.h"
    ++#include "lib-reftable-clar.h"
     +#include "reftable/basics.h"
     +
     +struct integer_needle_lesseq_args {
    @@ t/unit-tests/u-reftable-basics.c (new)
     +				&integer_needle_lesseq, &args);
     +		cl_assert_equal_i(idx, testcases[i].expected_idx);
     +	}
    -+
     +}
     +
     +void test_reftable_basics__names_length(void)
    @@ t/unit-tests/u-reftable-basics.c (new)
     +	free_names(out);
     +}
     +
    ++void test_reftable_basics__parse_names_drop_empty_string(void)
    ++{
    ++	char in[] = "a\n\nb\n";
    ++	char **out = parse_names(in, strlen(in));
    ++	cl_assert(out != NULL);
    ++	cl_assert_equal_s(out[0], "a");
    ++	/* simply '\n' should be dropped as empty string */
    ++	cl_assert_equal_s(out[1], "b");
    ++	cl_assert(out[2] == NULL);
    ++	free_names(out);
    ++}
    ++
     +void test_reftable_basics__common_prefix_size(void)
     +{
     +	struct reftable_buf a = REFTABLE_BUF_INIT;
    @@ t/unit-tests/u-reftable-basics.c (new)
     +	};
     +
     +	for (size_t i = 0; i < ARRAY_SIZE(cases); i++) {
    -+		reftable_buf_reset(&a);
    -+		reftable_buf_reset(&b);
     +		cl_assert_equal_i(reftable_buf_addstr(&a, cases[i].a), 0);
     +		cl_assert_equal_i(reftable_buf_addstr(&b, cases[i].b), 0);
     +		cl_assert_equal_i(common_prefix_size(&a, &b), cases[i].want);
    ++		reftable_buf_reset(&a);
    ++		reftable_buf_reset(&b);
     +	}
     +	reftable_buf_release(&a);
     +	reftable_buf_release(&b);
     +}
     +
    ++void test_reftable_basics__put_get_be64(void)
    ++{
    ++	uint64_t in = 0x1122334455667788;
    ++	uint8_t dest[8];
    ++	uint64_t out;
    ++	reftable_put_be64(dest, in);
    ++	out = reftable_get_be64(dest);
    ++	cl_assert(in == out);
    ++}
    ++
    ++void test_reftable_basics__put_get_be32(void)
    ++{
    ++	uint32_t in = 0x11223344;
    ++	uint8_t dest[4];
    ++	uint32_t out;
    ++	reftable_put_be32(dest, in);
    ++	out = reftable_get_be32(dest);
    ++	cl_assert_equal_i(in, out);
    ++}
    ++
     +void test_reftable_basics__put_get_be24(void)
     +{
     +	uint32_t in = 0x112233;
    @@ t/unit-tests/u-reftable-basics.c (new)
     +	cl_assert_equal_i(in, out);
     +}
     +
    -+void test_reftable_basics__grow_alloc(void)
    ++void test_reftable_basics__alloc_grow(void)
     +{
     +	int *arr = NULL, *old_arr;
     +	size_t alloc = 0, old_alloc;
    @@ t/unit-tests/u-reftable-basics.c (new)
     +	reftable_free(arr);
     +}
     +
    -+void test_reftable_basics__grow_alloc_or_null(void)
    ++void test_reftable_basics__alloc_grow_or_null(void)
     +{
     +	int *arr = NULL;
     +	size_t alloc = 0, old_alloc;
 3:  d9eb47645b !  3:  57d7541caa t/unit-tests: convert reftable block test to use clar
    @@ Makefile: CLAR_TEST_SUITES += u-oidmap
      CLAR_TEST_SUITES += u-reftable-tree
      CLAR_TEST_SUITES += u-strbuf
      CLAR_TEST_SUITES += u-strcmp-offset
    -@@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/clar/clar.o
    - CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
    +@@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
      CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-oid.o
    + CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable-clar.o
      
     -UNIT_TEST_PROGRAMS += t-reftable-block
      UNIT_TEST_PROGRAMS += t-reftable-merged
      UNIT_TEST_PROGRAMS += t-reftable-pq
    - UNIT_TEST_PROGRAMS += t-reftable-reader
    + UNIT_TEST_PROGRAMS += t-reftable-readwrite
     
      ## t/meson.build ##
     @@ t/meson.build: clar_test_suites = [
    @@ t/meson.build: clar_unit_tests = executable('unit-tests',
     -  'unit-tests/t-reftable-block.c',
        'unit-tests/t-reftable-merged.c',
        'unit-tests/t-reftable-pq.c',
    -   'unit-tests/t-reftable-reader.c',
    +   'unit-tests/t-reftable-readwrite.c',
     
      ## t/unit-tests/t-reftable-block.c => t/unit-tests/u-reftable-block.c ##
     @@ t/unit-tests/u-reftable-block.c: license that can be found in the LICENSE file or at
    @@ t/unit-tests/u-reftable-block.c: license that can be found in the LICENSE file o
      
     -#include "test-lib.h"
     +#include "unit-test.h"
    ++#include "lib-reftable-clar.h"
      #include "reftable/block.h"
      #include "reftable/blocksource.h"
      #include "reftable/constants.h"
    @@ t/unit-tests/u-reftable-block.c: license that can be found in the LICENSE file o
      	const int header_off = 21; /* random */
      	struct reftable_record recs[30];
     @@ t/unit-tests/u-reftable-block.c: static void t_ref_block_read_write(void)
    - 	struct reftable_buf want = REFTABLE_BUF_INIT, buf = REFTABLE_BUF_INIT;
    - 
    - 	REFTABLE_CALLOC_ARRAY(block.data, block_size);
    --	check(block.data != NULL);
    -+	cl_assert(block.data != NULL);
    - 	block.len = block_size;
    - 	block_source_from_buf(&block.source ,&buf);
    - 	ret = block_writer_init(&bw, BLOCK_TYPE_REF, block.data, block_size,
    + 	struct reftable_buf block_data = REFTABLE_BUF_INIT;
    + 
    + 	REFTABLE_CALLOC_ARRAY(block_data.buf, block_size);
    +-	check(block_data.buf != NULL);
    ++	cl_assert(block_data.buf != NULL);
    + 	block_data.len = block_size;
    + 
    +-	ret = block_writer_init(&bw, REFTABLE_BLOCK_TYPE_REF, (uint8_t *) block_data.buf, block_size,
    ++	ret = block_writer_init(&bw, REFTABLE_BLOCK_TYPE_REF,
    ++				(uint8_t *) block_data.buf, block_size,
      				header_off, hash_size(REFTABLE_HASH_SHA1));
     -	check(!ret);
     +	cl_assert(ret == 0);
    @@ t/unit-tests/u-reftable-block.c: static void t_ref_block_read_write(void)
      	}
      
      	for (i = 0; i < N; i++) {
    -@@ t/unit-tests/u-reftable-block.c: static void t_ref_block_read_write(void)
      		reftable_record_key(&recs[i], &want);
      
    - 		ret = block_iter_seek_key(&it, &br, &want);
    + 		ret = block_iter_seek_key(&it, &want);
     -		check_int(ret, ==, 0);
     +		cl_assert_equal_i(ret, 0);
      
    @@ t/unit-tests/u-reftable-block.c: static void t_ref_block_read_write(void)
     +		cl_assert_equal_i(reftable_record_equal(&recs[i], &rec, REFTABLE_HASH_SIZE_SHA1), 1);
      
      		want.len--;
    - 		ret = block_iter_seek_key(&it, &br, &want);
    + 		ret = block_iter_seek_key(&it, &want);
     -		check_int(ret, ==, 0);
     +		cl_assert_equal_i(ret, 0);
      
    @@ t/unit-tests/u-reftable-block.c: static void t_ref_block_read_write(void)
     +		cl_assert_equal_i(reftable_record_equal(&recs[10 * (i / 10)], &rec, REFTABLE_HASH_SIZE_SHA1), 1);
      	}
      
    - 	block_reader_release(&br);
    + 	reftable_block_release(&block);
     @@ t/unit-tests/u-reftable-block.c: static void t_ref_block_read_write(void)
      		reftable_record_release(&recs[i]);
      }
    @@ t/unit-tests/u-reftable-block.c: static void t_ref_block_read_write(void)
      	const int header_off = 21;
      	struct reftable_record recs[30];
     @@ t/unit-tests/u-reftable-block.c: static void t_log_block_read_write(void)
    - 	struct reftable_buf want = REFTABLE_BUF_INIT, buf = REFTABLE_BUF_INIT;
    - 
    - 	REFTABLE_CALLOC_ARRAY(block.data, block_size);
    --	check(block.data != NULL);
    -+	cl_assert(block.data != NULL);
    - 	block.len = block_size;
    - 	block_source_from_buf(&block.source ,&buf);
    - 	ret = block_writer_init(&bw, BLOCK_TYPE_LOG, block.data, block_size,
    + 	struct reftable_buf block_data = REFTABLE_BUF_INIT;
    + 
    + 	REFTABLE_CALLOC_ARRAY(block_data.buf, block_size);
    +-	check(block_data.buf != NULL);
    ++	cl_assert(block_data.buf != NULL);
    + 	block_data.len = block_size;
    + 
    + 	ret = block_writer_init(&bw, REFTABLE_BLOCK_TYPE_LOG, (uint8_t *) block_data.buf, block_size,
      				header_off, hash_size(REFTABLE_HASH_SHA1));
     -	check(!ret);
     +	cl_assert(ret == 0);
    @@ t/unit-tests/u-reftable-block.c: static void t_log_block_read_write(void)
      	}
      
      	for (i = 0; i < N; i++) {
    - 		block_iter_reset(&it);
      		reftable_buf_reset(&want);
     -		check(!reftable_buf_addstr(&want, recs[i].u.log.refname));
     +		cl_assert(reftable_buf_addstr(&want, recs[i].u.log.refname) == 0);
      
    - 		ret = block_iter_seek_key(&it, &br, &want);
    + 		ret = block_iter_seek_key(&it, &want);
     -		check_int(ret, ==, 0);
     +		cl_assert_equal_i(ret, 0);
      
    @@ t/unit-tests/u-reftable-block.c: static void t_log_block_read_write(void)
     +		cl_assert_equal_i(reftable_record_equal(&recs[i], &rec, REFTABLE_HASH_SIZE_SHA1), 1);
      
      		want.len--;
    - 		ret = block_iter_seek_key(&it, &br, &want);
    + 		ret = block_iter_seek_key(&it, &want);
     -		check_int(ret, ==, 0);
     +		cl_assert_equal_i(ret, 0);
      
    @@ t/unit-tests/u-reftable-block.c: static void t_log_block_read_write(void)
     +		cl_assert_equal_i(reftable_record_equal(&recs[10 * (i / 10)], &rec, REFTABLE_HASH_SIZE_SHA1), 1);
      	}
      
    - 	block_reader_release(&br);
    + 	reftable_block_release(&block);
     @@ t/unit-tests/u-reftable-block.c: static void t_log_block_read_write(void)
      		reftable_record_release(&recs[i]);
      }
    @@ t/unit-tests/u-reftable-block.c: static void t_log_block_read_write(void)
      	const int header_off = 21;
      	struct reftable_record recs[30];
     @@ t/unit-tests/u-reftable-block.c: static void t_obj_block_read_write(void)
    - 	struct reftable_buf want = REFTABLE_BUF_INIT, buf = REFTABLE_BUF_INIT;
    - 
    - 	REFTABLE_CALLOC_ARRAY(block.data, block_size);
    --	check(block.data != NULL);
    -+	cl_assert(block.data != NULL);
    - 	block.len = block_size;
    - 	block_source_from_buf(&block.source, &buf);
    - 	ret = block_writer_init(&bw, BLOCK_TYPE_OBJ, block.data, block_size,
    + 	struct reftable_buf block_data = REFTABLE_BUF_INIT;
    + 
    + 	REFTABLE_CALLOC_ARRAY(block_data.buf, block_size);
    +-	check(block_data.buf != NULL);
    ++	cl_assert(block_data.buf != NULL);
    + 	block_data.len = block_size;
    + 
    + 	ret = block_writer_init(&bw, REFTABLE_BLOCK_TYPE_OBJ, (uint8_t *) block_data.buf, block_size,
      				header_off, hash_size(REFTABLE_HASH_SHA1));
     -	check(!ret);
     +	cl_assert(ret == 0);
    @@ t/unit-tests/u-reftable-block.c: static void t_obj_block_read_write(void)
      	}
      
      	for (i = 0; i < N; i++) {
    -@@ t/unit-tests/u-reftable-block.c: static void t_obj_block_read_write(void)
      		reftable_record_key(&recs[i], &want);
      
    - 		ret = block_iter_seek_key(&it, &br, &want);
    + 		ret = block_iter_seek_key(&it, &want);
     -		check_int(ret, ==, 0);
     +		cl_assert_equal_i(ret, 0);
      
    @@ t/unit-tests/u-reftable-block.c: static void t_obj_block_read_write(void)
     +		cl_assert_equal_i(reftable_record_equal(&recs[i], &rec, REFTABLE_HASH_SIZE_SHA1), 1);
      	}
      
    - 	block_reader_release(&br);
    + 	reftable_block_release(&block);
     @@ t/unit-tests/u-reftable-block.c: static void t_obj_block_read_write(void)
      		reftable_record_release(&recs[i]);
      }
    @@ t/unit-tests/u-reftable-block.c: static void t_obj_block_read_write(void)
      	const int header_off = 21;
      	struct reftable_record recs[30];
     @@ t/unit-tests/u-reftable-block.c: static void t_index_block_read_write(void)
    - 	struct reftable_buf want = REFTABLE_BUF_INIT, buf = REFTABLE_BUF_INIT;
    - 
    - 	REFTABLE_CALLOC_ARRAY(block.data, block_size);
    --	check(block.data != NULL);
    -+	cl_assert(block.data != NULL);
    - 	block.len = block_size;
    - 	block_source_from_buf(&block.source, &buf);
    - 	ret = block_writer_init(&bw, BLOCK_TYPE_INDEX, block.data, block_size,
    + 	struct reftable_buf block_data = REFTABLE_BUF_INIT;
    + 
    + 	REFTABLE_CALLOC_ARRAY(block_data.buf, block_size);
    +-	check(block_data.buf != NULL);
    ++	cl_assert(block_data.buf != NULL);
    + 	block_data.len = block_size;
    + 
    + 	ret = block_writer_init(&bw, REFTABLE_BLOCK_TYPE_INDEX, (uint8_t *) block_data.buf, block_size,
      				header_off, hash_size(REFTABLE_HASH_SHA1));
     -	check(!ret);
     +	cl_assert(ret == 0);
    @@ t/unit-tests/u-reftable-block.c: static void t_index_block_read_write(void)
     @@ t/unit-tests/u-reftable-block.c: static void t_index_block_read_write(void)
      
      		reftable_buf_init(&recs[i].u.idx.last_key);
    - 		recs[i].type = BLOCK_TYPE_INDEX;
    + 		recs[i].type = REFTABLE_BLOCK_TYPE_INDEX;
     -		check(!reftable_buf_addstr(&recs[i].u.idx.last_key, buf));
    -+		cl_assert(reftable_buf_addstr(&recs[i].u.idx.last_key, buf) == 0);
    ++		cl_assert(!reftable_buf_addstr(&recs[i].u.idx.last_key, buf));
      		recs[i].u.idx.offset = i;
      
      		ret = block_writer_add(&bw, &recs[i]);
    @@ t/unit-tests/u-reftable-block.c: static void t_index_block_read_write(void)
      	}
      
      	for (i = 0; i < N; i++) {
    -@@ t/unit-tests/u-reftable-block.c: static void t_index_block_read_write(void)
      		reftable_record_key(&recs[i], &want);
      
    - 		ret = block_iter_seek_key(&it, &br, &want);
    + 		ret = block_iter_seek_key(&it, &want);
     -		check_int(ret, ==, 0);
     +		cl_assert_equal_i(ret, 0);
      
    @@ t/unit-tests/u-reftable-block.c: static void t_index_block_read_write(void)
     +		cl_assert_equal_i(reftable_record_equal(&recs[i], &rec, REFTABLE_HASH_SIZE_SHA1), 1);
      
      		want.len--;
    - 		ret = block_iter_seek_key(&it, &br, &want);
    + 		ret = block_iter_seek_key(&it, &want);
     -		check_int(ret, ==, 0);
     +		cl_assert_equal_i(ret, 0);
      
    @@ t/unit-tests/u-reftable-block.c: static void t_index_block_read_write(void)
     +		cl_assert_equal_i(reftable_record_equal(&recs[10 * (i / 10)], &rec, REFTABLE_HASH_SIZE_SHA1), 1);
      	}
      
    - 	block_reader_release(&br);
    + 	reftable_block_release(&block);
     @@ t/unit-tests/u-reftable-block.c: static void t_index_block_read_write(void)
    - 	for (i = 0; i < N; i++)
      		reftable_record_release(&recs[i]);
      }
    + 
    +-static void t_block_iterator(void)
    ++void test_reftable_block__iterator(void)
    + {
    + 	struct reftable_block_source source = { 0 };
    + 	struct block_writer writer = {
    +@@ t/unit-tests/u-reftable-block.c: static void t_block_iterator(void)
    + 
    + 	data.len = 1024;
    + 	REFTABLE_CALLOC_ARRAY(data.buf, data.len);
    +-	check(data.buf != NULL);
    ++	cl_assert(data.buf != NULL);
    + 
    +-	err = block_writer_init(&writer, REFTABLE_BLOCK_TYPE_REF, (uint8_t *) data.buf, data.len,
    ++	err = block_writer_init(&writer, REFTABLE_BLOCK_TYPE_REF,
    ++				(uint8_t *) data.buf, data.len,
    + 				0, hash_size(REFTABLE_HASH_SHA1));
    +-	check(!err);
    ++	cl_assert(!err);
    + 
    + 	for (size_t i = 0; i < ARRAY_SIZE(expected_refs); i++) {
    + 		expected_refs[i] = (struct reftable_record) {
    +@@ t/unit-tests/u-reftable-block.c: static void t_block_iterator(void)
    + 		memset(expected_refs[i].u.ref.value.val1, i, REFTABLE_HASH_SIZE_SHA1);
    + 
    + 		err = block_writer_add(&writer, &expected_refs[i]);
    +-		check_int(err, ==, 0);
    ++		cl_assert_equal_i(err, 0);
    + 	}
    + 
    + 	err = block_writer_finish(&writer);
    +-	check_int(err, >, 0);
    ++	cl_assert(err > 0);
    + 
    + 	block_source_from_buf(&source, &data);
    + 	reftable_block_init(&block, &source, 0, 0, data.len,
    + 			    REFTABLE_HASH_SIZE_SHA1, REFTABLE_BLOCK_TYPE_REF);
    + 
    + 	err = reftable_block_init_iterator(&block, &it);
    +-	check_int(err, ==, 0);
    ++	cl_assert_equal_i(err, 0);
    + 
    + 	for (size_t i = 0; ; i++) {
    + 		err = reftable_iterator_next_ref(&it, &ref);
    + 		if (err > 0) {
    +-			check_int(i, ==, ARRAY_SIZE(expected_refs));
    ++			cl_assert_equal_i(i, ARRAY_SIZE(expected_refs));
    + 			break;
    + 		}
    +-		check_int(err, ==, 0);
    ++		cl_assert_equal_i(err, 0);
    + 
    +-		check(reftable_ref_record_equal(&ref, &expected_refs[i].u.ref,
    +-						REFTABLE_HASH_SIZE_SHA1));
    ++		cl_assert(reftable_ref_record_equal(&ref,
    ++						    &expected_refs[i].u.ref, REFTABLE_HASH_SIZE_SHA1));
    + 	}
    + 
    + 	err = reftable_iterator_seek_ref(&it, "refs/heads/does-not-exist");
    +-	check_int(err, ==, 0);
    ++	cl_assert_equal_i(err, 0);
    + 	err = reftable_iterator_next_ref(&it, &ref);
    +-	check_int(err, ==, 1);
    ++	cl_assert_equal_i(err, 1);
    + 
    + 	err = reftable_iterator_seek_ref(&it, "refs/heads/branch-13");
    +-	check_int(err, ==, 0);
    ++	cl_assert_equal_i(err, 0);
    + 	err = reftable_iterator_next_ref(&it, &ref);
    +-	check_int(err, ==, 0);
    +-	check(reftable_ref_record_equal(&ref, &expected_refs[13].u.ref,
    +-					REFTABLE_HASH_SIZE_SHA1));
    ++	cl_assert_equal_i(err, 0);
    ++	cl_assert(reftable_ref_record_equal(&ref,
    ++					    &expected_refs[13].u.ref,REFTABLE_HASH_SIZE_SHA1));
    + 
    + 	for (size_t i = 0; i < ARRAY_SIZE(expected_refs); i++)
    + 		reftable_free(expected_refs[i].u.ref.refname);
    +@@ t/unit-tests/u-reftable-block.c: static void t_block_iterator(void)
    + 	block_writer_release(&writer);
    + 	reftable_buf_release(&data);
    + }
     -
     -int cmd_main(int argc UNUSED, const char *argv[] UNUSED)
     -{
    @@ t/unit-tests/u-reftable-block.c: static void t_index_block_read_write(void)
     -	TEST(t_log_block_read_write(), "read-write operations on log blocks work");
     -	TEST(t_obj_block_read_write(), "read-write operations on obj blocks work");
     -	TEST(t_ref_block_read_write(), "read-write operations on ref blocks work");
    +-	TEST(t_block_iterator(), "block iterator works");
     -
     -	return test_done();
     -}
 4:  6ffc7cdfc6 !  4:  db11c0eb30 t/unit-tests: convert reftable merged test to use clar
    @@ Makefile: CLAR_TEST_SUITES += u-oidtree
      CLAR_TEST_SUITES += u-reftable-tree
      CLAR_TEST_SUITES += u-strbuf
      CLAR_TEST_SUITES += u-strcmp-offset
    -@@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/clar/clar.o
    - CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
    +@@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
      CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-oid.o
    + CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable-clar.o
      
     -UNIT_TEST_PROGRAMS += t-reftable-merged
      UNIT_TEST_PROGRAMS += t-reftable-pq
    - UNIT_TEST_PROGRAMS += t-reftable-reader
      UNIT_TEST_PROGRAMS += t-reftable-readwrite
    + UNIT_TEST_PROGRAMS += t-reftable-record
     
      ## t/meson.build ##
     @@ t/meson.build: clar_test_suites = [
    @@ t/meson.build: clar_unit_tests = executable('unit-tests',
      unit_test_programs = [
     -  'unit-tests/t-reftable-merged.c',
        'unit-tests/t-reftable-pq.c',
    -   'unit-tests/t-reftable-reader.c',
        'unit-tests/t-reftable-readwrite.c',
    +   'unit-tests/t-reftable-record.c',
     
      ## t/unit-tests/t-reftable-merged.c => t/unit-tests/u-reftable-merged.c ##
     @@ t/unit-tests/u-reftable-merged.c: license that can be found in the LICENSE file or at
    @@ t/unit-tests/u-reftable-merged.c: license that can be found in the LICENSE file
      */
      
     -#include "test-lib.h"
    +-#include "lib-reftable.h"
     +#include "unit-test.h"
    - #include "lib-reftable.h"
    ++#include "lib-reftable-clar.h"
      #include "reftable/blocksource.h"
      #include "reftable/constants.h"
    + #include "reftable/merged.h"
     @@ t/unit-tests/u-reftable-merged.c: merged_table_from_records(struct reftable_ref_record **refs,
      	int err;
      
    - 	REFTABLE_CALLOC_ARRAY(*readers, n);
    --	check(*readers != NULL);
    -+	cl_assert(*readers != NULL);
    + 	REFTABLE_CALLOC_ARRAY(*tables, n);
    +-	check(*tables != NULL);
    ++	cl_assert(*tables != NULL);
      	REFTABLE_CALLOC_ARRAY(*source, n);
     -	check(*source != NULL);
     +	cl_assert(*source != NULL);
    @@ t/unit-tests/u-reftable-merged.c: merged_table_from_records(struct reftable_ref_
     +		cl_reftable_write_to_buf(&buf[i], refs[i], sizes[i], NULL, 0, &opts);
      		block_source_from_buf(&(*source)[i], &buf[i]);
      
    - 		err = reftable_reader_new(&(*readers)[i], &(*source)[i],
    - 					  "name");
    + 		err = reftable_table_new(&(*tables)[i], &(*source)[i],
    + 					 "name");
     -		check(!err);
    -+		cl_assert(err == 0);
    ++		cl_assert(!err);
      	}
      
    - 	err = reftable_merged_table_new(&mt, *readers, n, REFTABLE_HASH_SHA1);
    + 	err = reftable_merged_table_new(&mt, *tables, n, REFTABLE_HASH_SHA1);
     -	check(!err);
    -+	cl_assert(err == 0);
    ++	cl_assert(!err);
      	return mt;
      }
      
    -@@ t/unit-tests/u-reftable-merged.c: static void readers_destroy(struct reftable_reader **readers, const size_t n)
    - 	reftable_free(readers);
    +@@ t/unit-tests/u-reftable-merged.c: static void tables_destroy(struct reftable_table **tables, const size_t n)
    + 	reftable_free(tables);
      }
      
     -static void t_merged_single_record(void)
    -+void test_reftable_merged__merged_single_record(void)
    ++void test_reftable_merged__single_record(void)
      {
      	struct reftable_ref_record r1[] = { {
      		.refname = (char *) "b",
     @@ t/unit-tests/u-reftable-merged.c: static void t_merged_single_record(void)
      	int err;
      
    - 	err = merged_table_init_iter(mt, &it, BLOCK_TYPE_REF);
    + 	err = merged_table_init_iter(mt, &it, REFTABLE_BLOCK_TYPE_REF);
     -	check(!err);
    -+	cl_assert(err == 0);
    ++	cl_assert(!err);
      	err = reftable_iterator_seek_ref(&it, "a");
     -	check(!err);
     +	cl_assert(err == 0);
    @@ t/unit-tests/u-reftable-merged.c: static void t_merged_single_record(void)
     -	check(!err);
     -	check(reftable_ref_record_equal(&r2[0], &ref, REFTABLE_HASH_SIZE_SHA1));
     +	cl_assert(err == 0);
    -+	cl_assert(reftable_ref_record_equal(&r2[0], &ref, REFTABLE_HASH_SIZE_SHA1) != 0);
    ++	cl_assert(reftable_ref_record_equal(&r2[0], &ref,
    ++					    REFTABLE_HASH_SIZE_SHA1) != 0);
      	reftable_ref_record_release(&ref);
      	reftable_iterator_destroy(&it);
    - 	readers_destroy(readers, 3);
    + 	tables_destroy(tables, 3);
     @@ t/unit-tests/u-reftable-merged.c: static void t_merged_single_record(void)
      	reftable_free(bs);
      }
      
     -static void t_merged_refs(void)
    -+void test_reftable_merged__merged_refs(void)
    ++void test_reftable_merged__refs(void)
      {
      	struct reftable_ref_record r1[] = {
      		{
     @@ t/unit-tests/u-reftable-merged.c: static void t_merged_refs(void)
      	size_t i;
      
    - 	err = merged_table_init_iter(mt, &it, BLOCK_TYPE_REF);
    + 	err = merged_table_init_iter(mt, &it, REFTABLE_BLOCK_TYPE_REF);
     -	check(!err);
    -+	cl_assert(err == 0);
    ++	cl_assert(!err);
      	err = reftable_iterator_seek_ref(&it, "a");
     -	check(!err);
     -	check_int(reftable_merged_table_hash_id(mt), ==, REFTABLE_HASH_SHA1);
    @@ t/unit-tests/u-reftable-merged.c: static void t_merged_refs(void)
     -		check(reftable_ref_record_equal(want[i], &out[i],
     -						 REFTABLE_HASH_SIZE_SHA1));
     +		cl_assert(reftable_ref_record_equal(want[i], &out[i],
    -+											REFTABLE_HASH_SIZE_SHA1) != 0);
    ++						    REFTABLE_HASH_SIZE_SHA1) != 0);
      	for (i = 0; i < len; i++)
      		reftable_ref_record_release(&out[i]);
      	reftable_free(out);
    @@ t/unit-tests/u-reftable-merged.c: static void t_merged_refs(void)
      }
      
     -static void t_merged_seek_multiple_times(void)
    -+void test_reftable_merged__merged_seek_multiple_times(void)
    ++void test_reftable_merged__seek_multiple_times(void)
      {
      	struct reftable_ref_record r1[] = {
      		{
    @@ t/unit-tests/u-reftable-merged.c: static void t_merged_seek_multiple_times(void)
     -		check(err == 1);
     +		cl_assert(reftable_iterator_next_ref(&it, &rec) == 0);
     +		cl_assert_equal_i(reftable_ref_record_equal(&rec, &r1[1],
    -+													REFTABLE_HASH_SIZE_SHA1), 1);
    ++							    REFTABLE_HASH_SIZE_SHA1), 1);
      
     -		err = reftable_iterator_next_ref(&it, &rec);
     -		check(!err);
    @@ t/unit-tests/u-reftable-merged.c: static void t_merged_seek_multiple_times(void)
     -		check(err == 1);
     +		cl_assert(reftable_iterator_next_ref(&it, &rec) == 0);
     +		cl_assert_equal_i(reftable_ref_record_equal(&rec, &r2[1],
    -+													REFTABLE_HASH_SIZE_SHA1), 1);
    ++							    REFTABLE_HASH_SIZE_SHA1), 1);
      
     -		err = reftable_iterator_next_ref(&it, &rec);
     -		check(err > 0);
    @@ t/unit-tests/u-reftable-merged.c: static void t_merged_seek_multiple_times(void)
      }
      
     -static void t_merged_seek_multiple_times_without_draining(void)
    -+void test_reftable_merged__merged_seek_multiple_times_no_drain(void)
    ++void test_reftable_merged__seek_multiple_times_no_drain(void)
      {
      	struct reftable_ref_record r1[] = {
      		{
    @@ t/unit-tests/u-reftable-merged.c: static void t_merged_seek_multiple_times_witho
      	struct reftable_merged_table *mt;
     -	int err;
      
    - 	mt = merged_table_from_records(refs, &sources, &readers, sizes, bufs, 2);
    - 	merged_table_init_iter(mt, &it, BLOCK_TYPE_REF);
    + 	mt = merged_table_from_records(refs, &sources, &tables, sizes, bufs, 2);
    + 	merged_table_init_iter(mt, &it, REFTABLE_BLOCK_TYPE_REF);
      
     -	err = reftable_iterator_seek_ref(&it, "b");
     -	check(!err);
    @@ t/unit-tests/u-reftable-merged.c: static void t_merged_seek_multiple_times_witho
     +	cl_assert(reftable_iterator_seek_ref(&it, "b") == 0);
     +	cl_assert(reftable_iterator_next_ref(&it, &rec) == 0);
     +	cl_assert_equal_i(reftable_ref_record_equal(&rec, &r2[0],
    -+												REFTABLE_HASH_SIZE_SHA1), 1);
    ++						    REFTABLE_HASH_SIZE_SHA1), 1);
      
     -	err = reftable_iterator_seek_ref(&it, "a");
     -	check(!err);
    @@ t/unit-tests/u-reftable-merged.c: static void t_merged_seek_multiple_times_witho
     +	cl_assert(reftable_iterator_seek_ref(&it, "a") == 0);
     +	cl_assert(reftable_iterator_next_ref(&it, &rec) == 0);
     +	cl_assert_equal_i(reftable_ref_record_equal(&rec, &r1[0],
    -+												REFTABLE_HASH_SIZE_SHA1), 1);
    ++						    REFTABLE_HASH_SIZE_SHA1), 1);
      
      	for (size_t i = 0; i < ARRAY_SIZE(bufs); i++)
      		reftable_buf_release(&bufs[i]);
     @@ t/unit-tests/u-reftable-merged.c: merged_table_from_log_records(struct reftable_log_record **logs,
      	int err;
      
    - 	REFTABLE_CALLOC_ARRAY(*readers, n);
    --	check(*readers != NULL);
    -+	cl_assert(*readers != NULL);
    + 	REFTABLE_CALLOC_ARRAY(*tables, n);
    +-	check(*tables != NULL);
    ++	cl_assert(*tables != NULL);
      	REFTABLE_CALLOC_ARRAY(*source, n);
     -	check(*source != NULL);
     +	cl_assert(*source != NULL);
    @@ t/unit-tests/u-reftable-merged.c: merged_table_from_log_records(struct reftable_
     +		cl_reftable_write_to_buf(&buf[i], NULL, 0, logs[i], sizes[i], &opts);
      		block_source_from_buf(&(*source)[i], &buf[i]);
      
    - 		err = reftable_reader_new(&(*readers)[i], &(*source)[i],
    - 					  "name");
    + 		err = reftable_table_new(&(*tables)[i], &(*source)[i],
    + 					 "name");
     -		check(!err);
    -+		cl_assert(err == 0);
    ++		cl_assert(!err);
      	}
      
    --	err = reftable_merged_table_new(&mt, *readers, n, REFTABLE_HASH_SHA1);
    + 	err = reftable_merged_table_new(&mt, *tables, n, REFTABLE_HASH_SHA1);
     -	check(!err);
    -+	cl_assert(reftable_merged_table_new(&mt, *readers, n, REFTABLE_HASH_SHA1) == 0);
    ++	cl_assert(!err);
      	return mt;
      }
      
     -static void t_merged_logs(void)
    -+void test_reftable_merged__merged_logs(void)
    ++void test_reftable_merged__logs(void)
      {
      	struct reftable_log_record r1[] = {
      		{
     @@ t/unit-tests/u-reftable-merged.c: static void t_merged_logs(void)
      	struct reftable_merged_table *mt = merged_table_from_log_records(
    - 		logs, &bs, &readers, sizes, bufs, 3);
    + 		logs, &bs, &tables, sizes, bufs, 3);
      	struct reftable_iterator it = { 0 };
     -	int err;
      	struct reftable_log_record *out = NULL;
      	size_t len = 0;
      	size_t cap = 0;
      	size_t i;
    ++	int err;
      
    --	err = merged_table_init_iter(mt, &it, BLOCK_TYPE_LOG);
    + 	err = merged_table_init_iter(mt, &it, REFTABLE_BLOCK_TYPE_LOG);
     -	check(!err);
    --	err = reftable_iterator_seek_log(&it, "a");
    ++	cl_assert(!err);
    + 	err = reftable_iterator_seek_log(&it, "a");
     -	check(!err);
     -	check_int(reftable_merged_table_hash_id(mt), ==, REFTABLE_HASH_SHA1);
     -	check_int(reftable_merged_table_min_update_index(mt), ==, 1);
     -	check_int(reftable_merged_table_max_update_index(mt), ==, 3);
    -+	cl_assert(merged_table_init_iter(mt, &it, BLOCK_TYPE_LOG) == 0);
    -+	cl_assert(reftable_iterator_seek_log(&it, "a") == 0);
    ++	cl_assert(!err);
     +	cl_assert_equal_i(reftable_merged_table_hash_id(mt), REFTABLE_HASH_SHA1);
     +	cl_assert_equal_i(reftable_merged_table_min_update_index(mt), 1);
     +	cl_assert_equal_i(reftable_merged_table_max_update_index(mt), 3);
    @@ t/unit-tests/u-reftable-merged.c: static void t_merged_logs(void)
     -		check(reftable_log_record_equal(want[i], &out[i],
     -						 REFTABLE_HASH_SIZE_SHA1));
     +		cl_assert(reftable_log_record_equal(want[i], &out[i],
    -+											REFTABLE_HASH_SIZE_SHA1) != 0);
    ++						    REFTABLE_HASH_SIZE_SHA1) != 0);
      
    --	err = merged_table_init_iter(mt, &it, BLOCK_TYPE_LOG);
    + 	err = merged_table_init_iter(mt, &it, REFTABLE_BLOCK_TYPE_LOG);
     -	check(!err);
    --	err = reftable_iterator_seek_log_at(&it, "a", 2);
    ++	cl_assert(!err);
    + 	err = reftable_iterator_seek_log_at(&it, "a", 2);
     -	check(!err);
    -+	cl_assert(merged_table_init_iter(mt, &it, BLOCK_TYPE_LOG) == 0);
    -+	cl_assert(reftable_iterator_seek_log_at(&it, "a", 2) == 0);
    ++	cl_assert(!err);
      	reftable_log_record_release(&out[0]);
     -	err = reftable_iterator_next_log(&it, &out[0]);
     -	check(!err);
     -	check(reftable_log_record_equal(&out[0], &r3[0], REFTABLE_HASH_SIZE_SHA1));
     +	cl_assert(reftable_iterator_next_log(&it, &out[0]) == 0);
     +	cl_assert(reftable_log_record_equal(&out[0], &r3[0],
    -+										REFTABLE_HASH_SIZE_SHA1) != 0);
    ++					    REFTABLE_HASH_SIZE_SHA1) != 0);
      	reftable_iterator_destroy(&it);
      
      	for (i = 0; i < len; i++)
    @@ t/unit-tests/u-reftable-merged.c: static void t_default_write_opts(void)
      
      	block_source_from_buf(&source, &buf);
      
    --	err = reftable_reader_new(&rd, &source, "filename");
    + 	err = reftable_table_new(&table, &source, "filename");
     -	check(!err);
    -+	cl_assert(reftable_reader_new(&rd, &source, "filename") == 0);
    ++	cl_assert(!err);
      
    - 	hash_id = reftable_reader_hash_id(rd);
    + 	hash_id = reftable_table_hash_id(table);
     -	check_int(hash_id, ==, REFTABLE_HASH_SHA1);
     +	cl_assert_equal_i(hash_id, REFTABLE_HASH_SHA1);
      
    - 	err = reftable_merged_table_new(&merged, &rd, 1, REFTABLE_HASH_SHA256);
    + 	err = reftable_merged_table_new(&merged, &table, 1, REFTABLE_HASH_SHA256);
     -	check_int(err, ==, REFTABLE_FORMAT_ERROR);
    --	err = reftable_merged_table_new(&merged, &rd, 1, REFTABLE_HASH_SHA1);
    --	check(!err);
     +	cl_assert_equal_i(err, REFTABLE_FORMAT_ERROR);
    -+	cl_assert(reftable_merged_table_new(&merged, &rd, 1, REFTABLE_HASH_SHA1) == 0);
    + 	err = reftable_merged_table_new(&merged, &table, 1, REFTABLE_HASH_SHA1);
    +-	check(!err);
    ++	cl_assert(!err);
      
    - 	reftable_reader_decref(rd);
    + 	reftable_table_decref(table);
      	reftable_merged_table_free(merged);
      	reftable_buf_release(&buf);
      }
 5:  19b08968a0 !  5:  60cf81862a t/unit-tests: convert reftable pq test to use clar
    @@ Makefile: CLAR_TEST_SUITES += u-prio-queue
      CLAR_TEST_SUITES += u-reftable-tree
      CLAR_TEST_SUITES += u-strbuf
      CLAR_TEST_SUITES += u-strcmp-offset
    -@@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/clar/clar.o
    - CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
    +@@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
      CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-oid.o
    + CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable-clar.o
      
     -UNIT_TEST_PROGRAMS += t-reftable-pq
    - UNIT_TEST_PROGRAMS += t-reftable-reader
      UNIT_TEST_PROGRAMS += t-reftable-readwrite
      UNIT_TEST_PROGRAMS += t-reftable-record
    + UNIT_TEST_PROGRAMS += t-reftable-stack
     
      ## t/meson.build ##
     @@ t/meson.build: clar_test_suites = [
    @@ t/meson.build: clar_unit_tests = executable('unit-tests',
      
      unit_test_programs = [
     -  'unit-tests/t-reftable-pq.c',
    -   'unit-tests/t-reftable-reader.c',
    ++  'unit-tests/t-reftable-reader.c',
        'unit-tests/t-reftable-readwrite.c',
        'unit-tests/t-reftable-record.c',
    +   'unit-tests/t-reftable-stack.c',
     
      ## t/unit-tests/t-reftable-pq.c => t/unit-tests/u-reftable-pq.c ##
     @@ t/unit-tests/u-reftable-pq.c: license that can be found in the LICENSE file or at
    @@ t/unit-tests/u-reftable-pq.c: license that can be found in the LICENSE file or a
      
     -#include "test-lib.h"
     +#include "unit-test.h"
    ++#include "lib-reftable-clar.h"
      #include "reftable/constants.h"
      #include "reftable/pq.h"
      #include "strbuf.h"
    @@ t/unit-tests/u-reftable-pq.c: static void t_pq_record(void)
      	char *last = NULL;
      
      	for (i = 0; i < N; i++) {
    --		check(!reftable_record_init(&recs[i], BLOCK_TYPE_REF));
    -+		cl_assert(reftable_record_init(&recs[i], BLOCK_TYPE_REF) == 0);
    +-		check(!reftable_record_init(&recs[i], REFTABLE_BLOCK_TYPE_REF));
    ++		cl_assert(!reftable_record_init(&recs[i],
    ++						REFTABLE_BLOCK_TYPE_REF));
      		recs[i].u.ref.refname = xstrfmt("%02"PRIuMAX, (uintmax_t)i);
      	}
      
    @@ t/unit-tests/u-reftable-pq.c: static void t_pq_record(void)
      		merged_iter_pqueue_check(&pq);
      
     -		check(pq_entry_equal(&top, &e));
    --		check(reftable_record_type(e.rec) == BLOCK_TYPE_REF);
    -+		cl_assert(pq_entry_equal(&top, &e) != 0);
    -+		cl_assert(reftable_record_type(e.rec) == BLOCK_TYPE_REF);
    +-		check(reftable_record_type(e.rec) == REFTABLE_BLOCK_TYPE_REF);
    ++		cl_assert(pq_entry_equal(&top, &e));
    ++		cl_assert(reftable_record_type(e.rec) == REFTABLE_BLOCK_TYPE_REF);
      		if (last)
     -			check_int(strcmp(last, e.rec->u.ref.refname), <, 0);
     +			cl_assert(strcmp(last, e.rec->u.ref.refname) < 0);
    @@ t/unit-tests/u-reftable-pq.c: static void t_pq_index(void)
      	size_t N = ARRAY_SIZE(recs), i;
      
      	for (i = 0; i < N; i++) {
    --		check(!reftable_record_init(&recs[i], BLOCK_TYPE_REF));
    -+		cl_assert(reftable_record_init(&recs[i], BLOCK_TYPE_REF) == 0);
    +-		check(!reftable_record_init(&recs[i], REFTABLE_BLOCK_TYPE_REF));
    ++		cl_assert(!reftable_record_init(&recs[i],
    ++						REFTABLE_BLOCK_TYPE_REF));
      		recs[i].u.ref.refname = (char *) "refs/heads/master";
      	}
      
    @@ t/unit-tests/u-reftable-pq.c: static void t_pq_index(void)
      		merged_iter_pqueue_check(&pq);
      
     -		check(pq_entry_equal(&top, &e));
    --		check(reftable_record_type(e.rec) == BLOCK_TYPE_REF);
    +-		check(reftable_record_type(e.rec) == REFTABLE_BLOCK_TYPE_REF);
     -		check_int(e.index, ==, i);
    -+		cl_assert(pq_entry_equal(&top, &e) != 0);
    -+		cl_assert(reftable_record_type(e.rec) == BLOCK_TYPE_REF);
    ++		cl_assert(pq_entry_equal(&top, &e));
    ++		cl_assert(reftable_record_type(e.rec) == REFTABLE_BLOCK_TYPE_REF);
     +		cl_assert_equal_i(e.index, i);
      		if (last)
     -			check_str(last, e.rec->u.ref.refname);
    @@ t/unit-tests/u-reftable-pq.c: static void t_pq_index(void)
      	size_t N = ARRAY_SIZE(recs), i;
      
      	for (i = 0; i < N; i++) {
    --		check(!reftable_record_init(&recs[i], BLOCK_TYPE_REF));
    -+		cl_assert(reftable_record_init(&recs[i], BLOCK_TYPE_REF) == 0);
    +-		check(!reftable_record_init(&recs[i], REFTABLE_BLOCK_TYPE_REF));
    ++		cl_assert(!reftable_record_init(&recs[i],
    ++						REFTABLE_BLOCK_TYPE_REF));
      		recs[i].u.ref.refname = (char *) "refs/heads/master";
      	}
 6:  b34d6714ed <  -:  ---------- t/unit-tests: convert reftable reader test to use clar
 -:  ---------- >  6:  0eec9f7601 t/unit-tests: convert reftable table test to use clar
 7:  05c909ea94 !  7:  36bdd9b003 t/unit-tests: convert reftable readwrite test to use clar
    @@ Commit message
         Signed-off-by: Seyi Kuforiji <[email protected]>
     
      ## Makefile ##
    -@@ Makefile: CLAR_TEST_SUITES += u-reftable-block
    +@@ Makefile: CLAR_TEST_SUITES += u-reftable-basics
    + CLAR_TEST_SUITES += u-reftable-block
      CLAR_TEST_SUITES += u-reftable-merged
      CLAR_TEST_SUITES += u-reftable-pq
    - CLAR_TEST_SUITES += u-reftable-reader
     +CLAR_TEST_SUITES += u-reftable-readwrite
    + CLAR_TEST_SUITES += u-reftable-table
      CLAR_TEST_SUITES += u-reftable-tree
      CLAR_TEST_SUITES += u-strbuf
    - CLAR_TEST_SUITES += u-strcmp-offset
    -@@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/clar/clar.o
    - CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
    +@@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
      CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-oid.o
    + CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable-clar.o
      
     -UNIT_TEST_PROGRAMS += t-reftable-readwrite
      UNIT_TEST_PROGRAMS += t-reftable-record
    @@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/clar/clar.o
     
      ## t/meson.build ##
     @@ t/meson.build: clar_test_suites = [
    +   'unit-tests/u-reftable-block.c',
        'unit-tests/u-reftable-merged.c',
        'unit-tests/u-reftable-pq.c',
    -   'unit-tests/u-reftable-reader.c',
     +  'unit-tests/u-reftable-readwrite.c',
    +   'unit-tests/u-reftable-table.c',
        'unit-tests/u-reftable-tree.c',
        'unit-tests/u-strbuf.c',
    -   'unit-tests/u-strcmp-offset.c',
     @@ t/meson.build: clar_unit_tests = executable('unit-tests',
      test('unit-tests', clar_unit_tests)
      
    @@ t/unit-tests/u-reftable-readwrite.c: license that can be found in the LICENSE fi
      #define DISABLE_SIGN_COMPARE_WARNINGS
      
     -#include "test-lib.h"
    +-#include "lib-reftable.h"
     +#include "unit-test.h"
    - #include "lib-reftable.h"
    ++#include "lib-reftable-clar.h"
      #include "reftable/basics.h"
      #include "reftable/blocksource.h"
    + #include "reftable/reftable-error.h"
     @@ t/unit-tests/u-reftable-readwrite.c: license that can be found in the LICENSE file or at
      
      static const int update_index = 5;
    @@ t/unit-tests/u-reftable-readwrite.c: license that can be found in the LICENSE fi
      {
      	struct reftable_buf buf = REFTABLE_BUF_INIT;
      	struct reftable_block_source source = { 0 };
    - 	struct reftable_block out = { 0 };
    + 	struct reftable_block_data out = { 0 };
      	int n;
      	uint8_t in[] = "hello";
     -	check(!reftable_buf_add(&buf, in, sizeof(in)));
    @@ t/unit-tests/u-reftable-readwrite.c: license that can be found in the LICENSE fi
      	block_source_from_buf(&source, &buf);
     -	check_int(block_source_size(&source), ==, 6);
     +	cl_assert_equal_i(block_source_size(&source), 6);
    - 	n = block_source_read_block(&source, &out, 0, sizeof(in));
    + 	n = block_source_read_data(&source, &out, 0, sizeof(in));
     -	check_int(n, ==, sizeof(in));
     -	check(!memcmp(in, out.data, n));
     +	cl_assert_equal_i(n, sizeof(in));
    -+	cl_assert(memcmp(in, out.data, n) == 0);
    - 	reftable_block_done(&out);
    ++	cl_assert(!memcmp(in, out.data, n));
    + 	block_source_release_data(&out);
      
    --	n = block_source_read_block(&source, &out, 1, 2);
    + 	n = block_source_read_data(&source, &out, 1, 2);
     -	check_int(n, ==, 2);
     -	check(!memcmp(out.data, "el", 2));
    -+	cl_assert_equal_i(block_source_read_block(&source, &out, 1, 2), 2);
    -+	cl_assert(memcmp(out.data, "el", 2) == 0);
    ++	cl_assert_equal_i(n, 2);
    ++	cl_assert(!memcmp(out.data, "el", 2));
      
    - 	reftable_block_done(&out);
    + 	block_source_release_data(&out);
      	block_source_close(&source);
     @@ t/unit-tests/u-reftable-readwrite.c: static void write_table(char ***names, struct reftable_buf *buf, int N,
      	int i;
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_log_write_limits(void)
      	struct reftable_write_options opts = {
      		.block_size = 256,
     @@ t/unit-tests/u-reftable-readwrite.c: static void t_log_write_read(void)
    - 	struct reftable_reader *reader;
    + 	struct reftable_table *table;
      	struct reftable_block_source source = { 0 };
      	struct reftable_buf buf = REFTABLE_BUF_INIT;
     -	struct reftable_writer *w = t_reftable_strbuf_writer(&buf, &opts);
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_log_write_read(void)
     -	int N = 2, err, i, n;
     +	int N = 2, i;
      	char **names;
    ++	int err;
      
      	names = reftable_calloc(N + 1, sizeof(*names));
     -	check(names != NULL);
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_log_write_read(void)
      
      	block_source_from_buf(&source, &buf);
      
    --	err = reftable_reader_new(&reader, &source, "file.log");
    + 	err = reftable_table_new(&table, &source, "file.log");
     -	check(!err);
    --
    --	err = reftable_reader_init_ref_iterator(reader, &it);
    ++	cl_assert(!err);
    + 
    + 	err = reftable_table_init_ref_iterator(table, &it);
     -	check(!err);
    --
    --	err = reftable_iterator_seek_ref(&it, names[N - 1]);
    ++	cl_assert(!err);
    + 
    + 	err = reftable_iterator_seek_ref(&it, names[N - 1]);
     -	check(!err);
    --
    --	err = reftable_iterator_next_ref(&it, &ref);
    ++	cl_assert(!err);
    + 
    + 	err = reftable_iterator_next_ref(&it, &ref);
     -	check(!err);
    -+	cl_assert(reftable_reader_new(&reader, &source, "file.log") == 0);
    -+	cl_assert(reftable_reader_init_ref_iterator(reader, &it) == 0);
    -+	cl_assert(reftable_iterator_seek_ref(&it, names[N - 1]) == 0);
    -+	cl_assert(reftable_iterator_next_ref(&it, &ref) == 0);
    ++	cl_assert(!err);
      
      	/* end of iteration. */
     -	err = reftable_iterator_next_ref(&it, &ref);
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_log_write_read(void)
      	reftable_iterator_destroy(&it);
      	reftable_ref_record_release(&ref);
      
    --	err = reftable_reader_init_log_iterator(reader, &it);
    + 	err = reftable_table_init_log_iterator(table, &it);
     -	check(!err);
    --	err = reftable_iterator_seek_log(&it, "");
    ++	cl_assert(!err);
    + 	err = reftable_iterator_seek_log(&it, "");
     -	check(!err);
    -+	cl_assert(reftable_reader_init_log_iterator(reader, &it) == 0);
    -+	cl_assert(reftable_iterator_seek_log(&it, "") == 0);
    ++	cl_assert(!err);
      
      	for (i = 0; ; i++) {
      		int err = reftable_iterator_next_log(&it, &log);
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_log_write_read(void)
      
      	/* cleanup. */
     @@ t/unit-tests/u-reftable-readwrite.c: static void t_log_write_read(void)
    - 	reftable_reader_decref(reader);
    + 	reftable_table_decref(table);
      }
      
     -static void t_log_zlib_corruption(void)
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_log_write_read(void)
      	struct reftable_write_options opts = {
      		.block_size = 256,
     @@ t/unit-tests/u-reftable-readwrite.c: static void t_log_zlib_corruption(void)
    - 	struct reftable_reader *reader;
    + 	struct reftable_table *table;
      	struct reftable_block_source source = { 0 };
      	struct reftable_buf buf = REFTABLE_BUF_INIT;
     -	struct reftable_writer *w = t_reftable_strbuf_writer(&buf, &opts);
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_log_zlib_corruption(void)
      	char message[100] = { 0 };
     -	int err, i, n;
     +	int i;
    ++	int err;
      	struct reftable_log_record log = {
      		.refname = (char *) "refname",
      		.value_type = REFTABLE_LOG_UPDATE,
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_log_zlib_corruption(void)
      	w = NULL;
      
     @@ t/unit-tests/u-reftable-readwrite.c: static void t_log_zlib_corruption(void)
    - 
      	block_source_from_buf(&source, &buf);
      
    --	err = reftable_reader_new(&reader, &source, "file.log");
    + 	err = reftable_table_new(&table, &source, "file.log");
     -	check(!err);
    --
    --	err = reftable_reader_init_log_iterator(reader, &it);
    ++	cl_assert(!err);
    + 
    + 	err = reftable_table_init_log_iterator(table, &it);
     -	check(!err);
    --	err = reftable_iterator_seek_log(&it, "refname");
    ++	cl_assert(!err);
    + 	err = reftable_iterator_seek_log(&it, "refname");
     -	check_int(err, ==, REFTABLE_ZLIB_ERROR);
    -+	cl_assert(reftable_reader_new(&reader, &source, "file.log") == 0);
    -+	cl_assert(reftable_reader_init_log_iterator(reader, &it) == 0);
    -+	cl_assert_equal_i(reftable_iterator_seek_log(&it, "refname"), REFTABLE_ZLIB_ERROR);
    ++	cl_assert_equal_i(err, REFTABLE_ZLIB_ERROR);
      
      	reftable_iterator_destroy(&it);
      
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_log_zlib_corruption(void)
      	char **names;
      	struct reftable_buf buf = REFTABLE_BUF_INIT;
     @@ t/unit-tests/u-reftable-readwrite.c: static void t_table_read_write_sequential(void)
    - 	struct reftable_iterator it = { 0 };
    - 	struct reftable_block_source source = { 0 };
    - 	struct reftable_reader *reader;
    --	int err = 0;
    - 	int j = 0;
    - 
    - 	write_table(&names, &buf, N, 256, REFTABLE_HASH_SHA1);
    - 
      	block_source_from_buf(&source, &buf);
      
    --	err = reftable_reader_new(&reader, &source, "file.ref");
    + 	err = reftable_table_new(&table, &source, "file.ref");
     -	check(!err);
    --
    --	err = reftable_reader_init_ref_iterator(reader, &it);
    ++	cl_assert(!err);
    + 
    + 	err = reftable_table_init_ref_iterator(table, &it);
     -	check(!err);
    --	err = reftable_iterator_seek_ref(&it, "");
    ++	cl_assert(!err);
    + 	err = reftable_iterator_seek_ref(&it, "");
     -	check(!err);
    -+	cl_assert(reftable_reader_new(&reader, &source, "file.ref") == 0);
    -+	cl_assert(reftable_reader_init_ref_iterator(reader, &it) == 0);
    -+	cl_assert(reftable_iterator_seek_ref(&it, "") == 0);
    ++	cl_assert(!err);
      
      	for (j = 0; ; j++) {
      		struct reftable_ref_record ref = { 0 };
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_table_read_write_sequential(v
     +	cl_assert_equal_i(j, N);
      
      	reftable_iterator_destroy(&it);
    - 	reftable_reader_decref(reader);
    + 	reftable_table_decref(table);
     @@ t/unit-tests/u-reftable-readwrite.c: static void t_table_read_write_sequential(void)
      	free_names(names);
      }
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_table_read_write_sequential(v
      	char **names;
      	struct reftable_buf buf = REFTABLE_BUF_INIT;
      	int N = 50;
    - 	struct reftable_reader *reader;
    + 	struct reftable_table *table;
      	struct reftable_block_source source = { 0 };
     -	int err;
      	struct reftable_log_record log = { 0 };
      	struct reftable_iterator it = { 0 };
    ++	int err;
      
    -@@ t/unit-tests/u-reftable-readwrite.c: static void t_table_read_api(void)
    + 	write_table(&names, &buf, N, 256, REFTABLE_HASH_SHA1);
      
      	block_source_from_buf(&source, &buf);
      
    --	err = reftable_reader_new(&reader, &source, "file.ref");
    + 	err = reftable_table_new(&table, &source, "file.ref");
     -	check(!err);
    -+	cl_assert(reftable_reader_new(&reader, &source, "file.ref") == 0);
    -+	cl_assert(reftable_reader_init_ref_iterator(reader, &it) == 0);
    -+	cl_assert(reftable_iterator_seek_ref(&it, names[0]) == 0);
    ++	cl_assert(!err);
      
    --	err = reftable_reader_init_ref_iterator(reader, &it);
    + 	err = reftable_table_init_ref_iterator(table, &it);
     -	check(!err);
    --	err = reftable_iterator_seek_ref(&it, names[0]);
    ++	cl_assert(!err);
    + 	err = reftable_iterator_seek_ref(&it, names[0]);
     -	check(!err);
    --
    --	err = reftable_iterator_next_log(&it, &log);
    ++	cl_assert(!err);
    + 
    + 	err = reftable_iterator_next_log(&it, &log);
     -	check_int(err, ==, REFTABLE_API_ERROR);
    -+	cl_assert_equal_i(reftable_iterator_next_log(&it, &log), REFTABLE_API_ERROR);
    ++	cl_assert_equal_i(err, REFTABLE_API_ERROR);
      
      	reftable_buf_release(&buf);
      	free_names(names);
     @@ t/unit-tests/u-reftable-readwrite.c: static void t_table_read_write_seek(int index, enum reftable_hash hash_id)
    - 
      	block_source_from_buf(&source, &buf);
      
    --	err = reftable_reader_new(&reader, &source, "file.ref");
    + 	err = reftable_table_new(&table, &source, "file.ref");
     -	check(!err);
    --	check_int(hash_id, ==, reftable_reader_hash_id(reader));
    -+	cl_assert(reftable_reader_new(&reader, &source, "file.ref") == 0);
    -+	cl_assert_equal_i(hash_id, reftable_reader_hash_id(reader));
    +-	check_int(hash_id, ==, reftable_table_hash_id(table));
    ++	cl_assert(!err);
    ++	cl_assert_equal_i(hash_id, reftable_table_hash_id(table));
      
      	if (!index) {
    - 		reader->ref_offsets.index_offset = 0;
    + 		table->ref_offsets.index_offset = 0;
      	} else {
    --		check_int(reader->ref_offsets.index_offset, >, 0);
    -+		cl_assert(reader->ref_offsets.index_offset > 0);
    +-		check_int(table->ref_offsets.index_offset, >, 0);
    ++		cl_assert(table->ref_offsets.index_offset > 0);
      	}
      
      	for (i = 1; i < N; i++) {
    --		err = reftable_reader_init_ref_iterator(reader, &it);
    + 		err = reftable_table_init_ref_iterator(table, &it);
     -		check(!err);
    --		err = reftable_iterator_seek_ref(&it, names[i]);
    ++		cl_assert(!err);
    + 		err = reftable_iterator_seek_ref(&it, names[i]);
     -		check(!err);
    --		err = reftable_iterator_next_ref(&it, &ref);
    ++		cl_assert(!err);
    + 		err = reftable_iterator_next_ref(&it, &ref);
     -		check(!err);
     -		check_str(names[i], ref.refname);
     -		check_int(REFTABLE_REF_VAL1, ==, ref.value_type);
     -		check_int(i, ==, ref.value.val1[0]);
    -+		cl_assert(reftable_reader_init_ref_iterator(reader, &it) == 0);
    -+		cl_assert(reftable_iterator_seek_ref(&it, names[i]) == 0);
    -+		cl_assert(reftable_iterator_next_ref(&it, &ref) == 0);
    ++		cl_assert(!err);
     +		cl_assert_equal_s(names[i], ref.refname);
     +		cl_assert_equal_i(REFTABLE_REF_VAL1, ref.value_type);
     +		cl_assert_equal_i(i, ref.value.val1[0]);
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_table_read_write_seek(int ind
     +	cl_assert(reftable_buf_addstr(&pastLast, names[N - 1]) == 0);
     +	cl_assert(reftable_buf_addstr(&pastLast, "/") == 0);
      
    --	err = reftable_reader_init_ref_iterator(reader, &it);
    + 	err = reftable_table_init_ref_iterator(table, &it);
     -	check(!err);
    -+	cl_assert(reftable_reader_init_ref_iterator(reader, &it) == 0);
    ++	cl_assert(!err);
      	err = reftable_iterator_seek_ref(&it, pastLast.buf);
      	if (err == 0) {
      		struct reftable_ref_record ref = { 0 };
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_table_read_write_seek(int ind
      
      	reftable_buf_release(&pastLast);
     @@ t/unit-tests/u-reftable-readwrite.c: static void t_table_read_write_seek(int index, enum reftable_hash hash_id)
    - 	reftable_reader_decref(reader);
    + 	reftable_table_decref(table);
      }
      
     -static void t_table_read_write_seek_linear(void)
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_table_read_write_seek(int ind
      	t_table_read_write_seek(1, REFTABLE_HASH_SHA1);
      }
     @@ t/unit-tests/u-reftable-readwrite.c: static void t_table_refs_for(int indexed)
    - 	struct reftable_reader *reader;
    + 	struct reftable_table *table;
      	struct reftable_block_source source = { 0 };
      	struct reftable_buf buf = REFTABLE_BUF_INIT;
     -	struct reftable_writer *w = t_reftable_strbuf_writer(&buf, &opts);
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_table_refs_for(int indexed)
      	struct reftable_iterator it = { 0 };
     -	int N = 50, n, j, err, i;
     +	int N = 50, j, i;
    ++	int err;
      
      	want_names = reftable_calloc(N + 1, sizeof(*want_names));
     -	check(want_names != NULL);
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_table_refs_for(int indexed)
      
      	reftable_writer_free(w);
      	w = NULL;
    - 
    +@@ t/unit-tests/u-reftable-readwrite.c: static void t_table_refs_for(int indexed)
      	block_source_from_buf(&source, &buf);
      
    --	err = reftable_reader_new(&reader, &source, "file.ref");
    + 	err = reftable_table_new(&table, &source, "file.ref");
     -	check(!err);
    -+	cl_assert(reftable_reader_new(&reader, &source, "file.ref") == 0);
    ++	cl_assert(!err);
      	if (!indexed)
    - 		reader->obj_offsets.is_present = 0;
    + 		table->obj_offsets.is_present = 0;
      
    --	err = reftable_reader_init_ref_iterator(reader, &it);
    + 	err = reftable_table_init_ref_iterator(table, &it);
     -	check(!err);
    --	err = reftable_iterator_seek_ref(&it, "");
    ++	cl_assert(!err);
    + 	err = reftable_iterator_seek_ref(&it, "");
     -	check(!err);
    -+	cl_assert(reftable_reader_init_ref_iterator(reader, &it) == 0);
    -+	cl_assert(reftable_iterator_seek_ref(&it, "") == 0);
    ++	cl_assert(!err);
      	reftable_iterator_destroy(&it);
      
    --	err = reftable_reader_refs_for(reader, &it, want_hash);
    + 	err = reftable_table_refs_for(table, &it, want_hash);
     -	check(!err);
    -+	cl_assert(reftable_reader_refs_for(reader, &it, want_hash) == 0);
    ++	cl_assert(!err);
      
      	for (j = 0; ; j++) {
      		int err = reftable_iterator_next_ref(&it, &ref);
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_table_refs_for(int indexed)
      	reftable_buf_release(&buf);
      	free_names(want_names);
     @@ t/unit-tests/u-reftable-readwrite.c: static void t_table_refs_for(int indexed)
    - 	reftable_reader_decref(reader);
    + 	reftable_table_decref(table);
      }
      
     -static void t_table_refs_for_no_index(void)
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_table_refs_for(int indexed)
     -	struct reftable_writer *w = t_reftable_strbuf_writer(&buf, &opts);
     +	struct reftable_writer *w = cl_reftable_strbuf_writer(&buf, &opts);
      	struct reftable_block_source source = { 0 };
    - 	struct reftable_reader *rd = NULL;
    + 	struct reftable_table *table = NULL;
      	struct reftable_ref_record rec = { 0 };
    - 	struct reftable_iterator it = { 0 };
    --	int err;
    +@@ t/unit-tests/u-reftable-readwrite.c: static void t_write_empty_table(void)
      
      	reftable_writer_set_limits(w, 1, 1);
      
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_table_refs_for(int indexed)
      
      	block_source_from_buf(&source, &buf);
      
    --	err = reftable_reader_new(&rd, &source, "filename");
    + 	err = reftable_table_new(&table, &source, "filename");
     -	check(!err);
    --
    --	err = reftable_reader_init_ref_iterator(rd, &it);
    ++	cl_assert(!err);
    + 
    + 	err = reftable_table_init_ref_iterator(table, &it);
     -	check(!err);
    --	err = reftable_iterator_seek_ref(&it, "");
    ++	cl_assert(!err);
    + 	err = reftable_iterator_seek_ref(&it, "");
     -	check(!err);
    --
    --	err = reftable_iterator_next_ref(&it, &rec);
    ++	cl_assert(!err);
    + 
    + 	err = reftable_iterator_next_ref(&it, &rec);
     -	check_int(err, >, 0);
    -+	cl_assert(reftable_reader_new(&rd, &source, "filename") == 0);
    -+	cl_assert(reftable_reader_init_ref_iterator(rd, &it) == 0);
    -+	cl_assert(reftable_iterator_seek_ref(&it, "") == 0);
    -+	cl_assert(reftable_iterator_next_ref(&it, &rec) > 0);
    ++	cl_assert(err > 0);
      
      	reftable_iterator_destroy(&it);
    - 	reftable_reader_decref(rd);
    + 	reftable_table_decref(table);
      	reftable_buf_release(&buf);
      }
      
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_write_key_order(void)
      		.block_size = 100,
     @@ t/unit-tests/u-reftable-readwrite.c: static void t_write_multiple_indices(void)
      	struct reftable_writer *writer;
    - 	struct reftable_reader *reader;
    + 	struct reftable_table *table;
      	char buf[128];
     -	int err, i;
     +	int i;
    ++	int err;
      
     -	writer = t_reftable_strbuf_writer(&writer_buf, &opts);
     +	writer = cl_reftable_strbuf_writer(&writer_buf, &opts);
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_write_multiple_indices(void)
     +	cl_assert(stats->log_stats.index_offset > 0);
      
      	block_source_from_buf(&source, &writer_buf);
    --	err = reftable_reader_new(&reader, &source, "filename");
    + 	err = reftable_table_new(&table, &source, "filename");
     -	check(!err);
    -+	cl_assert(reftable_reader_new(&reader, &source, "filename") == 0);
    ++	cl_assert(!err);
      
      	/*
      	 * Seeking the log uses the log index now. In case there is any
      	 * confusion regarding indices we would notice here.
      	 */
    --	err = reftable_reader_init_log_iterator(reader, &it);
    + 	err = reftable_table_init_log_iterator(table, &it);
     -	check(!err);
    --	err = reftable_iterator_seek_log(&it, "");
    ++	cl_assert(!err);
    + 	err = reftable_iterator_seek_log(&it, "");
     -	check(!err);
    -+	cl_assert(reftable_reader_init_log_iterator(reader, &it) == 0);
    -+	cl_assert(reftable_iterator_seek_log(&it, "") == 0);
    ++	cl_assert(!err);
      
      	reftable_iterator_destroy(&it);
      	reftable_writer_free(writer);
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_write_multiple_indices(void)
      	struct reftable_write_options opts = {
      		.block_size = 100,
     @@ t/unit-tests/u-reftable-readwrite.c: static void t_write_multi_level_index(void)
    - 	const struct reftable_stats *stats;
    - 	struct reftable_writer *writer;
    - 	struct reftable_reader *reader;
    --	int err;
    + 	struct reftable_table *table;
    + 	int err;
      
     -	writer = t_reftable_strbuf_writer(&writer_buf, &opts);
     +	writer = cl_reftable_strbuf_writer(&writer_buf, &opts);
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_write_multi_level_index(void)
     +	cl_assert_equal_i(stats->ref_stats.max_index_level, 2);
      
      	block_source_from_buf(&source, &writer_buf);
    --	err = reftable_reader_new(&reader, &source, "filename");
    + 	err = reftable_table_new(&table, &source, "filename");
     -	check(!err);
    -+	cl_assert(reftable_reader_new(&reader, &source, "filename") == 0);
    ++	cl_assert(!err);
      
      	/*
      	 * Seeking the last ref should work as expected.
      	 */
    --	err = reftable_reader_init_ref_iterator(reader, &it);
    + 	err = reftable_table_init_ref_iterator(table, &it);
     -	check(!err);
    --	err = reftable_iterator_seek_ref(&it, "refs/heads/199");
    ++	cl_assert(!err);
    + 	err = reftable_iterator_seek_ref(&it, "refs/heads/199");
     -	check(!err);
    -+	cl_assert(reftable_reader_init_ref_iterator(reader, &it) == 0);
    -+	cl_assert(reftable_iterator_seek_ref(&it, "refs/heads/199") == 0);
    ++	cl_assert(!err);
      
      	reftable_iterator_destroy(&it);
      	reftable_writer_free(writer);
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_write_multi_level_index(void)
      {
      	struct reftable_buf buf = REFTABLE_BUF_INIT;
      	struct reftable_block_source source = { 0 };
    - 	struct reftable_reader *reader;
    --	int err;
    +@@ t/unit-tests/u-reftable-readwrite.c: static void t_corrupt_table_empty(void)
      
      	block_source_from_buf(&source, &buf);
    --	err = reftable_reader_new(&reader, &source, "file.log");
    + 	err = reftable_table_new(&table, &source, "file.log");
     -	check_int(err, ==, REFTABLE_FORMAT_ERROR);
    -+	cl_assert_equal_i(reftable_reader_new(&reader, &source,
    -+										  "file.log"),REFTABLE_FORMAT_ERROR);
    ++	cl_assert_equal_i(err, REFTABLE_FORMAT_ERROR);
      }
      
     -static void t_corrupt_table(void)
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_write_multi_level_index(void)
      	uint8_t zeros[1024] = { 0 };
      	struct reftable_buf buf = REFTABLE_BUF_INIT;
      	struct reftable_block_source source = { 0 };
    - 	struct reftable_reader *reader;
    --	int err;
    + 	struct reftable_table *table;
    + 	int err;
     -	check(!reftable_buf_add(&buf, zeros, sizeof(zeros)));
    -+	cl_assert(reftable_buf_add(&buf, zeros, sizeof(zeros)) == 0);
    ++
    ++	cl_assert(!reftable_buf_add(&buf, zeros, sizeof(zeros)));
      
      	block_source_from_buf(&source, &buf);
    --	err = reftable_reader_new(&reader, &source, "file.log");
    + 	err = reftable_table_new(&table, &source, "file.log");
     -	check_int(err, ==, REFTABLE_FORMAT_ERROR);
    -+	cl_assert_equal_i(reftable_reader_new(&reader, &source,
    -+										  "file.log"), REFTABLE_FORMAT_ERROR);
    ++	cl_assert_equal_i(err, REFTABLE_FORMAT_ERROR);
      
      	reftable_buf_release(&buf);
      }

8: 1515cf15b7 ! 8: df744c1458 t/unit-tests: convert reftable record test to use clar
@@ Commit message

## Makefile ##
-@@ Makefile: CLAR_TEST_SUITES += u-reftable-merged
- CLAR_TEST_SUITES += u-reftable-pq
- CLAR_TEST_SUITES += u-reftable-reader
- CLAR_TEST_SUITES += u-reftable-readwrite -+CLAR_TEST_SUITES += u-reftable-record
- CLAR_TEST_SUITES += u-reftable-tree
- CLAR_TEST_SUITES += u-strbuf
- CLAR_TEST_SUITES += u-strcmp-offset
-@@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/clar/clar.o
- CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o +@@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-oid.o
+ CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable-clar.o

-UNIT_TEST_PROGRAMS += t-reftable-record
UNIT_TEST_PROGRAMS += t-reftable-stack
@@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/clar/clar.o
UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/test-lib.o

## t/meson.build ##
-@@ t/meson.build: clar_test_suites = [
- 'unit-tests/u-reftable-pq.c',
- 'unit-tests/u-reftable-reader.c',
- 'unit-tests/u-reftable-readwrite.c',
-+ 'unit-tests/u-reftable-record.c',
- 'unit-tests/u-reftable-tree.c',
- 'unit-tests/u-strbuf.c',
- 'unit-tests/u-strcmp-offset.c',
@@ t/meson.build: clar_unit_tests = executable('unit-tests',
test('unit-tests', clar_unit_tests)

@@ t/unit-tests/t-reftable-record.c => t/unit-tests/u-reftable-record.c

-#include "test-lib.h"
+#include "unit-test.h"
++#include "lib-reftable-clar.h"
#include "reftable/basics.h"
#include "reftable/constants.h"
#include "reftable/record.h"
@@ t/unit-tests/u-reftable-record.c: static void t_reftable_log_record_roundtrip(vo
+ cl_assert(reftable_log_record_is_deletion(&in[2]) == 0);

for (size_t i = 0; i < ARRAY_SIZE(in); i++) {
- struct reftable_record rec = { .type = BLOCK_TYPE_LOG };
+ struct reftable_record rec = { .type = REFTABLE_BLOCK_TYPE_LOG };
@@ t/unit-tests/u-reftable-record.c: static void t_reftable_log_record_roundtrip(void)
reftable_record_key(&rec, &key);

@@ t/unit-tests/u-reftable-record.c: static void t_reftable_index_record_comparison
+void test_reftable_record__index_record_roundtrip(void)
{
struct reftable_record in = {
- .type = BLOCK_TYPE_INDEX,
+ .type = REFTABLE_BLOCK_TYPE_INDEX,
@@ t/unit-tests/u-reftable-record.c: static void t_reftable_index_record_roundtrip(void)
int n, m;
uint8_t extra;
9: dcbb2b6e56 ! 9: 4a247de9e4 t/unit-tests: convert reftable stack test to use clar

    @@ Commit message
         Signed-off-by: Seyi Kuforiji <[email protected]>
     
      ## Makefile ##
    -@@ Makefile: CLAR_TEST_SUITES += u-reftable-pq
    - CLAR_TEST_SUITES += u-reftable-reader
    +@@ Makefile: CLAR_TEST_SUITES += u-reftable-block
    + CLAR_TEST_SUITES += u-reftable-merged
    + CLAR_TEST_SUITES += u-reftable-pq
      CLAR_TEST_SUITES += u-reftable-readwrite
    - CLAR_TEST_SUITES += u-reftable-record
     +CLAR_TEST_SUITES += u-reftable-stack
    + CLAR_TEST_SUITES += u-reftable-table
      CLAR_TEST_SUITES += u-reftable-tree
      CLAR_TEST_SUITES += u-strbuf
    - CLAR_TEST_SUITES += u-strcmp-offset
    -@@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/clar/clar.o
    - CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
    +@@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
      CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-oid.o
    + CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable-clar.o
      
     -UNIT_TEST_PROGRAMS += t-reftable-stack
      UNIT_TEST_PROGS = $(patsubst %,$(UNIT_TEST_BIN)/%$X,$(UNIT_TEST_PROGRAMS))
    @@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/clar/clar.o
     
      ## t/meson.build ##
     @@ t/meson.build: clar_test_suites = [
    -   'unit-tests/u-reftable-reader.c',
    +   'unit-tests/u-reftable-merged.c',
    +   'unit-tests/u-reftable-pq.c',
        'unit-tests/u-reftable-readwrite.c',
    -   'unit-tests/u-reftable-record.c',
    ++  'unit-tests/u-reftable-record.c',
     +  'unit-tests/u-reftable-stack.c',
    +   'unit-tests/u-reftable-table.c',
        'unit-tests/u-reftable-tree.c',
        'unit-tests/u-strbuf.c',
    -   'unit-tests/u-strcmp-offset.c',
     @@ t/meson.build: clar_unit_tests = executable('unit-tests',
      test('unit-tests', clar_unit_tests)
      
    @@ t/meson.build: clar_unit_tests = executable('unit-tests',
      ]
      
      foreach unit_test_program : unit_test_programs
    -@@ t/meson.build: integration_tests = [
    +@@ t/meson.build: benchmarks = [
      # sufficient to catch missing test suites in our CI though.
      foreach glob, tests : {
        't[0-9][0-9][0-9][0-9]-*.sh': integration_tests,
    +-  'perf/p[0-9][0-9][0-9][0-9]-*.sh': benchmarks,
     -  'unit-tests/t-*.c': unit_test_programs,
        'unit-tests/u-*.c': clar_test_suites,
      }
    @@ t/unit-tests/u-reftable-stack.c: license that can be found in the LICENSE file o
      #define DISABLE_SIGN_COMPARE_WARNINGS
      
     -#include "test-lib.h"
    +-#include "lib-reftable.h"
     +#include "unit-test.h"
    - #include "lib-reftable.h"
      #include "dir.h"
    ++#include "lib-reftable-clar.h"
      #include "reftable/merged.h"
    + #include "reftable/reftable-error.h"
    + #include "reftable/stack.h"
     @@ t/unit-tests/u-reftable-stack.c: static char *get_tmp_template(int linenumber)
      static char *get_tmp_dir(int linenumber)
      {
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_add_one(void)
      	};
      	struct reftable_ref_record dest = { 0 };
      	struct stat stat_result = { 0 };
    --	err = reftable_new_stack(&st, dir, &opts);
    ++	int err;
    ++
    + 	err = reftable_new_stack(&st, dir, &opts);
     -	check(!err);
    --
    --	err = reftable_stack_add(st, write_test_ref, &ref);
    ++	cl_assert(!err);
    + 
    + 	err = reftable_stack_add(st, write_test_ref, &ref);
     -	check(!err);
    --
    --	err = reftable_stack_read_ref(st, ref.refname, &dest);
    ++	cl_assert(!err);
    + 
    + 	err = reftable_stack_read_ref(st, ref.refname, &dest);
     -	check(!err);
     -	check(reftable_ref_record_equal(&ref, &dest, REFTABLE_HASH_SIZE_SHA1));
    --	check_int(st->readers_len, >, 0);
    -+	cl_assert(reftable_new_stack(&st, dir, &opts) == 0);
    -+	cl_assert(reftable_stack_add(st, write_test_ref, &ref) == 0);
    -+	cl_assert(reftable_stack_read_ref(st, ref.refname, &dest) == 0);
    -+	cl_assert(reftable_ref_record_equal(&ref, &dest, REFTABLE_HASH_SIZE_SHA1) != 0);
    -+	cl_assert(st->readers_len > 0);
    +-	check_int(st->tables_len, >, 0);
    ++	cl_assert(!err);
    ++	cl_assert(reftable_ref_record_equal(&ref, &dest,
    ++					    REFTABLE_HASH_SIZE_SHA1));
    ++	cl_assert(st->tables_len > 0);
      
      #ifndef GIT_WINDOWS_NATIVE
     -	check(!reftable_buf_addstr(&scratch, dir));
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_add_one(void)
     +	cl_assert(reftable_buf_addstr(&scratch, dir) == 0);
     +	cl_assert(reftable_buf_addstr(&scratch, "/") == 0);
      	/* do not try at home; not an external API for reftable. */
    --	check(!reftable_buf_addstr(&scratch, st->readers[0]->name));
    --	err = stat(scratch.buf, &stat_result);
    +-	check(!reftable_buf_addstr(&scratch, st->tables[0]->name));
    ++	cl_assert(!reftable_buf_addstr(&scratch, st->tables[0]->name));
    + 	err = stat(scratch.buf, &stat_result);
     -	check(!err);
     -	check_int((stat_result.st_mode & 0777), ==, opts.default_permissions);
    -+	cl_assert(reftable_buf_addstr(&scratch, st->readers[0]->name) == 0);
    -+	cl_assert(stat(scratch.buf, &stat_result) == 0);
    -+	cl_assert_equal_i((stat_result.st_mode & 0777), opts.default_permissions);
    ++	cl_assert(!err);
    ++	cl_assert_equal_i((stat_result.st_mode & 0777),
    ++			   opts.default_permissions);
      #else
      	(void) stat_result;
      #endif
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_transaction_api_pe
      		 * all tables in the stack.
      		 */
      		if (i != n)
    --			check_int(st->merged->readers_len, ==, i + 1);
    -+			cl_assert_equal_i(st->merged->readers_len, i + 1);
    +-			check_int(st->merged->tables_len, ==, i + 1);
    ++			cl_assert_equal_i(st->merged->tables_len, i + 1);
      		else
    --			check_int(st->merged->readers_len, ==, 1);
    -+			cl_assert_equal_i(st->merged->readers_len, 1);
    +-			check_int(st->merged->tables_len, ==, 1);
    ++			cl_assert_equal_i(st->merged->tables_len, 1);
      	}
      
      	reftable_stack_destroy(st);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_transaction_api_pe
      	struct reftable_ref_record ref = {
      		.refname = (char *) "refs/heads/master",
     @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_auto_compaction_fails_gracefully(void)
    - 	struct reftable_stack *st;
    - 	struct reftable_buf table_path = REFTABLE_BUF_INIT;
      	char *dir = get_tmp_dir(__LINE__);
    --	int err;
    + 	int err;
      
     -	err = reftable_new_stack(&st, dir, &opts);
     -	check(!err);
     -
     -	err = reftable_stack_add(st, write_test_ref, &ref);
     -	check(!err);
    --	check_int(st->merged->readers_len, ==, 1);
    +-	check_int(st->merged->tables_len, ==, 1);
     -	check_int(st->stats.attempts, ==, 0);
     -	check_int(st->stats.failures, ==, 0);
     +	cl_assert(reftable_new_stack(&st, dir, &opts) == 0);
     +	cl_assert(reftable_stack_add(st, write_test_ref, &ref) == 0);
    -+	cl_assert_equal_i(st->merged->readers_len, 1);
    ++	cl_assert_equal_i(st->merged->tables_len, 1);
     +	cl_assert_equal_i(st->stats.attempts, 0);
     +	cl_assert_equal_i(st->stats.failures, 0);
      
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_auto_compaction_fa
      	 */
     -	check(!reftable_buf_addstr(&table_path, dir));
     -	check(!reftable_buf_addstr(&table_path, "/"));
    --	check(!reftable_buf_addstr(&table_path, st->readers[0]->name));
    +-	check(!reftable_buf_addstr(&table_path, st->tables[0]->name));
     -	check(!reftable_buf_addstr(&table_path, ".lock"));
    -+	cl_assert(reftable_buf_addstr(&table_path, dir) == 0);
    -+	cl_assert(reftable_buf_addstr(&table_path, "/") == 0);
    -+	cl_assert(reftable_buf_addstr(&table_path, st->readers[0]->name) == 0);
    -+	cl_assert(reftable_buf_addstr(&table_path, ".lock") == 0);
    ++	cl_assert(!reftable_buf_addstr(&table_path, dir));
    ++	cl_assert(!reftable_buf_addstr(&table_path, "/"));
    ++	cl_assert(!reftable_buf_addstr(&table_path,
    ++				       st->tables[0]->name));
    ++	cl_assert(!reftable_buf_addstr(&table_path, ".lock"));
      	write_file_buf(table_path.buf, "", 0);
      
      	ref.update_index = 2;
    --	err = reftable_stack_add(st, write_test_ref, &ref);
    + 	err = reftable_stack_add(st, write_test_ref, &ref);
     -	check(!err);
    --	check_int(st->merged->readers_len, ==, 2);
    +-	check_int(st->merged->tables_len, ==, 2);
     -	check_int(st->stats.attempts, ==, 1);
     -	check_int(st->stats.failures, ==, 1);
    -+	cl_assert(reftable_stack_add(st, write_test_ref, &ref) == 0);
    -+	cl_assert_equal_i(st->merged->readers_len, 2);
    ++	cl_assert(!err);
    ++	cl_assert_equal_i(st->merged->tables_len, 2);
     +	cl_assert_equal_i(st->stats.attempts, 1);
     +	cl_assert_equal_i(st->stats.failures, 1);
      
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_update_index_check
      		.exact_log_message = 1,
      		.default_permissions = 0660,
     @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_add(void)
    + 	struct reftable_buf path = REFTABLE_BUF_INIT;
      	struct stat stat_result;
      	size_t i, N = ARRAY_SIZE(refs);
    ++	int err;
      
    --	err = reftable_new_stack(&st, dir, &opts);
    + 	err = reftable_new_stack(&st, dir, &opts);
     -	check(!err);
    -+	cl_assert(reftable_new_stack(&st, dir, &opts) == 0);
    ++	cl_assert(!err);
      
      	for (i = 0; i < N; i++) {
      		char buf[256];
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_add(void)
     +	cl_assert(reftable_buf_addstr(&path, dir) == 0);
     +	cl_assert(reftable_buf_addstr(&path, "/") == 0);
      	/* do not try at home; not an external API for reftable. */
    --	check(!reftable_buf_addstr(&path, st->readers[0]->name));
    --	err = stat(path.buf, &stat_result);
    +-	check(!reftable_buf_addstr(&path, st->tables[0]->name));
    ++	cl_assert(!reftable_buf_addstr(&path, st->tables[0]->name));
    + 	err = stat(path.buf, &stat_result);
     -	check(!err);
     -	check_int((stat_result.st_mode & 0777), ==, opts.default_permissions);
    -+	cl_assert(reftable_buf_addstr(&path, st->readers[0]->name) == 0);
    -+	cl_assert(stat(path.buf, &stat_result) == 0);
    ++	cl_assert(!err);
     +	cl_assert_equal_i((stat_result.st_mode & 0777), opts.default_permissions);
      #else
      	(void) stat_result;
    @@ t/unit-tests/u-reftable-stack.c: static int fastlogN(uint64_t sz, uint64_t N)
      	char *dir = get_tmp_dir(__LINE__);
     -	int err;
      	size_t i, N = 100;
    ++	int err;
      
     -	err = reftable_new_stack(&st, dir, &opts);
     -	check(!err);
    @@ t/unit-tests/u-reftable-stack.c: static int fastlogN(uint64_t sz, uint64_t N)
      	for (i = 0; i < N; i++) {
      		char name[100];
     @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_auto_compaction(void)
    - 		};
      		snprintf(name, sizeof(name), "branch%04"PRIuMAX, (uintmax_t)i);
      
    --		err = reftable_stack_add(st, write_test_ref, &ref);
    + 		err = reftable_stack_add(st, write_test_ref, &ref);
     -		check(!err);
    --
    --		err = reftable_stack_auto_compact(st);
    ++		cl_assert(!err);
    + 
    + 		err = reftable_stack_auto_compact(st);
     -		check(!err);
    --		check(i < 2 || st->merged->readers_len < 2 * fastlogN(i, 2));
    -+		cl_assert(reftable_stack_add(st, write_test_ref, &ref) == 0);
    -+		cl_assert(reftable_stack_auto_compact(st) == 0);
    -+		cl_assert(i < 2 || st->merged->readers_len < 2 * fastlogN(i, 2));
    +-		check(i < 2 || st->merged->tables_len < 2 * fastlogN(i, 2));
    ++		cl_assert(!err);
    ++		cl_assert(i < 2 || st->merged->tables_len < 2 * fastlogN(i, 2));
      	}
      
     -	check_int(reftable_stack_compaction_stats(st)->entries_written, <,
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_auto_compaction(vo
      	char *dir = get_tmp_dir(__LINE__);
     -	int err;
      	size_t N = 100;
    ++	int err;
      
     -	err = reftable_new_stack(&st, dir, &opts);
     -	check(!err);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_auto_compaction(vo
      	for (size_t i = 0; i < N; i++) {
      		char name[20];
     @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_auto_compaction_factor(void)
    - 		};
      		xsnprintf(name, sizeof(name), "branch%04"PRIuMAX, (uintmax_t)i);
      
    --		err = reftable_stack_add(st, &write_test_ref, &ref);
    + 		err = reftable_stack_add(st, &write_test_ref, &ref);
     -		check(!err);
    --
    --		check(i < 5 || st->merged->readers_len < 5 * fastlogN(i, 5));
    -+		cl_assert(reftable_stack_add(st, &write_test_ref, &ref) == 0);
    -+		cl_assert(i < 5 || st->merged->readers_len < 5 * fastlogN(i, 5));
    ++		cl_assert(!err);
    + 
    +-		check(i < 5 || st->merged->tables_len < 5 * fastlogN(i, 5));
    ++		cl_assert(i < 5 || st->merged->tables_len < 5 * fastlogN(i, 5));
      	}
      
      	reftable_stack_destroy(st);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_auto_compaction_fa
      	struct reftable_write_options opts = {
      		.disable_auto_compact = 1,
     @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_auto_compaction_with_locked_tables(void)
    - 	struct reftable_stack *st = NULL;
    - 	struct reftable_buf buf = REFTABLE_BUF_INIT;
      	char *dir = get_tmp_dir(__LINE__);
    --	int err;
    + 	int err;
      
     -	err = reftable_new_stack(&st, dir, &opts);
     -	check(!err);
     +	cl_assert(reftable_new_stack(&st, dir, &opts) == 0);
      
      	write_n_ref_tables(st, 5);
    --	check_int(st->merged->readers_len, ==, 5);
    -+	cl_assert_equal_i(st->merged->readers_len, 5);
    +-	check_int(st->merged->tables_len, ==, 5);
    ++	cl_assert_equal_i(st->merged->tables_len, 5);
      
      	/*
      	 * Given that all tables we have written should be roughly the same
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_auto_compaction_wi
      	 */
     -	check(!reftable_buf_addstr(&buf, dir));
     -	check(!reftable_buf_addstr(&buf, "/"));
    --	check(!reftable_buf_addstr(&buf, st->readers[2]->name));
    +-	check(!reftable_buf_addstr(&buf, st->tables[2]->name));
     -	check(!reftable_buf_addstr(&buf, ".lock"));
    -+	cl_assert(reftable_buf_addstr(&buf, dir) == 0);
    -+	cl_assert(reftable_buf_addstr(&buf, "/") == 0);
    -+	cl_assert(reftable_buf_addstr(&buf, st->readers[2]->name) == 0);
    -+	cl_assert(reftable_buf_addstr(&buf, ".lock") == 0);
    ++	cl_assert(!reftable_buf_addstr(&buf, dir));
    ++	cl_assert(!reftable_buf_addstr(&buf, "/"));
    ++	cl_assert(!reftable_buf_addstr(&buf, st->tables[2]->name));
    ++	cl_assert(!reftable_buf_addstr(&buf, ".lock"));
      	write_file_buf(buf.buf, "", 0);
      
      	/*
     @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_auto_compaction_with_locked_tables(void)
    - 	 * would in theory compact all tables, due to the preexisting lock we
      	 * only compact the newest two tables.
      	 */
    --	err = reftable_stack_auto_compact(st);
    + 	err = reftable_stack_auto_compact(st);
     -	check(!err);
     -	check_int(st->stats.failures, ==, 0);
    --	check_int(st->merged->readers_len, ==, 4);
    -+	cl_assert(reftable_stack_auto_compact(st) == 0);
    +-	check_int(st->merged->tables_len, ==, 4);
    ++	cl_assert(!err);
     +	cl_assert_equal_i(st->stats.failures, 0);
    -+	cl_assert_equal_i(st->merged->readers_len, 4);
    ++	cl_assert_equal_i(st->merged->tables_len, 4);
      
      	reftable_stack_destroy(st);
      	reftable_buf_release(&buf);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_add_performs_auto_
      		 * all tables in the stack.
      		 */
      		if (i != n)
    --			check_int(st->merged->readers_len, ==, i + 1);
    -+			cl_assert_equal_i(st->merged->readers_len, i + 1);
    +-			check_int(st->merged->tables_len, ==, i + 1);
    ++			cl_assert_equal_i(st->merged->tables_len, i + 1);
      		else
    --			check_int(st->merged->readers_len, ==, 1);
    -+			cl_assert_equal_i(st->merged->readers_len, 1);
    +-			check_int(st->merged->tables_len, ==, 1);
    ++			cl_assert_equal_i(st->merged->tables_len, 1);
      	}
      
      	reftable_stack_destroy(st);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_add_performs_auto_
      	struct reftable_write_options opts = {
      		.disable_auto_compact = 1,
     @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_compaction_with_locked_tables(void)
    - 	struct reftable_stack *st = NULL;
    - 	struct reftable_buf buf = REFTABLE_BUF_INIT;
      	char *dir = get_tmp_dir(__LINE__);
    --	int err;
    + 	int err;
      
     -	err = reftable_new_stack(&st, dir, &opts);
     -	check(!err);
     +	cl_assert(reftable_new_stack(&st, dir, &opts) == 0);
      
      	write_n_ref_tables(st, 3);
    --	check_int(st->merged->readers_len, ==, 3);
    -+	cl_assert_equal_i(st->merged->readers_len, 3);
    +-	check_int(st->merged->tables_len, ==, 3);
    ++	cl_assert_equal_i(st->merged->tables_len, 3);
      
      	/* Lock one of the tables that we're about to compact. */
     -	check(!reftable_buf_addstr(&buf, dir));
     -	check(!reftable_buf_addstr(&buf, "/"));
    --	check(!reftable_buf_addstr(&buf, st->readers[1]->name));
    +-	check(!reftable_buf_addstr(&buf, st->tables[1]->name));
     -	check(!reftable_buf_addstr(&buf, ".lock"));
    -+	cl_assert(reftable_buf_addstr(&buf, dir) == 0);
    -+	cl_assert(reftable_buf_addstr(&buf, "/") == 0);
    -+	cl_assert(reftable_buf_addstr(&buf, st->readers[1]->name) == 0);
    -+	cl_assert(reftable_buf_addstr(&buf, ".lock") == 0);
    ++	cl_assert(!reftable_buf_addstr(&buf, dir));
    ++	cl_assert(!reftable_buf_addstr(&buf, "/"));
    ++	cl_assert(!reftable_buf_addstr(&buf, st->tables[1]->name));
    ++	cl_assert(!reftable_buf_addstr(&buf, ".lock"));
      	write_file_buf(buf.buf, "", 0);
      
      	/*
    - 	 * Compaction is expected to fail given that we were not able to
    +@@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_compaction_with_locked_tables(void)
      	 * compact all tables.
      	 */
    --	err = reftable_stack_compact_all(st, NULL);
    + 	err = reftable_stack_compact_all(st, NULL);
     -	check_int(err, ==, REFTABLE_LOCK_ERROR);
     -	check_int(st->stats.failures, ==, 1);
    --	check_int(st->merged->readers_len, ==, 3);
    -+	cl_assert_equal_i(reftable_stack_compact_all(st, NULL), REFTABLE_LOCK_ERROR);
    +-	check_int(st->merged->tables_len, ==, 3);
    ++	cl_assert_equal_i(err, REFTABLE_LOCK_ERROR);
     +	cl_assert_equal_i(st->stats.failures, 1);
    -+	cl_assert_equal_i(st->merged->readers_len, 3);
    ++	cl_assert_equal_i(st->merged->tables_len, 3);
      
      	reftable_stack_destroy(st);
      	reftable_buf_release(&buf);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_compaction_with_lo
      }
      
     @@ t/unit-tests/u-reftable-stack.c: static void unclean_stack_close(struct reftable_stack *st)
    - 	REFTABLE_FREE_AND_NULL(st->readers);
    + 	REFTABLE_FREE_AND_NULL(st->tables);
      }
      
     -static void t_reftable_stack_compaction_concurrent_clean(void)
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_compaction_concurr
      {
      	struct reftable_write_options opts = { 0 };
      	struct reftable_stack *st1 = NULL, *st2 = NULL;
    - 	struct reftable_ref_record rec = { 0 };
    - 	struct reftable_iterator it = { 0 };
    - 	char *dir = get_tmp_dir(__LINE__);
    --	int err;
    +@@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_read_across_reload(void)
    + 	int err;
      
      	/* Create a first stack and set up an iterator for it. */
     -	err = reftable_new_stack(&st1, dir, &opts);
     -	check(!err);
     +	cl_assert(reftable_new_stack(&st1, dir, &opts) == 0);
      	write_n_ref_tables(st1, 2);
    --	check_int(st1->merged->readers_len, ==, 2);
    -+	cl_assert_equal_i(st1->merged->readers_len, 2);
    +-	check_int(st1->merged->tables_len, ==, 2);
    ++	cl_assert_equal_i(st1->merged->tables_len, 2);
      	reftable_stack_init_ref_iterator(st1, &it);
     -	err = reftable_iterator_seek_ref(&it, "");
     -	check(!err);
     +	cl_assert(reftable_iterator_seek_ref(&it, "") == 0);
      
      	/* Set up a second stack for the same directory and compact it. */
    --	err = reftable_new_stack(&st2, dir, &opts);
    + 	err = reftable_new_stack(&st2, dir, &opts);
     -	check(!err);
    --	check_int(st2->merged->readers_len, ==, 2);
    --	err = reftable_stack_compact_all(st2, NULL);
    +-	check_int(st2->merged->tables_len, ==, 2);
    ++	cl_assert(!err);
    ++	cl_assert_equal_i(st2->merged->tables_len, 2);
    + 	err = reftable_stack_compact_all(st2, NULL);
     -	check(!err);
    --	check_int(st2->merged->readers_len, ==, 1);
    -+	cl_assert(reftable_new_stack(&st2, dir, &opts) == 0);
    -+	cl_assert_equal_i(st2->merged->readers_len, 2);
    -+	cl_assert(reftable_stack_compact_all(st2, NULL) == 0);
    -+	cl_assert_equal_i(st2->merged->readers_len, 1);
    +-	check_int(st2->merged->tables_len, ==, 1);
    ++	cl_assert(!err);
    ++	cl_assert_equal_i(st2->merged->tables_len, 1);
      
      	/*
      	 * Verify that we can continue to use the old iterator even after we
      	 * have reloaded its stack.
      	 */
    --	err = reftable_stack_reload(st1);
    + 	err = reftable_stack_reload(st1);
     -	check(!err);
    --	check_int(st1->merged->readers_len, ==, 1);
    --	err = reftable_iterator_next_ref(&it, &rec);
    +-	check_int(st1->merged->tables_len, ==, 1);
    ++	cl_assert(!err);
    ++	cl_assert_equal_i(st1->merged->tables_len, 1);
    + 	err = reftable_iterator_next_ref(&it, &rec);
     -	check(!err);
     -	check_str(rec.refname, "refs/heads/branch-0000");
    --	err = reftable_iterator_next_ref(&it, &rec);
    ++	cl_assert(!err);
    ++	cl_assert_equal_s(rec.refname, "refs/heads/branch-0000");
    + 	err = reftable_iterator_next_ref(&it, &rec);
     -	check(!err);
     -	check_str(rec.refname, "refs/heads/branch-0001");
    --	err = reftable_iterator_next_ref(&it, &rec);
    --	check_int(err, >, 0);
    -+	cl_assert(reftable_stack_reload(st1) == 0);
    -+	cl_assert_equal_i(st1->merged->readers_len, 1);
    -+	cl_assert(reftable_iterator_next_ref(&it, &rec) == 0);
    -+	cl_assert_equal_s(rec.refname, "refs/heads/branch-0000");
    -+	cl_assert(reftable_iterator_next_ref(&it, &rec) == 0);
    ++	cl_assert(!err);
     +	cl_assert_equal_s(rec.refname, "refs/heads/branch-0001");
    -+	cl_assert(reftable_iterator_next_ref(&it, &rec) > 0);
    + 	err = reftable_iterator_next_ref(&it, &rec);
    +-	check_int(err, >, 0);
    ++	cl_assert(err > 0);
      
      	reftable_ref_record_release(&rec);
      	reftable_iterator_destroy(&it);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_read_across_reload
      	struct reftable_write_options opts = { 0 };
      	struct reftable_stack *st = NULL;
     @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_reload_with_missing_table(void)
    - 	struct reftable_iterator it = { 0 };
    - 	struct reftable_buf table_path = REFTABLE_BUF_INIT, content = REFTABLE_BUF_INIT;
    - 	char *dir = get_tmp_dir(__LINE__);
    --	int err;
    + 	int err;
      
      	/* Create a first stack and set up an iterator for it. */
     -	err = reftable_new_stack(&st, dir, &opts);
     -	check(!err);
     +	cl_assert(reftable_new_stack(&st, dir, &opts) == 0);
      	write_n_ref_tables(st, 2);
    --	check_int(st->merged->readers_len, ==, 2);
    -+	cl_assert_equal_i(st->merged->readers_len, 2);
    +-	check_int(st->merged->tables_len, ==, 2);
    ++	cl_assert_equal_i(st->merged->tables_len, 2);
      	reftable_stack_init_ref_iterator(st, &it);
     -	err = reftable_iterator_seek_ref(&it, "");
     -	check(!err);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_reload_with_missin
      
      	/*
      	 * Update the tables.list file with some garbage data, while reusing
    - 	 * our old readers. This should trigger a partial reload of the stack,
    - 	 * where we try to reuse our old readers.
    + 	 * our old tables. This should trigger a partial reload of the stack,
    + 	 * where we try to reuse our old tables.
      	*/
    --	check(!reftable_buf_addstr(&content, st->readers[0]->name));
    +-	check(!reftable_buf_addstr(&content, st->tables[0]->name));
     -	check(!reftable_buf_addstr(&content, "\n"));
    --	check(!reftable_buf_addstr(&content, st->readers[1]->name));
    +-	check(!reftable_buf_addstr(&content, st->tables[1]->name));
     -	check(!reftable_buf_addstr(&content, "\n"));
     -	check(!reftable_buf_addstr(&content, "garbage\n"));
     -	check(!reftable_buf_addstr(&table_path, st->list_file));
     -	check(!reftable_buf_addstr(&table_path, ".lock"));
    -+	cl_assert(reftable_buf_addstr(&content, st->readers[0]->name) == 0);
    -+	cl_assert(reftable_buf_addstr(&content, "\n") == 0);
    -+	cl_assert(reftable_buf_addstr(&content, st->readers[1]->name) == 0);
    -+	cl_assert(reftable_buf_addstr(&content, "\n") == 0);
    -+	cl_assert(reftable_buf_addstr(&content, "garbage\n") == 0);
    -+	cl_assert(reftable_buf_addstr(&table_path, st->list_file) == 0);
    -+	cl_assert(reftable_buf_addstr(&table_path, ".lock") == 0);
    ++	cl_assert(!reftable_buf_addstr(&content, st->tables[0]->name));
    ++	cl_assert(!reftable_buf_addstr(&content, "\n"));
    ++	cl_assert(!reftable_buf_addstr(&content, st->tables[1]->name));
    ++	cl_assert(!reftable_buf_addstr(&content, "\n"));
    ++	cl_assert(!reftable_buf_addstr(&content, "garbage\n"));
    ++	cl_assert(!reftable_buf_addstr(&table_path, st->list_file));
    ++	cl_assert(!reftable_buf_addstr(&table_path, ".lock"));
      	write_file_buf(table_path.buf, content.buf, content.len);
     -	err = rename(table_path.buf, st->list_file);
     -	check(!err);
     +	cl_assert(rename(table_path.buf, st->list_file) == 0);
      
    --	err = reftable_stack_reload(st);
    + 	err = reftable_stack_reload(st);
     -	check_int(err, ==, -4);
    --	check_int(st->merged->readers_len, ==, 2);
    -+	cl_assert_equal_i(reftable_stack_reload(st), -4);
    -+	cl_assert_equal_i(st->merged->readers_len, 2);
    +-	check_int(st->merged->tables_len, ==, 2);
    ++	cl_assert_equal_i(err, -4);
    ++	cl_assert_equal_i(st->merged->tables_len, 2);
      
      	/*
      	 * Even though the reload has failed, we should be able to continue
10:  79aa0145aa <  -:  ---------- t/unit-tests: adapt lib-reftable{c,h} helper functions to clar
 -:  ---------- > 10:  7ea45d3600 t/unit-tests: finalize migration of reftable-related tests
Signature · 1 line
2.43.0
#1 lore raw

PATCH v3 1/10 t/unit-tests: implement clar specific reftable test helper functions

Helper functions defined in t/unit-tests/lib-reftable.{c,h} are required for the reftable-related test files to run. In the current implementation these functions are designed to conform with our homegrown unit-testing structure. So in other to convert the reftable test files, there is need for a clar specific implementation of these helper functions.

Implement equivalent helper functions in lib-reftable-clar.{c,h} to use clar. These functions conform with the clar testing framework and become available for all reftable-related test files implemented using the clar testing framework, which requires them. This will be used by subsequent commits.

---
 Makefile                         |   1 +
 t/meson.build                    |   3 +-
 t/unit-tests/lib-reftable-clar.c | 101 +++++++++++++++++++++++++++++++
 t/unit-tests/lib-reftable-clar.h |  20 ++++++
 4 files changed, 124 insertions(+), 1 deletion(-)
 create mode 100644 t/unit-tests/lib-reftable-clar.c
 create mode 100644 t/unit-tests/lib-reftable-clar.h
Makefile +1 -0
index 70d1543b6b..e4fa038508 100644
@@ -1375,6 +1375,7 @@ CLAR_TEST_OBJS = $(patsubst %,$(UNIT_TEST_DIR)/%.o,$(CLAR_TEST_SUITES))
 CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/clar/clar.o
 CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
 CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-oid.o
+CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable-clar.o
 
 UNIT_TEST_PROGRAMS += t-reftable-basics
 UNIT_TEST_PROGRAMS += t-reftable-block
t/meson.build +2 -1
index d052fc3e23..f77f21536e 100644
@@ -19,7 +19,8 @@ clar_test_suites = [
 clar_sources = [
   'unit-tests/clar/clar.c',
   'unit-tests/unit-test.c',
-  'unit-tests/lib-oid.c'
+  'unit-tests/lib-oid.c',
+  'unit-tests/lib-reftable-clar.c'
 ]
 
 clar_decls_h = custom_target(
t/unit-tests/lib-reftable-clar.c new file +101 -0

101 lines not on this page · raw message

t/unit-tests/lib-reftable-clar.h new file +20 -0
new file mode 100644
index 0000000000..b562648973
@@ -0,0 +1,20 @@
+#include "git-compat-util.h"
+#include "clar/clar.h"
+#include "clar-decls.h"
+#include "git-compat-util.h"
+#include "reftable/reftable-writer.h"
+#include "strbuf.h"
+
+struct reftable_buf;
+
+void cl_reftable_set_hash(uint8_t *p, int i, enum reftable_hash id);
+
+struct reftable_writer *cl_reftable_strbuf_writer(struct reftable_buf *buf,
+						  struct reftable_write_options *opts);
+
+void cl_reftable_write_to_buf(struct reftable_buf *buf,
+			     struct reftable_ref_record *refs,
+			     size_t nrecords,
+			     struct reftable_log_record *logs,
+			     size_t nlogs,
+			     struct reftable_write_options *opts);
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH v3 01/10] t/unit-tests: implement clar specific reftable test helper functions

Quoted 4 lines · Seyi Kuforiji

Helper functions defined in t/unit-tests/lib-reftable.{c,h} are required for the reftable-related test files to run. In the current implementation these functions are designed to conform with our homegrown unit-testing structure. So in other to convert the reftable

nit: s/in other/in order/

Quoted 2 lines

test files, there is need for a clar specific implementation of these helper functions.

#3 lore raw

PATCH v3 2/10 t/unit-tests: convert reftable basics test to use clar test framework

In reply to Seyi Kuforiji

Adapt reftable basics test file to clar by using clar assertions where necessary.Break up test edge case to improve modularity and clarity.

---
 Makefile                         |   2 +-
 t/meson.build                    |   2 +-
 t/unit-tests/t-reftable-basics.c | 219 -----------------------------
 t/unit-tests/u-reftable-basics.c | 227 +++++++++++++++++++++++++++++++
 4 files changed, 229 insertions(+), 221 deletions(-)
 delete mode 100644 t/unit-tests/t-reftable-basics.c
 create mode 100644 t/unit-tests/u-reftable-basics.c
Makefile +1 -1
index e4fa038508..a01103e3a6 100644
@@ -1364,6 +1364,7 @@ CLAR_TEST_SUITES += u-oid-array
 CLAR_TEST_SUITES += u-oidmap
 CLAR_TEST_SUITES += u-oidtree
 CLAR_TEST_SUITES += u-prio-queue
+CLAR_TEST_SUITES += u-reftable-basics
 CLAR_TEST_SUITES += u-reftable-tree
 CLAR_TEST_SUITES += u-strbuf
 CLAR_TEST_SUITES += u-strcmp-offset
@@ -1377,7 +1378,6 @@ CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
 CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-oid.o
 CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable-clar.o
 
-UNIT_TEST_PROGRAMS += t-reftable-basics
 UNIT_TEST_PROGRAMS += t-reftable-block
 UNIT_TEST_PROGRAMS += t-reftable-merged
 UNIT_TEST_PROGRAMS += t-reftable-pq
t/meson.build +1 -1
index f77f21536e..e00e8d41d6 100644
@@ -8,6 +8,7 @@ clar_test_suites = [
   'unit-tests/u-oidmap.c',
   'unit-tests/u-oidtree.c',
   'unit-tests/u-prio-queue.c',
+  'unit-tests/u-reftable-basics.c',
   'unit-tests/u-reftable-tree.c',
   'unit-tests/u-strbuf.c',
   'unit-tests/u-strcmp-offset.c',
@@ -55,7 +56,6 @@ clar_unit_tests = executable('unit-tests',
 test('unit-tests', clar_unit_tests)
 
 unit_test_programs = [
-  'unit-tests/t-reftable-basics.c',
   'unit-tests/t-reftable-block.c',
   'unit-tests/t-reftable-merged.c',
   'unit-tests/t-reftable-pq.c',
t/unit-tests/t-reftable-basics.c deleted +0 -219

219 lines not on this page · raw message

t/unit-tests/u-reftable-basics.c new file +227 -0

227 lines not on this page · raw message

Signature · 1 line
2.43.0
#4 lore raw

Re: [PATCH v3 02/10] t/unit-tests: convert reftable basics test to use clar test framework

Quoted 2 lines · Seyi Kuforiji

Adapt reftable basics test file to clar by using clar assertions where necessary.Break up test edge case to improve modularity and

Nit: missing space.

Quoted 11 lines

clarity.

---
 Makefile                         |   2 +-
 t/meson.build                    |   2 +-
 t/unit-tests/t-reftable-basics.c | 219 -----------------------------
 t/unit-tests/u-reftable-basics.c | 227 +++++++++++++++++++++++++++++++
 4 files changed, 229 insertions(+), 221 deletions(-)
 delete mode 100644 t/unit-tests/t-reftable-basics.c
 create mode 100644 t/unit-tests/u-reftable-basics.c

Hm, these still show as deletion and addition :/ Did you try playing around with the creation factor? What is the exact command that you have used to generate these mails?

Patrick

#5 lore raw

Re: [PATCH v3 02/10] t/unit-tests: convert reftable basics test to use clar test framework

Quoted 19 lines · Patrick Steinhardt
Quoted 2 lines · Seyi Kuforiji

Adapt reftable basics test file to clar by using clar assertions where necessary.Break up test edge case to improve modularity and

Nit: missing space.

Quoted 11 lines

clarity.

---
 Makefile                         |   2 +-
 t/meson.build                    |   2 +-
 t/unit-tests/t-reftable-basics.c | 219 -----------------------------
 t/unit-tests/u-reftable-basics.c | 227 +++++++++++++++++++++++++++++++
 4 files changed, 229 insertions(+), 221 deletions(-)
 delete mode 100644 t/unit-tests/t-reftable-basics.c
 create mode 100644 t/unit-tests/u-reftable-basics.c
Quoted 5 lines

Hm, these still show as deletion and addition :/ Did you try playing around with the creation factor? What is the exact command that you have used to generate these mails?

Patrick

This was the only file that came out as a deletion and creation. Below is the command I used:

git format-patch -v3 --cover-letter --find-renames=20% --range-diff=upstream/master..convert-reftable-clar-v2 upstream/master

Thanks,
Seyi

#6 lore raw

Re: [PATCH v3 02/10] t/unit-tests: convert reftable basics test to use clar test framework

Quoted 14 lines · Seyi Kuforiji
Quoted 13 lines · Patrick Steinhardt
Quoted 7 lines · Seyi Kuforiji
 Makefile                         |   2 +-
 t/meson.build                    |   2 +-
 t/unit-tests/t-reftable-basics.c | 219 -----------------------------
 t/unit-tests/u-reftable-basics.c | 227 +++++++++++++++++++++++++++++++
 4 files changed, 229 insertions(+), 221 deletions(-)
 delete mode 100644 t/unit-tests/t-reftable-basics.c
 create mode 100644 t/unit-tests/u-reftable-basics.c

Hm, these still show as deletion and addition :/ Did you try playing around with the creation factor? What is the exact command that you have used to generate these mails?

Quoted 8 lines
Quoted 1 line

Patrick

This was the only file that came out as a deletion and creation. Below is the command I used:

git format-patch -v3 --cover-letter --find-renames=20% --range-diff=upstream/master..convert-reftable-clar-v2 upstream/master

Ah, true indeed. Never mind then, I think this is good enough :) Thanks!

Patrick

#7 lore raw

PATCH v3 3/10 t/unit-tests: convert reftable block test to use clar

In reply to Seyi Kuforiji

Adapt reftable block test file to use clar testing framework by using clar assertions where necessary.

---
 Makefile                                      |   2 +-
 t/meson.build                                 |   2 +-
 ...{t-reftable-block.c => u-reftable-block.c} | 164 +++++++++---------
 3 files changed, 80 insertions(+), 88 deletions(-)
 rename t/unit-tests/{t-reftable-block.c => u-reftable-block.c} (74%)
Makefile +1 -1
index a01103e3a6..d01dfd179b 100644
@@ -1365,6 +1365,7 @@ CLAR_TEST_SUITES += u-oidmap
 CLAR_TEST_SUITES += u-oidtree
 CLAR_TEST_SUITES += u-prio-queue
 CLAR_TEST_SUITES += u-reftable-basics
+CLAR_TEST_SUITES += u-reftable-block
 CLAR_TEST_SUITES += u-reftable-tree
 CLAR_TEST_SUITES += u-strbuf
 CLAR_TEST_SUITES += u-strcmp-offset
@@ -1378,7 +1379,6 @@ CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
 CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-oid.o
 CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable-clar.o
 
-UNIT_TEST_PROGRAMS += t-reftable-block
 UNIT_TEST_PROGRAMS += t-reftable-merged
 UNIT_TEST_PROGRAMS += t-reftable-pq
 UNIT_TEST_PROGRAMS += t-reftable-readwrite
t/meson.build +1 -1
index e00e8d41d6..b1d9dea9e7 100644
@@ -9,6 +9,7 @@ clar_test_suites = [
   'unit-tests/u-oidtree.c',
   'unit-tests/u-prio-queue.c',
   'unit-tests/u-reftable-basics.c',
+  'unit-tests/u-reftable-block.c',
   'unit-tests/u-reftable-tree.c',
   'unit-tests/u-strbuf.c',
   'unit-tests/u-strcmp-offset.c',
@@ -56,7 +57,6 @@ clar_unit_tests = executable('unit-tests',
 test('unit-tests', clar_unit_tests)
 
 unit_test_programs = [
-  'unit-tests/t-reftable-block.c',
   'unit-tests/t-reftable-merged.c',
   'unit-tests/t-reftable-pq.c',
   'unit-tests/t-reftable-readwrite.c',
t/unit-tests/u-reftable-block.c renamed from t/unit-tests/t-reftable-block.c +78 -86

409 lines not on this page · raw message

Signature · 1 line
2.43.0
#8 lore raw

Re: [PATCH v3 03/10] t/unit-tests: convert reftable block test to use clar

Quoted 15 lines · Seyi Kuforiji
t/unit-tests/u-reftable-block.c renamed from t/unit-tests/t-reftable-block.c +2 -1
similarity index 74%
rename from t/unit-tests/t-reftable-block.c
rename to t/unit-tests/u-reftable-block.c
index 52f1dae1c9..5d1419b801 100644
@@ -6,14 +6,15 @@ license that can be found in the LICENSE file or at
 https://developers.google.com/open-source/licenses/bsd
 */
 
-#include "test-lib.h"
+#include "unit-test.h"
+#include "lib-reftable-clar.h"
 #include "reftable/block.h"

t/unit-tests/u-reftable-block.c license that can be found in the LICENSE file or at · line 20

Quoted 10 lines
t/unit-tests/u-reftable-block.c renamed from t/unit-tests/t-reftable-block.c +1 -1
 #include "reftable/blocksource.h"
 #include "reftable/constants.h"
 #include "reftable/reftable-error.h"
 #include "strbuf.h"
 
-static void t_ref_block_read_write(void)
+void test_reftable_block__index_read_write(void)
 {
 	const int header_off = 21; /* random */
 	struct reftable_record recs[30];

The name here still looks wrong to me. This is about writing ref blocks, not index blocks.

t/unit-tests/u-reftable-block.c static void t_obj_block_read_write(void) · line 230

Quoted 12 lines
t/unit-tests/u-reftable-block.c renamed from t/unit-tests/t-reftable-block.c +2 -2
@@ -220,12 +222,12 @@ static void t_obj_block_read_write(void)
 	struct reftable_buf block_data = REFTABLE_BUF_INIT;
 
 	REFTABLE_CALLOC_ARRAY(block_data.buf, block_size);
-	check(block_data.buf != NULL);
+	cl_assert(block_data.buf != NULL);
 	block_data.len = block_size;
 
 	ret = block_writer_init(&bw, REFTABLE_BLOCK_TYPE_OBJ, (uint8_t *) block_data.buf, block_size,
 				header_off, hash_size(REFTABLE_HASH_SHA1));
-	check(!ret);
+	cl_assert(ret == 0);

All of these could be retained as cl_assert(!ret), which is more idiomatic in our codebase. Either that, or these should use cl_assert_equal_i() to give better diagnostics.

Patrick

#9 lore raw

PATCH v3 4/10 t/unit-tests: convert reftable merged test to use clar

In reply to Seyi Kuforiji

Adapt reftable merged test file to use clar testing framework by using clar assertions where necessary.

---
 Makefile                                      |   2 +-
 t/meson.build                                 |   2 +-
 ...-reftable-merged.c => u-reftable-merged.c} | 162 ++++++++----------
 3 files changed, 72 insertions(+), 94 deletions(-)
 rename t/unit-tests/{t-reftable-merged.c => u-reftable-merged.c} (77%)
Makefile +1 -1
index d01dfd179b..fb0ef10ff2 100644
@@ -1366,6 +1366,7 @@ CLAR_TEST_SUITES += u-oidtree
 CLAR_TEST_SUITES += u-prio-queue
 CLAR_TEST_SUITES += u-reftable-basics
 CLAR_TEST_SUITES += u-reftable-block
+CLAR_TEST_SUITES += u-reftable-merged
 CLAR_TEST_SUITES += u-reftable-tree
 CLAR_TEST_SUITES += u-strbuf
 CLAR_TEST_SUITES += u-strcmp-offset
@@ -1379,7 +1380,6 @@ CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
 CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-oid.o
 CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable-clar.o
 
-UNIT_TEST_PROGRAMS += t-reftable-merged
 UNIT_TEST_PROGRAMS += t-reftable-pq
 UNIT_TEST_PROGRAMS += t-reftable-readwrite
 UNIT_TEST_PROGRAMS += t-reftable-record
t/meson.build +1 -1
index b1d9dea9e7..d25dfb0c92 100644
@@ -10,6 +10,7 @@ clar_test_suites = [
   'unit-tests/u-prio-queue.c',
   'unit-tests/u-reftable-basics.c',
   'unit-tests/u-reftable-block.c',
+  'unit-tests/u-reftable-merged.c',
   'unit-tests/u-reftable-tree.c',
   'unit-tests/u-strbuf.c',
   'unit-tests/u-strcmp-offset.c',
@@ -57,7 +58,6 @@ clar_unit_tests = executable('unit-tests',
 test('unit-tests', clar_unit_tests)
 
 unit_test_programs = [
-  'unit-tests/t-reftable-merged.c',
   'unit-tests/t-reftable-pq.c',
   'unit-tests/t-reftable-readwrite.c',
   'unit-tests/t-reftable-record.c',
t/unit-tests/u-reftable-merged.c renamed from t/unit-tests/t-reftable-merged.c +70 -92

330 lines not on this page · raw message

Signature · 1 line
2.43.0
#10 lore raw

PATCH v3 5/10 t/unit-tests: convert reftable pq test to use clar

In reply to Seyi Kuforiji

Adapt reftable priority queue test file to use clar by using clar assertions where necessary.

---
 Makefile                                      |  2 +-
 t/meson.build                                 |  3 +-
 .../{t-reftable-pq.c => u-reftable-pq.c}      | 59 +++++++++----------
 3 files changed, 30 insertions(+), 34 deletions(-)
 rename t/unit-tests/{t-reftable-pq.c => u-reftable-pq.c} (64%)
Makefile +1 -1
index fb0ef10ff2..3cccc73073 100644
@@ -1367,6 +1367,7 @@ CLAR_TEST_SUITES += u-prio-queue
 CLAR_TEST_SUITES += u-reftable-basics
 CLAR_TEST_SUITES += u-reftable-block
 CLAR_TEST_SUITES += u-reftable-merged
+CLAR_TEST_SUITES += u-reftable-pq
 CLAR_TEST_SUITES += u-reftable-tree
 CLAR_TEST_SUITES += u-strbuf
 CLAR_TEST_SUITES += u-strcmp-offset
@@ -1380,7 +1381,6 @@ CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
 CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-oid.o
 CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable-clar.o
 
-UNIT_TEST_PROGRAMS += t-reftable-pq
 UNIT_TEST_PROGRAMS += t-reftable-readwrite
 UNIT_TEST_PROGRAMS += t-reftable-record
 UNIT_TEST_PROGRAMS += t-reftable-stack
t/meson.build +2 -1
index d25dfb0c92..ac4394b7a2 100644
@@ -11,6 +11,7 @@ clar_test_suites = [
   'unit-tests/u-reftable-basics.c',
   'unit-tests/u-reftable-block.c',
   'unit-tests/u-reftable-merged.c',
+  'unit-tests/u-reftable-pq.c',
   'unit-tests/u-reftable-tree.c',
   'unit-tests/u-strbuf.c',
   'unit-tests/u-strcmp-offset.c',
@@ -58,7 +59,7 @@ clar_unit_tests = executable('unit-tests',
 test('unit-tests', clar_unit_tests)
 
 unit_test_programs = [
-  'unit-tests/t-reftable-pq.c',
+  'unit-tests/t-reftable-reader.c',
   'unit-tests/t-reftable-readwrite.c',
   'unit-tests/t-reftable-record.c',
   'unit-tests/t-reftable-stack.c',
t/unit-tests/u-reftable-pq.c renamed from t/unit-tests/t-reftable-pq.c +27 -32

139 lines not on this page · raw message

Signature · 1 line
2.43.0
#11 lore raw

PATCH v3 6/10 t/unit-tests: convert reftable table test to use clar

In reply to Seyi Kuforiji

Adapt reftable table test file to use clar by using clar assertions where necessary.

---
 Makefile                                      |  4 +-
 t/meson.build                                 |  5 +-
 ...{t-reftable-table.c => u-reftable-table.c} | 73 +++++++++----------
 3 files changed, 38 insertions(+), 44 deletions(-)
 rename t/unit-tests/{t-reftable-table.c => u-reftable-table.c} (75%)
Makefile +2 -2
index 3cccc73073..0227fdb3e1 100644
@@ -1368,6 +1368,7 @@ CLAR_TEST_SUITES += u-reftable-basics
 CLAR_TEST_SUITES += u-reftable-block
 CLAR_TEST_SUITES += u-reftable-merged
 CLAR_TEST_SUITES += u-reftable-pq
+CLAR_TEST_SUITES += u-reftable-table
 CLAR_TEST_SUITES += u-reftable-tree
 CLAR_TEST_SUITES += u-strbuf
 CLAR_TEST_SUITES += u-strcmp-offset
@@ -1384,7 +1385,6 @@ CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable-clar.o
 UNIT_TEST_PROGRAMS += t-reftable-readwrite
 UNIT_TEST_PROGRAMS += t-reftable-record
 UNIT_TEST_PROGRAMS += t-reftable-stack
-UNIT_TEST_PROGRAMS += t-reftable-table
 UNIT_TEST_PROGS = $(patsubst %,$(UNIT_TEST_BIN)/%$X,$(UNIT_TEST_PROGRAMS))
 UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/test-lib.o
 UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable.o
@@ -3972,4 +3972,4 @@ $(LIBGIT_HIDDEN_EXPORT): $(LIBGIT_PARTIAL_EXPORT)
 	$(OBJCOPY) --localize-hidden $^ $@
 
 contrib/libgit-sys/libgitpub.a: $(LIBGIT_HIDDEN_EXPORT)
-	$(AR) $(ARFLAGS) $@ $^
+	$(AR) $(ARFLAGS) $@ $^
\ No newline at end of file
t/meson.build +2 -3
index ac4394b7a2..46d3a8580b 100644
@@ -12,6 +12,7 @@ clar_test_suites = [
   'unit-tests/u-reftable-block.c',
   'unit-tests/u-reftable-merged.c',
   'unit-tests/u-reftable-pq.c',
+  'unit-tests/u-reftable-table.c',
   'unit-tests/u-reftable-tree.c',
   'unit-tests/u-strbuf.c',
   'unit-tests/u-strcmp-offset.c',
@@ -59,11 +60,9 @@ clar_unit_tests = executable('unit-tests',
 test('unit-tests', clar_unit_tests)
 
 unit_test_programs = [
-  'unit-tests/t-reftable-reader.c',
   'unit-tests/t-reftable-readwrite.c',
   'unit-tests/t-reftable-record.c',
   'unit-tests/t-reftable-stack.c',
-  'unit-tests/t-reftable-table.c',
 ]
 
 foreach unit_test_program : unit_test_programs
@@ -1233,4 +1232,4 @@ if perl.found() and time.found()
       timeout: 0,
     )
   endforeach
-endif
+endif
\ No newline at end of file
t/unit-tests/u-reftable-table.c renamed from t/unit-tests/t-reftable-table.c +34 -39

169 lines not on this page · raw message

Signature · 1 line
2.43.0
#12 lore raw

Re: [PATCH v3 06/10] t/unit-tests: convert reftable table test to use clar

Makefile $(LIBGIT_HIDDEN_EXPORT): $(LIBGIT_PARTIAL_EXPORT) · line 3975

Quoted 12 lines · Seyi Kuforiji
Makefile +1 -1
index 3cccc73073..0227fdb3e1 100644
...
@@ -3972,4 +3972,4 @@ $(LIBGIT_HIDDEN_EXPORT): $(LIBGIT_PARTIAL_EXPORT)
 	$(OBJCOPY) --localize-hidden $^ $@
 
 contrib/libgit-sys/libgitpub.a: $(LIBGIT_HIDDEN_EXPORT)
-	$(AR) $(ARFLAGS) $@ $^
+	$(AR) $(ARFLAGS) $@ $^
\ No newline at end of file

I'll fix this up before pushing this morning's integration result out, but here is an occasion for a quick quiz.

Can anybody tell, without running "make <something>", what this accidental and unintended change breaks? It may be rather surprising ;-)

#13 lore raw

Re: [PATCH v3 06/10] t/unit-tests: convert reftable table test to use clar

Quoted 19 lines · Junio C Hamano

Makefile $(LIBGIT_HIDDEN_EXPORT): $(LIBGIT_PARTIAL_EXPORT) · line 3975

Quoted 12 lines · Seyi Kuforiji
Makefile +1 -1
index 3cccc73073..0227fdb3e1 100644
...
@@ -3972,4 +3972,4 @@ $(LIBGIT_HIDDEN_EXPORT): $(LIBGIT_PARTIAL_EXPORT)
      $(OBJCOPY) --localize-hidden $^ $@
 
 contrib/libgit-sys/libgitpub.a: $(LIBGIT_HIDDEN_EXPORT)
-     $(AR) $(ARFLAGS) $@ $^
+     $(AR) $(ARFLAGS) $@ $^
\ No newline at end of file

I'll fix this up before pushing this morning's integration result out, but here is an occasion for a quick quiz.

Quoted 5 lines

Can anybody tell, without running "make <something>", what this accidental and unintended change breaks? It may be rather surprising ;-)

Hi Junio,

I'm guessing this messes with the installation of dependencies, but I'm not certain.

Thanks,
Seyi

#14 lore raw

Re: [PATCH v3 06/10] t/unit-tests: convert reftable table test to use clar

In reply to Junio C Hamano
Quoted 8 lines · Junio C Hamano
Quoted 8 lines
Makefile +0 -0
index 3cccc73073..0227fdb3e1 100644
...
@@ -3972,4 +3972,4 @@ $(LIBGIT_HIDDEN_EXPORT): $(LIBGIT_PARTIAL_EXPORT)
 	$(OBJCOPY) --localize-hidden $^ $@
 
Quoted 8 lines

Makefile $(LIBGIT_HIDDEN_EXPORT): $(LIBGIT_PARTIAL_EXPORT) · line 3975

Quoted 4 lines
Makefile +1 -1
 contrib/libgit-sys/libgitpub.a: $(LIBGIT_HIDDEN_EXPORT)
-	$(AR) $(ARFLAGS) $@ $^
+	$(AR) $(ARFLAGS) $@ $^
\ No newline at end of file

Can anybody tell, without running "make <something>", what this accidental and unintended change breaks? It may be rather surprising ;-)

After dropping the last newline from the top-level Makefile,

    $ make check-docs

ends like this:

    $ make check-docs
    make -C Documentation lint-docs
    make[1]: Entering directory '/home/gitster/git.git/Documentation'
        GEN lint-docs-manpages
    removed but documented: git
    removed but documented: git-add
    ...
    removed but documented: git-write-tree
    removed but documented: scalar
    removed but listed: git-add
    removed but listed: git-am
    ...
    removed but listed: git-write-tree
    removed but listed: scalar
    make[1]: *** [Makefile:504: lint-docs-manpages] Error 1
    make[1]: Leaving directory '/home/gitster/git.git/Documentation'
    make: *** [Makefile:3829: check-docs] Error 2

This is because of a cute Makefile trick used in lint-manpages script is not written robustly enough, but that is not much less interesting than the lesson we learn from this episode.

A more robust and traditional way to use the same Makefile trick is to apply this patch to Documentation/lint-manpages.sh by the way.

 Documentation/lint-manpages.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/lint-manpages.sh +1 -1
index a0ea572382..65758a3159 100755
@@ -2,11 +2,11 @@
 
 extract_variable () {
 	(
-		cat ../Makefile
 		cat <<EOF
 print_variable:
 	@\$(foreach b,\$($1),echo XXX \$(b:\$X=) YYY;)
 EOF
+		cat ../Makefile
 	) |
 	make -C .. -f - print_variable 2>/dev/null |
 	sed -n -e 's/.*XXX \(.*\) YYY.*/\1/p'
#15 lore raw

PATCH v3 7/10 t/unit-tests: convert reftable readwrite test to use clar

In reply to Seyi Kuforiji

Adapt reftable readwrite test file to use clar by using clar assertions where necessary.

---
 Makefile                                      |   2 +-
 t/meson.build                                 |   2 +-
 ...ble-readwrite.c => u-reftable-readwrite.c} | 386 ++++++++----------
 3 files changed, 165 insertions(+), 225 deletions(-)
 rename t/unit-tests/{t-reftable-readwrite.c => u-reftable-readwrite.c} (68%)
Makefile +1 -1
index 0227fdb3e1..d86ef5a142 100644
@@ -1368,6 +1368,7 @@ CLAR_TEST_SUITES += u-reftable-basics
 CLAR_TEST_SUITES += u-reftable-block
 CLAR_TEST_SUITES += u-reftable-merged
 CLAR_TEST_SUITES += u-reftable-pq
+CLAR_TEST_SUITES += u-reftable-readwrite
 CLAR_TEST_SUITES += u-reftable-table
 CLAR_TEST_SUITES += u-reftable-tree
 CLAR_TEST_SUITES += u-strbuf
@@ -1382,7 +1383,6 @@ CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
 CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-oid.o
 CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable-clar.o
 
-UNIT_TEST_PROGRAMS += t-reftable-readwrite
 UNIT_TEST_PROGRAMS += t-reftable-record
 UNIT_TEST_PROGRAMS += t-reftable-stack
 UNIT_TEST_PROGS = $(patsubst %,$(UNIT_TEST_BIN)/%$X,$(UNIT_TEST_PROGRAMS))
t/meson.build +1 -1
index 46d3a8580b..5189176472 100644
@@ -12,6 +12,7 @@ clar_test_suites = [
   'unit-tests/u-reftable-block.c',
   'unit-tests/u-reftable-merged.c',
   'unit-tests/u-reftable-pq.c',
+  'unit-tests/u-reftable-readwrite.c',
   'unit-tests/u-reftable-table.c',
   'unit-tests/u-reftable-tree.c',
   'unit-tests/u-strbuf.c',
@@ -60,7 +61,6 @@ clar_unit_tests = executable('unit-tests',
 test('unit-tests', clar_unit_tests)
 
 unit_test_programs = [
-  'unit-tests/t-reftable-readwrite.c',
   'unit-tests/t-reftable-record.c',
   'unit-tests/t-reftable-stack.c',
 ]
t/unit-tests/u-reftable-readwrite.c renamed from t/unit-tests/t-reftable-readwrite.c +163 -223

945 lines not on this page · raw message

Signature · 1 line
2.43.0
#16 lore raw

PATCH v3 8/10 t/unit-tests: convert reftable record test to use clar

In reply to Seyi Kuforiji

Adapt reftable record test file to use clar by using clar assertions where necessary.

---
 Makefile                                      |   1 -
 t/meson.build                                 |   1 -
 ...-reftable-record.c => u-reftable-record.c} | 217 ++++++++----------
 3 files changed, 99 insertions(+), 120 deletions(-)
 rename t/unit-tests/{t-reftable-record.c => u-reftable-record.c} (63%)
Makefile +0 -1
index d86ef5a142..3b41342ddb 100644
@@ -1383,7 +1383,6 @@ CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
 CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-oid.o
 CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable-clar.o
 
-UNIT_TEST_PROGRAMS += t-reftable-record
 UNIT_TEST_PROGRAMS += t-reftable-stack
 UNIT_TEST_PROGS = $(patsubst %,$(UNIT_TEST_BIN)/%$X,$(UNIT_TEST_PROGRAMS))
 UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/test-lib.o
t/meson.build +0 -1
index 5189176472..297937f307 100644
@@ -61,7 +61,6 @@ clar_unit_tests = executable('unit-tests',
 test('unit-tests', clar_unit_tests)
 
 unit_test_programs = [
-  'unit-tests/t-reftable-record.c',
   'unit-tests/t-reftable-stack.c',
 ]
 
t/unit-tests/u-reftable-record.c renamed from t/unit-tests/t-reftable-record.c +99 -118

423 lines not on this page · raw message

Signature · 1 line
2.43.0
#17 lore raw

PATCH v3 9/10 t/unit-tests: convert reftable stack test to use clar

In reply to Seyi Kuforiji

Adapt reftable stack test file to use clar by using clar assertions where necessary.

This marks the end of all unit tests migrated away from the unit-tests/t-*.c pattern, there are no longer any files matching that glob. Remove the sanity check for t-*.c files to prevent Meson configuration errors during CI and local builds.

---
 Makefile                                      |   2 +-
 t/meson.build                                 |   5 +-
 ...{t-reftable-stack.c => u-reftable-stack.c} | 726 +++++++-----------
 3 files changed, 282 insertions(+), 451 deletions(-)
 rename t/unit-tests/{t-reftable-stack.c => u-reftable-stack.c} (59%)
Makefile +1 -1
index 3b41342ddb..8ed8f234f4 100644
@@ -1369,6 +1369,7 @@ CLAR_TEST_SUITES += u-reftable-block
 CLAR_TEST_SUITES += u-reftable-merged
 CLAR_TEST_SUITES += u-reftable-pq
 CLAR_TEST_SUITES += u-reftable-readwrite
+CLAR_TEST_SUITES += u-reftable-stack
 CLAR_TEST_SUITES += u-reftable-table
 CLAR_TEST_SUITES += u-reftable-tree
 CLAR_TEST_SUITES += u-strbuf
@@ -1383,7 +1384,6 @@ CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
 CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-oid.o
 CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable-clar.o
 
-UNIT_TEST_PROGRAMS += t-reftable-stack
 UNIT_TEST_PROGS = $(patsubst %,$(UNIT_TEST_BIN)/%$X,$(UNIT_TEST_PROGRAMS))
 UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/test-lib.o
 UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable.o
t/meson.build +2 -3
index 297937f307..fcbb659263 100644
@@ -13,6 +13,8 @@ clar_test_suites = [
   'unit-tests/u-reftable-merged.c',
   'unit-tests/u-reftable-pq.c',
   'unit-tests/u-reftable-readwrite.c',
+  'unit-tests/u-reftable-record.c',
+  'unit-tests/u-reftable-stack.c',
   'unit-tests/u-reftable-table.c',
   'unit-tests/u-reftable-tree.c',
   'unit-tests/u-strbuf.c',
@@ -61,7 +63,6 @@ clar_unit_tests = executable('unit-tests',
 test('unit-tests', clar_unit_tests)
 
 unit_test_programs = [
-  'unit-tests/t-reftable-stack.c',
 ]
 
 foreach unit_test_program : unit_test_programs
@@ -1163,8 +1164,6 @@ benchmarks = [
 # sufficient to catch missing test suites in our CI though.
 foreach glob, tests : {
   't[0-9][0-9][0-9][0-9]-*.sh': integration_tests,
-  'perf/p[0-9][0-9][0-9][0-9]-*.sh': benchmarks,
-  'unit-tests/t-*.c': unit_test_programs,
   'unit-tests/u-*.c': clar_test_suites,
 }
   actual_tests = run_command(shell, '-c', 'ls ' + glob,
t/unit-tests/u-reftable-stack.c renamed from t/unit-tests/t-reftable-stack.c +279 -447

1,421 lines not on this page · raw message

Signature · 1 line
2.43.0
#18 lore raw

PATCH v3 10/10 t/unit-tests: finalize migration of reftable-related tests

In reply to Seyi Kuforiji

The old lib-reftable.{c,h} implemented helper functions for our homegrown unit-testing framework. As part of migrating reftable-related tests to the Clar framework, Clar-specific versions of these functions in lib-reftable-clar.{c,h} were introduced.

Now that all test files using these helpers have been converted to Clar, we can safely remove the original lib-reftable.{c,h} and rename the Clar- specific versions back to lib-reftable.{c,h}. This restores a clean and consistent naming scheme for shared test utilities.

Finally, update our build system to reflect the changes made and remove redundant code related to the reftable tests and our old homegrown unit-testing setup.

---
 Makefile                            |   6 +-
 t/Makefile                          |   1 -
 t/meson.build                       |  21 +-----
 t/unit-tests/lib-reftable-clar.c    | 101 ----------------------------
 t/unit-tests/lib-reftable-clar.h    |  20 ------
 t/unit-tests/lib-reftable.c         |  35 +++++-----
 t/unit-tests/lib-reftable.h         |  15 ++---
 t/unit-tests/u-reftable-basics.c    |   2 +-
 t/unit-tests/u-reftable-block.c     |   2 +-
 t/unit-tests/u-reftable-merged.c    |   2 +-
 t/unit-tests/u-reftable-pq.c        |   2 +-
 t/unit-tests/u-reftable-readwrite.c |   2 +-
 t/unit-tests/u-reftable-record.c    |   2 +-
 t/unit-tests/u-reftable-stack.c     |   4 +-
 t/unit-tests/u-reftable-table.c     |   2 +-
 15 files changed, 38 insertions(+), 179 deletions(-)
 delete mode 100644 t/unit-tests/lib-reftable-clar.c
 delete mode 100644 t/unit-tests/lib-reftable-clar.h
Makefile +2 -4
index 8ed8f234f4..8d8f2d574d 100644
@@ -1380,13 +1380,11 @@ CLAR_TEST_SUITES += u-urlmatch-normalization
 CLAR_TEST_PROG = $(UNIT_TEST_BIN)/unit-tests$(X)
 CLAR_TEST_OBJS = $(patsubst %,$(UNIT_TEST_DIR)/%.o,$(CLAR_TEST_SUITES))
 CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/clar/clar.o
-CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
 CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-oid.o
-CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable-clar.o
+CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable.o
+CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
 
-UNIT_TEST_PROGS = $(patsubst %,$(UNIT_TEST_BIN)/%$X,$(UNIT_TEST_PROGRAMS))
 UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/test-lib.o
-UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable.o
 
 # xdiff and reftable libs may in turn depend on what is in libgit.a
 GITLIBS = common-main.o $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB) $(LIB_FILE)
t/Makefile +0 -1
index 791e0a0978..757674e727 100644
@@ -125,7 +125,6 @@ check-meson:
 	@mkdir -p mesontmp && \
 	printf "%s\n" \
 		"integration_tests t[0-9][0-9][0-9][0-9]-*.sh" \
-		"unit_test_programs unit-tests/t-*.c" \
 		"clar_test_suites unit-tests/u-*.c" | \
 	while read -r variable pattern; do \
 		awk "/^$$variable = \[\$$/ {flag=1 ; next } /^]$$/ { flag=0 } flag { gsub(/^  \047/, \"\"); gsub(/\047,\$$/, \"\"); print }" meson.build >mesontmp/meson.txt && \
t/meson.build +1 -20
index fcbb659263..be96a9639f 100644
@@ -28,7 +28,7 @@ clar_sources = [
   'unit-tests/clar/clar.c',
   'unit-tests/unit-test.c',
   'unit-tests/lib-oid.c',
-  'unit-tests/lib-reftable-clar.c'
+  'unit-tests/lib-reftable.c'
 ]
 
 clar_decls_h = custom_target(
@@ -62,25 +62,6 @@ clar_unit_tests = executable('unit-tests',
 )
 test('unit-tests', clar_unit_tests)
 
-unit_test_programs = [
-]
-
-foreach unit_test_program : unit_test_programs
-  unit_test_name = fs.stem(unit_test_program)
-  unit_test = executable(unit_test_name,
-    sources: [
-      'unit-tests/test-lib.c',
-      'unit-tests/lib-reftable.c',
-      unit_test_program,
-    ],
-    dependencies: [libgit_commonmain],
-  )
-  test(unit_test_name, unit_test,
-    workdir: meson.current_source_dir(),
-    timeout: 0,
-  )
-endforeach
-
 subdir('helper')
 
 integration_tests = [
t/unit-tests/lib-reftable-clar.c deleted +0 -101

101 lines not on this page · raw message

t/unit-tests/lib-reftable-clar.h deleted +0 -20
deleted file mode 100644
index b562648973..0000000000
@@ -1,20 +0,0 @@
-#include "git-compat-util.h"
-#include "clar/clar.h"
-#include "clar-decls.h"
-#include "git-compat-util.h"
-#include "reftable/reftable-writer.h"
-#include "strbuf.h"
-
-struct reftable_buf;
-
-void cl_reftable_set_hash(uint8_t *p, int i, enum reftable_hash id);
-
-struct reftable_writer *cl_reftable_strbuf_writer(struct reftable_buf *buf,
-						  struct reftable_write_options *opts);
-
-void cl_reftable_write_to_buf(struct reftable_buf *buf,
-			     struct reftable_ref_record *refs,
-			     size_t nrecords,
-			     struct reftable_log_record *logs,
-			     size_t nlogs,
-			     struct reftable_write_options *opts);
t/unit-tests/lib-reftable.c +19 -16
index 8a69612266..fdb5b11a20 100644
@@ -1,12 +1,14 @@
-#define DISABLE_SIGN_COMPARE_WARNINGS
-
+#include "unit-test.h"
 #include "lib-reftable.h"
-#include "test-lib.h"
+#include "hex.h"
+#include "parse-options.h"
 #include "reftable/constants.h"
 #include "reftable/writer.h"
 #include "strbuf.h"
+#include "string-list.h"
+#include "strvec.h"
 
-void t_reftable_set_hash(uint8_t *p, int i, enum reftable_hash id)
+void cl_reftable_set_hash(uint8_t *p, int i, enum reftable_hash id)
 {
 	memset(p, (uint8_t)i, hash_size(id));
 }
@@ -22,17 +24,17 @@ static int strbuf_writer_flush(void *arg UNUSED)
 	return 0;
 }
 
-struct reftable_writer *t_reftable_strbuf_writer(struct reftable_buf *buf,
+struct reftable_writer *cl_reftable_strbuf_writer(struct reftable_buf *buf,
 						 struct reftable_write_options *opts)
 {
 	struct reftable_writer *writer;
 	int ret = reftable_writer_new(&writer, &strbuf_writer_write, &strbuf_writer_flush,
 				      buf, opts);
-	check(!ret);
+	cl_assert(!ret);
 	return writer;
 }
 
-void t_reftable_write_to_buf(struct reftable_buf *buf,
+void cl_reftable_write_to_buf(struct reftable_buf *buf,
 			     struct reftable_ref_record *refs,
 			     size_t nrefs,
 			     struct reftable_log_record *logs,
@@ -64,35 +66,36 @@ void t_reftable_write_to_buf(struct reftable_buf *buf,
 			min = ui;
 	}
 
-	writer = t_reftable_strbuf_writer(buf, &opts);
-	reftable_writer_set_limits(writer, min, max);
+	writer = cl_reftable_strbuf_writer(buf, &opts);
+	ret = reftable_writer_set_limits(writer, min, max);
+	cl_assert(!ret);
 
 	if (nrefs) {
 		ret = reftable_writer_add_refs(writer, refs, nrefs);
-		check_int(ret, ==, 0);
+		cl_assert_equal_i(ret, 0);
 	}
 
 	if (nlogs) {
 		ret = reftable_writer_add_logs(writer, logs, nlogs);
-		check_int(ret, ==, 0);
+		cl_assert_equal_i(ret, 0);
 	}
 
 	ret = reftable_writer_close(writer);
-	check_int(ret, ==, 0);
+	cl_assert_equal_i(ret, 0);
 
 	stats = reftable_writer_stats(writer);
-	for (size_t i = 0; i < stats->ref_stats.blocks; i++) {
+	for (size_t i = 0; i < (size_t)stats->ref_stats.blocks; i++) {
 		size_t off = i * (opts.block_size ? opts.block_size
 						  : DEFAULT_BLOCK_SIZE);
 		if (!off)
 			off = header_size(opts.hash_id == REFTABLE_HASH_SHA256 ? 2 : 1);
-		check_char(buf->buf[off], ==, 'r');
+		cl_assert(buf->buf[off] == 'r');
 	}
 
 	if (nrefs)
-		check_int(stats->ref_stats.blocks, >, 0);
+		cl_assert(stats->ref_stats.blocks > 0);
 	if (nlogs)
-		check_int(stats->log_stats.blocks, >, 0);
+		cl_assert(stats->log_stats.blocks > 0);
 
 	reftable_writer_free(writer);
 }
t/unit-tests/lib-reftable.h +7 -8
index e4c360fa7e..d7e6d3136f 100644
@@ -1,21 +1,20 @@
-#ifndef LIB_REFTABLE_H
-#define LIB_REFTABLE_H
-
+#include "git-compat-util.h"
+#include "clar/clar.h"
+#include "clar-decls.h"
 #include "git-compat-util.h"
 #include "reftable/reftable-writer.h"
+#include "strbuf.h"
 
 struct reftable_buf;
 
-void t_reftable_set_hash(uint8_t *p, int i, enum reftable_hash id);
+void cl_reftable_set_hash(uint8_t *p, int i, enum reftable_hash id);
 
-struct reftable_writer *t_reftable_strbuf_writer(struct reftable_buf *buf,
+struct reftable_writer *cl_reftable_strbuf_writer(struct reftable_buf *buf,
 						 struct reftable_write_options *opts);
 
-void t_reftable_write_to_buf(struct reftable_buf *buf,
+void cl_reftable_write_to_buf(struct reftable_buf *buf,
 			     struct reftable_ref_record *refs,
 			     size_t nrecords,
 			     struct reftable_log_record *logs,
 			     size_t nlogs,
 			     struct reftable_write_options *opts);
-
-#endif
t/unit-tests/u-reftable-basics.c +1 -1
index f105c22d15..a0471083e7 100644
@@ -7,7 +7,7 @@ license that can be found in the LICENSE file or at
 */
 
 #include "unit-test.h"
-#include "lib-reftable-clar.h"
+#include "lib-reftable.h"
 #include "reftable/basics.h"
 
 struct integer_needle_lesseq_args {
t/unit-tests/u-reftable-block.c +1 -1
index 5d1419b801..bb0603464c 100644
@@ -7,7 +7,7 @@ license that can be found in the LICENSE file or at
 */
 
 #include "unit-test.h"
-#include "lib-reftable-clar.h"
+#include "lib-reftable.h"
 #include "reftable/block.h"
 #include "reftable/blocksource.h"
 #include "reftable/constants.h"
t/unit-tests/u-reftable-merged.c +1 -1
index e5b9dda4f4..656de01d6e 100644
@@ -7,7 +7,7 @@ license that can be found in the LICENSE file or at
 */
 
 #include "unit-test.h"
-#include "lib-reftable-clar.h"
+#include "lib-reftable.h"
 #include "reftable/blocksource.h"
 #include "reftable/constants.h"
 #include "reftable/merged.h"
t/unit-tests/u-reftable-pq.c +1 -1
index b3d64f55de..5526c55739 100644
@@ -7,7 +7,7 @@ license that can be found in the LICENSE file or at
 */
 
 #include "unit-test.h"
-#include "lib-reftable-clar.h"
+#include "lib-reftable.h"
 #include "reftable/constants.h"
 #include "reftable/pq.h"
 #include "strbuf.h"
t/unit-tests/u-reftable-readwrite.c +1 -1
index f1c6a04429..d72b049a18 100644
@@ -9,7 +9,7 @@ license that can be found in the LICENSE file or at
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "unit-test.h"
-#include "lib-reftable-clar.h"
+#include "lib-reftable.h"
 #include "reftable/basics.h"
 #include "reftable/blocksource.h"
 #include "reftable/reftable-error.h"
t/unit-tests/u-reftable-record.c +1 -1
index 137a7ab815..e00e6e1881 100644
@@ -7,7 +7,7 @@
 */
 
 #include "unit-test.h"
-#include "lib-reftable-clar.h"
+#include "lib-reftable.h"
 #include "reftable/basics.h"
 #include "reftable/constants.h"
 #include "reftable/record.h"
t/unit-tests/u-reftable-stack.c +2 -2
index 8d6cfba22c..60ceecbc72 100644
@@ -10,7 +10,7 @@ license that can be found in the LICENSE file or at
 
 #include "unit-test.h"
 #include "dir.h"
-#include "lib-reftable-clar.h"
+#include "lib-reftable.h"
 #include "reftable/merged.h"
 #include "reftable/reftable-error.h"
 #include "reftable/stack.h"
@@ -480,7 +480,7 @@ void test_reftable_stack__add(void)
 	struct reftable_buf path = REFTABLE_BUF_INIT;
 	struct stat stat_result;
 	size_t i, N = ARRAY_SIZE(refs);
-	int err;
+	int err = 0;
 
 	err = reftable_new_stack(&st, dir, &opts);
 	cl_assert(!err);
t/unit-tests/u-reftable-table.c +1 -1
index 25ea672e6a..5a00b4826e 100644
@@ -1,5 +1,5 @@
 #include "test-lib.h"
-#include "lib-reftable-clar.h"
+#include "lib-reftable.h"
 #include "reftable/blocksource.h"
 #include "reftable/constants.h"
 #include "reftable/iter.h"
Signature · 1 line
2.43.0
#19 lore raw

Re: [PATCH v3 10/10] t/unit-tests: finalize migration of reftable-related tests

Quoted 6 lines · Seyi Kuforiji
Makefile +0 -0
index 8ed8f234f4..8d8f2d574d 100644
@@ -1380,13 +1380,11 @@ CLAR_TEST_SUITES += u-urlmatch-normalization
 CLAR_TEST_PROG = $(UNIT_TEST_BIN)/unit-tests$(X)

Makefile CLAR_TEST_SUITES += u-urlmatch-normalization · line 1387

Quoted 10 lines
Makefile +2 -3
 CLAR_TEST_OBJS = $(patsubst %,$(UNIT_TEST_DIR)/%.o,$(CLAR_TEST_SUITES))
 CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/clar/clar.o
-CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
 CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-oid.o
-CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable-clar.o
+CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable.o
+CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
 
-UNIT_TEST_PROGS = $(patsubst %,$(UNIT_TEST_BIN)/%$X,$(UNIT_TEST_PROGRAMS))
 UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/test-lib.o

Can't "test-lib.c" also be deleted now?

Patrick

#20 lore raw

Re: [PATCH v3 10/10] t/unit-tests: finalize migration of reftable-related tests

Quoted 16 lines · Patrick Steinhardt
Quoted 14 lines · Seyi Kuforiji
Makefile +2 -2
index 8ed8f234f4..8d8f2d574d 100644
@@ -1380,13 +1380,11 @@ CLAR_TEST_SUITES += u-urlmatch-normalization
 CLAR_TEST_PROG = $(UNIT_TEST_BIN)/unit-tests$(X)
 CLAR_TEST_OBJS = $(patsubst %,$(UNIT_TEST_DIR)/%.o,$(CLAR_TEST_SUITES))
 CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/clar/clar.o
-CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
 CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-oid.o
-CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable-clar.o
+CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable.o
+CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
 
Quoted 6 lines

Makefile CLAR_TEST_SUITES += u-urlmatch-normalization · line 1387

Quoted 2 lines
Makefile +0 -1
-UNIT_TEST_PROGS = $(patsubst %,$(UNIT_TEST_BIN)/%$X,$(UNIT_TEST_PROGRAMS))
 UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/test-lib.o

Can't "test-lib.c" also be deleted now?

Patrick

I don't think we can just yet, as t/helper/test-example-tap imports the test-lib.h.h header file. Fixing that would be beyond the scope of this patch series, don't you think?

#21 lore raw

Re: [PATCH v3 10/10] t/unit-tests: finalize migration of reftable-related tests

Quoted 22 lines · Seyi Kuforiji
Quoted 21 lines · Patrick Steinhardt
Quoted 6 lines · Seyi Kuforiji
Makefile +0 -0
index 8ed8f234f4..8d8f2d574d 100644
@@ -1380,13 +1380,11 @@ CLAR_TEST_SUITES += u-urlmatch-normalization
 CLAR_TEST_PROG = $(UNIT_TEST_BIN)/unit-tests$(X)

Makefile CLAR_TEST_SUITES += u-urlmatch-normalization · line 1387

Quoted 10 lines
Makefile +2 -3
 CLAR_TEST_OBJS = $(patsubst %,$(UNIT_TEST_DIR)/%.o,$(CLAR_TEST_SUITES))
 CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/clar/clar.o
-CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
 CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-oid.o
-CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable-clar.o
+CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable.o
+CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
 
-UNIT_TEST_PROGS = $(patsubst %,$(UNIT_TEST_BIN)/%$X,$(UNIT_TEST_PROGRAMS))
 UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/test-lib.o

Can't "test-lib.c" also be deleted now?

Quoted 5 lines
Quoted 1 line

Patrick

I don't think we can just yet, as t/helper/test-example-tap imports the test-lib.h.h header file. Fixing that would be beyond the scope of this patch series, don't you think?

Yup, agreed. It may be useful to point out this detail in the commit message.

Patrick

#22 lore raw

Re: [PATCH v3 10/10] t/unit-tests: finalize migration of reftable-related tests

Quoted 6 lines · Patrick Steinhardt
Quoted 3 lines

I don't think we can just yet, as t/helper/test-example-tap imports the test-lib.h.h header file. Fixing that would be beyond the scope of this patch series, don't you think?

Yup, agreed. It may be useful to point out this detail in the commit message.

Excellent suggestion.
Thanks.

#23 lore raw
In reply to Seyi Kuforiji
Quoted 9 lines · Seyi Kuforiji

This small patch series marks the final batch of our existing unit test files transitioned to the Clar testing framework. It covers all the reftable-related test files, and is part of our ongoing effort to standardize our testing framework to enhance its maintainability.

Changes in v3:
- some code refactoring based on review, which includes initial creation of reftable helper functions to t/unit-tests/lib-reftable-clar-test.{c,h} files in the initial commit

I guess this is no longer a "small patch series" ;-)

Are we done iterating, or will there be a small and final finishing touch interation?

No need to rush, as we won't be merging things down to 'master' until the 2.50 final gets tagged, but preparing a reasonably well cooked topic in 'next' for the next cycle is always a good idea.

Thanks.

#24 lore raw

Hi Junio,

I'll make a v4 patch to clean up and finalize the series :)

Thanks
Seyi

Quoted 23 lines · Junio C Hamano
Quoted 9 lines · Seyi Kuforiji

This small patch series marks the final batch of our existing unit test files transitioned to the Clar testing framework. It covers all the reftable-related test files, and is part of our ongoing effort to standardize our testing framework to enhance its maintainability.

Changes in v3:
- some code refactoring based on review, which includes initial creation of reftable helper functions to t/unit-tests/lib-reftable-clar-test.{c,h} files in the initial commit

I guess this is no longer a "small patch series" ;-)

Are we done iterating, or will there be a small and final finishing touch interation?

No need to rush, as we won't be merging things down to 'master' until the 2.50 final gets tagged, but preparing a reasonably well cooked topic in 'next' for the next cycle is always a good idea.

Thanks.

#25 lore raw
In reply to Junio C Hamano
Quoted 15 lines · Junio C Hamano
Quoted 9 lines · Seyi Kuforiji

This small patch series marks the final batch of our existing unit test files transitioned to the Clar testing framework. It covers all the reftable-related test files, and is part of our ongoing effort to standardize our testing framework to enhance its maintainability.

Changes in v3:
- some code refactoring based on review, which includes initial creation of reftable helper functions to t/unit-tests/lib-reftable-clar-test.{c,h} files in the initial commit

I guess this is no longer a "small patch series" ;-)

Quoted 8 lines

Are we done iterating, or will there be a small and final finishing touch interation?

No need to rush, as we won't be merging things down to 'master' until the 2.50 final gets tagged, but preparing a reasonably well cooked topic in 'next' for the next cycle is always a good idea.

Thanks.

Hi Junio,

I'll make a v4 patch to clean up and finalize the series :)

Thanks
Seyi