Skip to contentSkip to conversation

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

PATCH Superseded Seyi Kuforiji 3 participants 33 messages Jun 5, 2025 – Jul 24, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

Hello,

This 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 v4:
- some code refactoring and cleanup based on review.

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                                      |  20 +-
 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} | 403 ++++-----
 ...-reftable-record.c => u-reftable-record.c} | 250 +++---
 ...{t-reftable-stack.c => u-reftable-stack.c} | 780 ++++++++----------
 ...{t-reftable-table.c => u-reftable-table.c} |  73 +-
 14 files changed, 1117 insertions(+), 1331 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} (68%)
 rename t/unit-tests/{t-reftable-record.c => u-reftable-record.c} (62%)
 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} (75%)

Range-diff against v3:

 1:  53a64f5551 =  1:  53a64f5551 t/unit-tests: implement clar specific reftable test helper functions
 2:  fec29d94d8 =  2:  fec29d94d8 t/unit-tests: convert reftable basics test to use clar test framework
 3:  57d7541caa !  3:  e717e4529d t/unit-tests: convert reftable block test to use clar
    @@ t/unit-tests/u-reftable-block.c: license that can be found in the LICENSE file o
      #include "strbuf.h"
      
     -static void t_ref_block_read_write(void)
    -+void test_reftable_block__index_read_write(void)
    ++void test_reftable_block__read_write(void)
      {
      	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)
     +				(uint8_t *) block_data.buf, block_size,
      				header_off, hash_size(REFTABLE_HASH_SHA1));
     -	check(!ret);
    -+	cl_assert(ret == 0);
    ++	cl_assert(!ret);
      
      	rec.u.ref.refname = (char *) "";
      	rec.u.ref.value_type = REFTABLE_REF_DELETION;
    @@ t/unit-tests/u-reftable-block.c: static void t_log_block_read_write(void)
      	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);
    ++	cl_assert(!ret);
      
      	for (i = 0; i < N; i++) {
      		rec.u.log.refname = xstrfmt("branch%02"PRIuMAX , (uintmax_t)i);
    @@ t/unit-tests/u-reftable-block.c: static void t_obj_block_read_write(void)
      	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);
    ++	cl_assert(!ret);
      
      	for (i = 0; i < N; i++) {
      		uint8_t bytes[] = { i, i + 1, i + 2, i + 3, i + 5 }, *allocated;
    @@ t/unit-tests/u-reftable-block.c: static void t_index_block_read_write(void)
      	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);
    ++	cl_assert(!ret);
      
      	for (i = 0; i < N; i++) {
      		char buf[128];
 4:  db11c0eb30 !  4:  dc176ad6d9 t/unit-tests: convert reftable merged test to use clar
    @@ t/unit-tests/u-reftable-merged.c: static void t_merged_single_record(void)
     +	cl_assert(!err);
      	err = reftable_iterator_seek_ref(&it, "a");
     -	check(!err);
    -+	cl_assert(err == 0);
    ++	cl_assert(!err);
      
      	err = reftable_iterator_next_ref(&it, &ref);
     -	check(!err);
     -	check(reftable_ref_record_equal(&r2[0], &ref, REFTABLE_HASH_SIZE_SHA1));
    -+	cl_assert(err == 0);
    ++	cl_assert(!err);
     +	cl_assert(reftable_ref_record_equal(&r2[0], &ref,
     +					    REFTABLE_HASH_SIZE_SHA1) != 0);
      	reftable_ref_record_release(&ref);
    @@ t/unit-tests/u-reftable-merged.c: static void t_merged_seek_multiple_times(void)
      	for (size_t i = 0; i < 5; i++) {
      		int err = reftable_iterator_seek_ref(&it, "c");
     -		check(!err);
    -+		cl_assert(err == 0);
    ++		cl_assert(!err);
      
     -		err = reftable_iterator_next_ref(&it, &rec);
     -		check(!err);
    @@ t/unit-tests/u-reftable-merged.c: static void t_default_write_opts(void)
      
     -	err = reftable_writer_add_ref(w, &rec);
     -	check(!err);
    -+	cl_assert(reftable_writer_add_ref(w, &rec) == 0);
    ++	cl_assert_equal_i(reftable_writer_add_ref(w, &rec), 0);
      
     -	err = reftable_writer_close(w);
     -	check(!err);
    -+	cl_assert(reftable_writer_close(w) == 0);
    ++	cl_assert_equal_i(reftable_writer_close(w), 0);
      	reftable_writer_free(w);
      
      	block_source_from_buf(&source, &buf);
 5:  60cf81862a !  5:  1694375fab t/unit-tests: convert reftable pq test to use clar
    @@ t/unit-tests/u-reftable-pq.c: static void merged_iter_pqueue_check(const struct
      {
      	int cmp;
     -	check(!reftable_record_cmp(a->rec, b->rec, &cmp));
    -+	cl_assert(reftable_record_cmp(a->rec, b->rec, &cmp) == 0);
    ++	cl_assert_equal_i(reftable_record_cmp(a->rec, b->rec, &cmp), 0);
      	return !cmp && (a->index == b->index);
      }
      
    @@ t/unit-tests/u-reftable-pq.c: static void t_pq_record(void)
      		struct pq_entry e;
      
     -		check(!merged_iter_pqueue_remove(&pq, &e));
    -+		cl_assert(merged_iter_pqueue_remove(&pq, &e) == 0);
    ++		cl_assert_equal_i(merged_iter_pqueue_remove(&pq, &e), 0);
      		merged_iter_pqueue_check(&pq);
      
     -		check(pq_entry_equal(&top, &e));
    @@ t/unit-tests/u-reftable-pq.c: static void t_pq_index(void)
      		struct pq_entry e;
      
     -		check(!merged_iter_pqueue_remove(&pq, &e));
    -+		cl_assert(merged_iter_pqueue_remove(&pq, &e) == 0);
    ++		cl_assert_equal_i(merged_iter_pqueue_remove(&pq, &e), 0);
      		merged_iter_pqueue_check(&pq);
      
     -		check(pq_entry_equal(&top, &e));
    @@ t/unit-tests/u-reftable-pq.c: static void t_merged_iter_pqueue_top(void)
      		struct pq_entry e;
      
     -		check(!merged_iter_pqueue_remove(&pq, &e));
    -+		cl_assert(merged_iter_pqueue_remove(&pq, &e) == 0);
    ++		cl_assert_equal_i(merged_iter_pqueue_remove(&pq, &e), 0);
      
      		merged_iter_pqueue_check(&pq);
     -		check(pq_entry_equal(&top, &e));
 6:  0eec9f7601 !  6:  9842215a17 t/unit-tests: convert reftable table test to use clar
    @@ t/meson.build: if perl.found() and time.found()
     
      ## t/unit-tests/t-reftable-table.c => t/unit-tests/u-reftable-table.c ##
     @@
    - #include "test-lib.h"
    +-#include "test-lib.h"
     -#include "lib-reftable.h"
    ++#include "unit-test.h"
     +#include "lib-reftable-clar.h"
      #include "reftable/blocksource.h"
      #include "reftable/constants.h"
 7:  36bdd9b003 !  7:  acc72b57b2 t/unit-tests: convert reftable readwrite test to use clar
    @@ t/unit-tests/u-reftable-readwrite.c: license that can be found in the LICENSE fi
      	int n;
      	uint8_t in[] = "hello";
     -	check(!reftable_buf_add(&buf, in, sizeof(in)));
    -+	cl_assert(reftable_buf_add(&buf, in, sizeof(in)) == 0);
    ++	cl_assert_equal_i(reftable_buf_add(&buf, in, sizeof(in)), 0);
      	block_source_from_buf(&source, &buf);
     -	check_int(block_source_size(&source), ==, 6);
     +	cl_assert_equal_i(block_source_size(&source), 6);
    @@ t/unit-tests/u-reftable-readwrite.c: static void write_table(char ***names, stru
      		refs[i].update_index = update_index;
      		refs[i].value_type = REFTABLE_REF_VAL1;
     -		t_reftable_set_hash(refs[i].value.val1, i, REFTABLE_HASH_SHA1);
    -+		cl_reftable_set_hash(refs[i].value.val1, i, REFTABLE_HASH_SHA1);
    ++		cl_reftable_set_hash(refs[i].value.val1, i,
    ++				     REFTABLE_HASH_SHA1);
      	}
      
      	for (i = 0; i < N; i++) {
    @@ t/unit-tests/u-reftable-readwrite.c: static void write_table(char ***names, stru
      		logs[i].update_index = update_index;
      		logs[i].value_type = REFTABLE_LOG_UPDATE;
     -		t_reftable_set_hash(logs[i].value.update.new_hash, i,
    +-				    REFTABLE_HASH_SHA1);
     +		cl_reftable_set_hash(logs[i].value.update.new_hash, i,
    - 				    REFTABLE_HASH_SHA1);
    ++				     REFTABLE_HASH_SHA1);
      		logs[i].value.update.message = (char *) "message";
      	}
      
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_log_buffer_size(void)
      					   .message = (char *) "commit: 9\n",
      				   } } };
     -	struct reftable_writer *w = t_reftable_strbuf_writer(&buf, &opts);
    -+	struct reftable_writer *w = cl_reftable_strbuf_writer(&buf, &opts);
    ++	struct reftable_writer *w = cl_reftable_strbuf_writer(&buf,
    ++							      &opts);
      
      	/* This tests buffer extension for log compression. Must use a random
      	   hash, to ensure that the compressed part is larger than the original.
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_log_buffer_size(void)
     -	check(!err);
     -	err = reftable_writer_close(w);
     -	check(!err);
    -+	cl_assert(reftable_writer_add_log(w, &log) == 0);
    -+	cl_assert(reftable_writer_close(w) == 0);
    ++	cl_assert_equal_i(reftable_writer_add_log(w, &log), 0);
    ++	cl_assert_equal_i(reftable_writer_close(w), 0);
      	reftable_writer_free(w);
      	reftable_buf_release(&buf);
      }
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_log_overflow(void)
      		},
      	};
     -	struct reftable_writer *w = t_reftable_strbuf_writer(&buf, &opts);
    -+	struct reftable_writer *w = cl_reftable_strbuf_writer(&buf, &opts);
    ++	struct reftable_writer *w = cl_reftable_strbuf_writer(&buf,
    ++							      &opts);
      
      	memset(msg, 'x', sizeof(msg) - 1);
      	reftable_writer_set_limits(w, update_index, update_index);
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_log_overflow(void)
      	struct reftable_write_options opts = { 0 };
      	struct reftable_buf buf = REFTABLE_BUF_INIT;
     -	struct reftable_writer *w = t_reftable_strbuf_writer(&buf, &opts);
    -+	struct reftable_writer *w = cl_reftable_strbuf_writer(&buf, &opts);
    ++	struct reftable_writer *w = cl_reftable_strbuf_writer(&buf,
    ++							      &opts);
      	struct reftable_log_record log = {
      		.refname = (char *)"refs/head/master",
      		.update_index = 0,
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_log_write_read(void)
      
     -		err = reftable_writer_add_ref(w, &ref);
     -		check(!err);
    -+		cl_assert(reftable_writer_add_ref(w, &ref) == 0);
    ++		cl_assert_equal_i(reftable_writer_add_ref(w, &ref), 0);
      	}
      
      	for (i = 0; i < N; i++) {
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_log_write_read(void)
      		log.update_index = i;
      		log.value_type = REFTABLE_LOG_UPDATE;
     -		t_reftable_set_hash(log.value.update.old_hash, i,
    -+		cl_reftable_set_hash(log.value.update.old_hash, i,
    - 				    REFTABLE_HASH_SHA1);
    +-				    REFTABLE_HASH_SHA1);
     -		t_reftable_set_hash(log.value.update.new_hash, i + 1,
    +-				    REFTABLE_HASH_SHA1);
    ++		cl_reftable_set_hash(log.value.update.old_hash, i,
    ++				     REFTABLE_HASH_SHA1);
     +		cl_reftable_set_hash(log.value.update.new_hash, i + 1,
    - 				    REFTABLE_HASH_SHA1);
    ++				     REFTABLE_HASH_SHA1);
      
     -		err = reftable_writer_add_log(w, &log);
     -		check(!err);
    -+		cl_assert(reftable_writer_add_log(w, &log) == 0);
    ++		cl_assert_equal_i(reftable_writer_add_log(w, &log), 0);
      	}
      
     -	n = reftable_writer_close(w);
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_log_write_read(void)
     -		check(!err);
     -		check_str(names[i], log.refname);
     -		check_int(i, ==, log.update_index);
    -+		cl_assert(err == 0);
    ++		cl_assert(!err);
     +		cl_assert_equal_s(names[i], log.refname);
     +		cl_assert_equal_i(i, log.update_index);
      		reftable_log_record_release(&log);
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_log_zlib_corruption(void)
      	struct reftable_block_source source = { 0 };
      	struct reftable_buf buf = REFTABLE_BUF_INIT;
     -	struct reftable_writer *w = t_reftable_strbuf_writer(&buf, &opts);
    -+	struct reftable_writer *w = cl_reftable_strbuf_writer(&buf, &opts);
    ++	struct reftable_writer *w = cl_reftable_strbuf_writer(&buf,
    ++							      &opts);
      	const struct reftable_stats *stats = NULL;
      	char message[100] = { 0 };
     -	int err, i, n;
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_log_zlib_corruption(void)
     -
     -	n = reftable_writer_close(w);
     -	check_int(n, ==, 0);
    -+	cl_assert(reftable_writer_add_log(w, &log) == 0);
    ++	cl_assert_equal_i(reftable_writer_add_log(w, &log), 0);
     +	cl_assert_equal_i(reftable_writer_close(w), 0);
      
      	stats = reftable_writer_stats(w);
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_table_read_write_seek(int ind
      
     -	check(!reftable_buf_addstr(&pastLast, names[N - 1]));
     -	check(!reftable_buf_addstr(&pastLast, "/"));
    -+	cl_assert(reftable_buf_addstr(&pastLast, names[N - 1]) == 0);
    -+	cl_assert(reftable_buf_addstr(&pastLast, "/") == 0);
    ++	cl_assert_equal_i(reftable_buf_addstr(&pastLast, names[N - 1]),
    ++					      0);
    ++	cl_assert_equal_i(reftable_buf_addstr(&pastLast, "/"), 0);
      
      	err = reftable_table_init_ref_iterator(table, &it);
     -	check(!err);
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_table_refs_for(int indexed)
      	struct reftable_block_source source = { 0 };
      	struct reftable_buf buf = REFTABLE_BUF_INIT;
     -	struct reftable_writer *w = t_reftable_strbuf_writer(&buf, &opts);
    -+	struct reftable_writer *w = cl_reftable_strbuf_writer(&buf, &opts);
    ++	struct reftable_writer *w = cl_reftable_strbuf_writer(&buf,
    ++							      &opts);
      	struct reftable_iterator it = { 0 };
     -	int N = 50, n, j, err, i;
     +	int N = 50, j, i;
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_table_refs_for(int indexed)
      
      		ref.value_type = REFTABLE_REF_VAL2;
     -		t_reftable_set_hash(ref.value.val2.value, i / 4,
    -+		cl_reftable_set_hash(ref.value.val2.value, i / 4,
    - 				    REFTABLE_HASH_SHA1);
    +-				    REFTABLE_HASH_SHA1);
     -		t_reftable_set_hash(ref.value.val2.target_value, 3 + i / 4,
    -+		cl_reftable_set_hash(ref.value.val2.target_value, 3 + i / 4,
    - 				    REFTABLE_HASH_SHA1);
    +-				    REFTABLE_HASH_SHA1);
    ++		cl_reftable_set_hash(ref.value.val2.value, i / 4,
    ++				     REFTABLE_HASH_SHA1);
    ++		cl_reftable_set_hash(ref.value.val2.target_value,
    ++				     3 + i / 4, REFTABLE_HASH_SHA1);
      
      		/* 80 bytes / entry, so 3 entries per block. Yields 17
      		 */
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_write_object_id_min_length(vo
      		ref.refname = name;
     -		err = reftable_writer_add_ref(w, &ref);
     -		check(!err);
    -+		cl_assert(reftable_writer_add_ref(w, &ref) == 0);
    ++		cl_assert_equal_i(reftable_writer_add_ref(w, &ref), 0);
      	}
      
     -	err = reftable_writer_close(w);
     -	check(!err);
     -	check_int(reftable_writer_stats(w)->object_id_len, ==, 2);
    -+	cl_assert(reftable_writer_close(w) == 0);
    ++	cl_assert_equal_i(reftable_writer_close(w), 0);
     +	cl_assert_equal_i(reftable_writer_stats(w)->object_id_len, 2);
      	reftable_writer_free(w);
      	reftable_buf_release(&buf);
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_write_object_id_length(void)
     -	err = reftable_writer_close(w);
     -	check(!err);
     -	check_int(reftable_writer_stats(w)->object_id_len, ==, 16);
    -+	cl_assert(reftable_writer_close(w) == 0);
    ++	cl_assert_equal_i(reftable_writer_close(w), 0);
     +	cl_assert_equal_i(reftable_writer_stats(w)->object_id_len, 16);
      	reftable_writer_free(w);
      	reftable_buf_release(&buf);
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_write_object_id_length(void)
     -	err = reftable_writer_close(w);
     -	check_int(err, ==, REFTABLE_EMPTY_TABLE_ERROR);
     +	cl_assert_equal_i(reftable_writer_add_ref(w, &ref), REFTABLE_API_ERROR);
    -+	cl_assert_equal_i(reftable_writer_close(w), REFTABLE_EMPTY_TABLE_ERROR);
    ++	cl_assert_equal_i(reftable_writer_close(w),
    ++			  REFTABLE_EMPTY_TABLE_ERROR);
      	reftable_writer_free(w);
      	reftable_buf_release(&buf);
      }
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_write_key_order(void)
     -	check(!err);
     -	err = reftable_writer_add_ref(w, &refs[1]);
     -	check_int(err, ==, REFTABLE_API_ERROR);
    -+	cl_assert(reftable_writer_add_ref(w, &refs[0]) == 0);
    -+	cl_assert_equal_i(reftable_writer_add_ref(w, &refs[1]), REFTABLE_API_ERROR);
    ++	cl_assert_equal_i(reftable_writer_add_ref(w, &refs[0]), 0);
    ++	cl_assert_equal_i(reftable_writer_add_ref(w, &refs[1]),
    ++			  REFTABLE_API_ERROR);
      
      	refs[0].update_index = 2;
     -	err = reftable_writer_add_ref(w, &refs[0]);
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_write_multiple_indices(void)
      
     -		err = reftable_writer_add_ref(writer, &ref);
     -		check(!err);
    -+		cl_assert(reftable_writer_add_ref(writer, &ref) == 0);
    ++		cl_assert_equal_i(reftable_writer_add_ref(writer, &ref), 0);
      	}
      
      	for (i = 0; i < 100; i++) {
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_write_multiple_indices(void)
      
     -		err = reftable_writer_add_log(writer, &log);
     -		check(!err);
    -+		cl_assert(reftable_writer_add_log(writer, &log) == 0);
    ++		cl_assert_equal_i(reftable_writer_add_log(writer, &log), 0);
      	}
      
      	reftable_writer_close(writer);
    @@ t/unit-tests/u-reftable-readwrite.c: static void t_write_multi_level_index(void)
      
     -		err = reftable_writer_add_ref(writer, &ref);
     -		check(!err);
    -+		cl_assert(reftable_writer_add_ref(writer, &ref) == 0);
    ++		cl_assert_equal_i(reftable_writer_add_ref(writer, &ref), 0);
      	}
      	reftable_writer_close(writer);

8: df744c1458 ! 8: 7b54300fac t/unit-tests: convert reftable record test to use clar

    @@ t/unit-tests/u-reftable-record.c: static void t_copy(struct reftable_record *rec
      
      	typ = reftable_record_type(rec);
     -	check(!reftable_record_init(&copy, typ));
    -+	cl_assert(reftable_record_init(&copy, typ) == 0);
    ++	cl_assert_equal_i(reftable_record_init(&copy, typ), 0);
      	reftable_record_copy_from(&copy, rec, REFTABLE_HASH_SIZE_SHA1);
      	/* do it twice to catch memory leaks */
      	reftable_record_copy_from(&copy, rec, REFTABLE_HASH_SIZE_SHA1);
     -	check(reftable_record_equal(rec, &copy, REFTABLE_HASH_SIZE_SHA1));
    -+	cl_assert(reftable_record_equal(rec, &copy, REFTABLE_HASH_SIZE_SHA1) != 0);
    ++	cl_assert(reftable_record_equal(rec, &copy,
    ++					REFTABLE_HASH_SIZE_SHA1) != 0);
      
      	reftable_record_release(&copy);
      }
    @@ t/unit-tests/u-reftable-record.c: static void t_reftable_ref_record_comparison(v
     -	check(!reftable_record_cmp(&in[0], &in[1], &cmp));
     -	check(!cmp);
     +	cl_assert(reftable_record_equal(&in[0], &in[1], REFTABLE_HASH_SIZE_SHA1) == 0);
    -+	cl_assert(reftable_record_cmp(&in[0], &in[1], &cmp) == 0);
    -+	cl_assert(cmp == 0);
    ++	cl_assert_equal_i(reftable_record_cmp(&in[0], &in[1], &cmp), 0);
    ++	cl_assert(!cmp);
      
     -	check(!reftable_record_equal(&in[1], &in[2], REFTABLE_HASH_SIZE_SHA1));
     -	check(!reftable_record_cmp(&in[1], &in[2], &cmp));
     -	check_int(cmp, >, 0);
    -+	cl_assert(reftable_record_equal(&in[1], &in[2], REFTABLE_HASH_SIZE_SHA1) == 0);
    -+	cl_assert(reftable_record_cmp(&in[1], &in[2], &cmp) == 0);
    ++	cl_assert(reftable_record_equal(&in[1], &in[2],
    ++					REFTABLE_HASH_SIZE_SHA1) == 0);
    ++	cl_assert_equal_i(reftable_record_cmp(&in[1], &in[2], &cmp), 0);
     +	cl_assert(cmp > 0);
      
      	in[1].u.ref.value_type = in[0].u.ref.value_type;
     -	check(reftable_record_equal(&in[0], &in[1], REFTABLE_HASH_SIZE_SHA1));
     -	check(!reftable_record_cmp(&in[0], &in[1], &cmp));
     -	check(!cmp);
    -+	cl_assert(reftable_record_equal(&in[0], &in[1], REFTABLE_HASH_SIZE_SHA1) != 0);
    -+	cl_assert(reftable_record_cmp(&in[0], &in[1], &cmp) == 0);
    -+	cl_assert(cmp == 0);
    ++	cl_assert(reftable_record_equal(&in[0], &in[1],
    ++					REFTABLE_HASH_SIZE_SHA1) != 0);
    ++	cl_assert_equal_i(reftable_record_cmp(&in[0], &in[1], &cmp), 0);
    ++	cl_assert(!cmp);
      }
      
     -static void t_reftable_ref_record_compare_name(void)
    @@ t/unit-tests/u-reftable-record.c: static void t_reftable_ref_record_compare_name
     -	check_int(reftable_ref_record_compare_name(&recs[0], &recs[1]), <, 0);
     -	check_int(reftable_ref_record_compare_name(&recs[1], &recs[0]), >, 0);
     -	check_int(reftable_ref_record_compare_name(&recs[0], &recs[2]), ==, 0);
    -+	cl_assert(reftable_ref_record_compare_name(&recs[0], &recs[1]) < 0);
    -+	cl_assert(reftable_ref_record_compare_name(&recs[1], &recs[0]) > 0);
    -+	cl_assert_equal_i(reftable_ref_record_compare_name(&recs[0], &recs[2]), 0);
    ++	cl_assert(reftable_ref_record_compare_name(&recs[0],
    ++						   &recs[1]) < 0);
    ++	cl_assert(reftable_ref_record_compare_name(&recs[1],
    ++						   &recs[0]) > 0);
    ++	cl_assert_equal_i(reftable_ref_record_compare_name(&recs[0],
    ++							   &recs[2]), 0);
      }
      
     -static void t_reftable_ref_record_roundtrip(void)
    @@ t/unit-tests/u-reftable-record.c: static void t_reftable_ref_record_roundtrip(vo
     -		check_int(reftable_record_val_type(&in), ==, i);
     -		check_int(reftable_record_is_deletion(&in), ==, i == REFTABLE_REF_DELETION);
     +		cl_assert_equal_i(reftable_record_val_type(&in), i);
    -+		cl_assert_equal_i(reftable_record_is_deletion(&in),  i == REFTABLE_REF_DELETION);
    ++		cl_assert_equal_i(reftable_record_is_deletion(&in),
    ++				  i == REFTABLE_REF_DELETION);
      
      		reftable_record_key(&in, &key);
      		n = reftable_record_encode(&in, dest, REFTABLE_HASH_SIZE_SHA1);
    @@ t/unit-tests/u-reftable-record.c: static void t_reftable_ref_record_roundtrip(vo
      
     -		check(reftable_ref_record_equal(&in.u.ref, &out.u.ref,
     -						 REFTABLE_HASH_SIZE_SHA1));
    -+		cl_assert(reftable_ref_record_equal(&in.u.ref, &out.u.ref,
    -+											REFTABLE_HASH_SIZE_SHA1) != 0);
    ++		cl_assert(reftable_ref_record_equal(&in.u.ref,
    ++						    &out.u.ref,
    ++						    REFTABLE_HASH_SIZE_SHA1) != 0);
      		reftable_record_release(&in);
      
      		reftable_buf_release(&key);
    @@ t/unit-tests/u-reftable-record.c: static void t_reftable_log_record_comparison(v
     -	check(!reftable_record_equal(&in[1], &in[2], REFTABLE_HASH_SIZE_SHA1));
     -	check(!reftable_record_cmp(&in[1], &in[2], &cmp));
     -	check_int(cmp, >, 0);
    -+	cl_assert(reftable_record_equal(&in[0], &in[1], REFTABLE_HASH_SIZE_SHA1) == 0);
    -+	cl_assert(reftable_record_equal(&in[1], &in[2], REFTABLE_HASH_SIZE_SHA1) == 0);
    -+	cl_assert(reftable_record_cmp(&in[1], &in[2], &cmp) == 0);
    ++	cl_assert_equal_i(reftable_record_equal(&in[0], &in[1],
    ++						REFTABLE_HASH_SIZE_SHA1), 0);
    ++	cl_assert_equal_i(reftable_record_equal(&in[1], &in[2],
    ++						REFTABLE_HASH_SIZE_SHA1), 0);
    ++	cl_assert_equal_i(reftable_record_cmp(&in[1], &in[2], &cmp), 0);
     +	cl_assert(cmp > 0);
      	/* comparison should be reversed for equal keys, because
      	 * comparison is now performed on the basis of update indices */
     -	check(!reftable_record_cmp(&in[0], &in[1], &cmp));
     -	check_int(cmp, <, 0);
    -+	cl_assert(reftable_record_cmp(&in[0], &in[1], &cmp) == 0);
    ++	cl_assert_equal_i(reftable_record_cmp(&in[0], &in[1], &cmp), 0);
     +	cl_assert(cmp < 0);
      
      	in[1].u.log.update_index = in[0].u.log.update_index;
     -	check(reftable_record_equal(&in[0], &in[1], REFTABLE_HASH_SIZE_SHA1));
     -	check(!reftable_record_cmp(&in[0], &in[1], &cmp));
    -+	cl_assert(reftable_record_equal(&in[0], &in[1], REFTABLE_HASH_SIZE_SHA1) != 0);
    -+	cl_assert(reftable_record_cmp(&in[0], &in[1], &cmp) == 0);
    ++	cl_assert(reftable_record_equal(&in[0], &in[1],
    ++					REFTABLE_HASH_SIZE_SHA1) != 0);
    ++	cl_assert_equal_i(reftable_record_cmp(&in[0], &in[1], &cmp), 0);
      }
      
     -static void t_reftable_log_record_compare_key(void)
    @@ t/unit-tests/u-reftable-record.c: static void t_reftable_log_record_compare_key(
      
     -	check_int(reftable_log_record_compare_key(&logs[0], &logs[1]), <, 0);
     -	check_int(reftable_log_record_compare_key(&logs[1], &logs[0]), >, 0);
    -+	cl_assert(reftable_log_record_compare_key(&logs[0], &logs[1]) < 0);
    -+	cl_assert(reftable_log_record_compare_key(&logs[1], &logs[0]) > 0);
    ++	cl_assert(reftable_log_record_compare_key(&logs[0],
    ++						  &logs[1]) < 0);
    ++	cl_assert(reftable_log_record_compare_key(&logs[1],
    ++						  &logs[0]) > 0);
      
      	logs[1].update_index = logs[0].update_index;
     -	check_int(reftable_log_record_compare_key(&logs[0], &logs[1]), <, 0);
    -+	cl_assert(reftable_log_record_compare_key(&logs[0], &logs[1]) < 0);
    ++	cl_assert(reftable_log_record_compare_key(&logs[0],
    ++						  &logs[1]) < 0);
      
     -	check_int(reftable_log_record_compare_key(&logs[0], &logs[2]), >, 0);
     -	check_int(reftable_log_record_compare_key(&logs[2], &logs[0]), <, 0);
    -+	cl_assert(reftable_log_record_compare_key(&logs[0], &logs[2]) > 0);
    -+	cl_assert(reftable_log_record_compare_key(&logs[2], &logs[0]) < 0);
    ++	cl_assert(reftable_log_record_compare_key(&logs[0],
    ++						  &logs[2]) > 0);
    ++	cl_assert(reftable_log_record_compare_key(&logs[2],
    ++						  &logs[0]) < 0);
      	logs[2].update_index = logs[0].update_index;
     -	check_int(reftable_log_record_compare_key(&logs[0], &logs[2]), ==, 0);
     +	cl_assert_equal_i(reftable_log_record_compare_key(&logs[0], &logs[2]), 0);
    @@ t/unit-tests/u-reftable-record.c: static void t_reftable_log_record_roundtrip(vo
     -	check(!reftable_log_record_is_deletion(&in[0]));
     -	check(reftable_log_record_is_deletion(&in[1]));
     -	check(!reftable_log_record_is_deletion(&in[2]));
    -+	cl_assert(reftable_log_record_is_deletion(&in[0]) == 0);
    ++	cl_assert_equal_i(reftable_log_record_is_deletion(&in[0]), 0);
     +	cl_assert(reftable_log_record_is_deletion(&in[1]) != 0);
    -+	cl_assert(reftable_log_record_is_deletion(&in[2]) == 0);
    ++	cl_assert_equal_i(reftable_log_record_is_deletion(&in[2]), 0);
      
      	for (size_t i = 0; i < ARRAY_SIZE(in); i++) {
      		struct reftable_record rec = { .type = REFTABLE_BLOCK_TYPE_LOG };
    @@ t/unit-tests/u-reftable-record.c: static void t_reftable_log_record_roundtrip(vo
     -		check(reftable_log_record_equal(&in[i], &out.u.log,
     -						 REFTABLE_HASH_SIZE_SHA1));
     +		cl_assert(reftable_log_record_equal(&in[i], &out.u.log,
    -+											REFTABLE_HASH_SIZE_SHA1) != 0);
    ++						    REFTABLE_HASH_SIZE_SHA1) != 0);
      		reftable_log_record_release(&in[i]);
      		reftable_buf_release(&key);
      		reftable_record_release(&out);
    @@ t/unit-tests/u-reftable-record.c: static void t_key_roundtrip(void)
      
     -	check(!reftable_buf_addstr(&last_key, "refs/heads/master"));
     -	check(!reftable_buf_addstr(&key, "refs/tags/bla"));
    -+	cl_assert(reftable_buf_addstr(&last_key, "refs/heads/master") == 0);
    -+	cl_assert(reftable_buf_addstr(&key, "refs/tags/bla") == 0);
    ++	cl_assert_equal_i(reftable_buf_addstr(&last_key,
    ++					      "refs/heads/master"), 0);
    ++	cl_assert_equal_i(reftable_buf_addstr(&key,
    ++					      "refs/tags/bla"), 0);
      	extra = 6;
      	n = reftable_encode_key(&restart, dest, last_key, key, extra);
     -	check(!restart);
     -	check_int(n, >, 0);
    -+	cl_assert(restart == 0);
    ++	cl_assert(!restart);
     +	cl_assert(n > 0);
      
     -	check(!reftable_buf_addstr(&roundtrip, "refs/heads/master"));
    -+	cl_assert(reftable_buf_addstr(&roundtrip, "refs/heads/master") == 0);
    ++	cl_assert_equal_i(reftable_buf_addstr(&roundtrip,
    ++					      "refs/heads/master"), 0);
      	m = reftable_decode_key(&roundtrip, &rt_extra, dest);
     -	check_int(n, ==, m);
     -	check(!reftable_buf_cmp(&key, &roundtrip));
     -	check_int(rt_extra, ==, extra);
     +	cl_assert_equal_i(n, m);
    -+	cl_assert(reftable_buf_cmp(&key, &roundtrip) == 0);
    ++	cl_assert_equal_i(reftable_buf_cmp(&key, &roundtrip), 0);
     +	cl_assert_equal_i(rt_extra, extra);
      
      	reftable_buf_release(&last_key);
    @@ t/unit-tests/u-reftable-record.c: static void t_reftable_obj_record_comparison(v
     -	check(!reftable_record_equal(&in[0], &in[1], REFTABLE_HASH_SIZE_SHA1));
     -	check(!reftable_record_cmp(&in[0], &in[1], &cmp));
     -	check(!cmp);
    -+	cl_assert(reftable_record_equal(&in[0], &in[1], REFTABLE_HASH_SIZE_SHA1) == 0);
    -+	cl_assert(reftable_record_cmp(&in[0], &in[1], &cmp) == 0);
    -+	cl_assert(cmp == 0);
    ++	cl_assert_equal_i(reftable_record_equal(&in[0], &in[1],
    ++						REFTABLE_HASH_SIZE_SHA1), 0);
    ++	cl_assert_equal_i(reftable_record_cmp(&in[0], &in[1], &cmp), 0);
    ++	cl_assert(!cmp);
      
     -	check(!reftable_record_equal(&in[1], &in[2], REFTABLE_HASH_SIZE_SHA1));
     -	check(!reftable_record_cmp(&in[1], &in[2], &cmp));
     -	check_int(cmp, >, 0);
    -+	cl_assert(reftable_record_equal(&in[1], &in[2], REFTABLE_HASH_SIZE_SHA1) == 0);
    -+	cl_assert(reftable_record_cmp(&in[1], &in[2], &cmp) == 0);
    ++	cl_assert_equal_i(reftable_record_equal(&in[1], &in[2],
    ++						REFTABLE_HASH_SIZE_SHA1), 0);
    ++	cl_assert_equal_i(reftable_record_cmp(&in[1], &in[2], &cmp), 0);
     +	cl_assert(cmp > 0);
      
      	in[1].u.obj.offset_len = in[0].u.obj.offset_len;
    @@ t/unit-tests/u-reftable-record.c: static void t_reftable_obj_record_comparison(v
     -	check(!reftable_record_cmp(&in[0], &in[1], &cmp));
     -	check(!cmp);
     +	cl_assert(reftable_record_equal(&in[0], &in[1], REFTABLE_HASH_SIZE_SHA1) != 0);
    -+	cl_assert(reftable_record_cmp(&in[0], &in[1], &cmp) == 0);
    -+	cl_assert(cmp == 0);
    ++	cl_assert_equal_i(reftable_record_cmp(&in[0], &in[1], &cmp), 0);
    ++	cl_assert(!cmp);
      }
      
     -static void t_reftable_obj_record_roundtrip(void)
    @@ t/unit-tests/u-reftable-record.c: static void t_reftable_obj_record_roundtrip(vo
      		uint8_t extra;
      
     -		check(!reftable_record_is_deletion(&in));
    -+		cl_assert(reftable_record_is_deletion(&in) == 0);
    ++		cl_assert_equal_i(reftable_record_is_deletion(&in), 0);
      		t_copy(&in);
      		reftable_record_key(&in, &key);
      		n = reftable_record_encode(&in, dest, REFTABLE_HASH_SIZE_SHA1);
    @@ t/unit-tests/u-reftable-record.c: static void t_reftable_obj_record_roundtrip(vo
     +		cl_assert_equal_i(n, m);
      
     -		check(reftable_record_equal(&in, &out, REFTABLE_HASH_SIZE_SHA1));
    -+		cl_assert(reftable_record_equal(&in, &out, REFTABLE_HASH_SIZE_SHA1) != 0);
    ++		cl_assert(reftable_record_equal(&in, &out,
    ++						REFTABLE_HASH_SIZE_SHA1) != 0);
      		reftable_buf_release(&key);
      		reftable_record_release(&out);
      	}
    @@ t/unit-tests/u-reftable-record.c: static void t_reftable_index_record_comparison
     -	check(!reftable_buf_addstr(&in[0].u.idx.last_key, "refs/heads/master"));
     -	check(!reftable_buf_addstr(&in[1].u.idx.last_key, "refs/heads/master"));
     -	check(!reftable_buf_addstr(&in[2].u.idx.last_key, "refs/heads/branch"));
    -+	cl_assert(reftable_buf_addstr(&in[0].u.idx.last_key, "refs/heads/master") == 0);
    -+	cl_assert(reftable_buf_addstr(&in[1].u.idx.last_key, "refs/heads/master") == 0);
    -+	cl_assert(reftable_buf_addstr(&in[2].u.idx.last_key, "refs/heads/branch") == 0);
    ++	cl_assert_equal_i(reftable_buf_addstr(&in[0].u.idx.last_key,
    ++					      "refs/heads/master"), 0);
    ++	cl_assert_equal_i(reftable_buf_addstr(&in[1].u.idx.last_key, "refs/heads/master"), 0);
    ++	cl_assert(reftable_buf_addstr(&in[2].u.idx.last_key,
    ++				      "refs/heads/branch") == 0);
      
     -	check(!reftable_record_equal(&in[0], &in[1], REFTABLE_HASH_SIZE_SHA1));
     -	check(!reftable_record_cmp(&in[0], &in[1], &cmp));
     -	check(!cmp);
    -+	cl_assert(reftable_record_equal(&in[0], &in[1], REFTABLE_HASH_SIZE_SHA1) == 0);
    -+	cl_assert(reftable_record_cmp(&in[0], &in[1], &cmp) == 0);
    -+	cl_assert(cmp == 0);
    ++	cl_assert_equal_i(reftable_record_equal(&in[0], &in[1],
    ++						REFTABLE_HASH_SIZE_SHA1), 0);
    ++	cl_assert_equal_i(reftable_record_cmp(&in[0], &in[1], &cmp), 0);
    ++	cl_assert(!cmp);
      
     -	check(!reftable_record_equal(&in[1], &in[2], REFTABLE_HASH_SIZE_SHA1));
     -	check(!reftable_record_cmp(&in[1], &in[2], &cmp));
     -	check_int(cmp, >, 0);
    -+	cl_assert(reftable_record_equal(&in[1], &in[2], REFTABLE_HASH_SIZE_SHA1) == 0);
    -+	cl_assert(reftable_record_cmp(&in[1], &in[2], &cmp) == 0);
    ++	cl_assert_equal_i(reftable_record_equal(&in[1], &in[2],
    ++						REFTABLE_HASH_SIZE_SHA1), 0);
    ++	cl_assert_equal_i(reftable_record_cmp(&in[1], &in[2], &cmp), 0);
     +	cl_assert(cmp > 0);
      
      	in[1].u.idx.offset = in[0].u.idx.offset;
     -	check(reftable_record_equal(&in[0], &in[1], REFTABLE_HASH_SIZE_SHA1));
     -	check(!reftable_record_cmp(&in[0], &in[1], &cmp));
     -	check(!cmp);
    -+	cl_assert(reftable_record_equal(&in[0], &in[1], REFTABLE_HASH_SIZE_SHA1) != 0);
    -+	cl_assert(reftable_record_cmp(&in[0], &in[1], &cmp) == 0);
    -+	cl_assert(cmp == 0);
    ++	cl_assert(reftable_record_equal(&in[0], &in[1],
    ++					REFTABLE_HASH_SIZE_SHA1) != 0);
    ++	cl_assert_equal_i(reftable_record_cmp(&in[0], &in[1], &cmp), 0);
    ++	cl_assert(!cmp);
      
      	for (size_t i = 0; i < ARRAY_SIZE(in); i++)
      		reftable_record_release(&in[i]);
    @@ t/unit-tests/u-reftable-record.c: static void t_reftable_index_record_roundtrip(
      	uint8_t extra;
      
     -	check(!reftable_buf_addstr(&in.u.idx.last_key, "refs/heads/master"));
    -+	cl_assert(reftable_buf_addstr(&in.u.idx.last_key, "refs/heads/master") == 0);
    ++	cl_assert_equal_i(reftable_buf_addstr(&in.u.idx.last_key,
    ++					      "refs/heads/master"), 0);
      	reftable_record_key(&in, &key);
      	t_copy(&in);
      
     -	check(!reftable_record_is_deletion(&in));
     -	check(!reftable_buf_cmp(&key, &in.u.idx.last_key));
    -+	cl_assert(reftable_record_is_deletion(&in) == 0);
    -+	cl_assert(reftable_buf_cmp(&key, &in.u.idx.last_key) == 0);
    ++	cl_assert_equal_i(reftable_record_is_deletion(&in), 0);
    ++	cl_assert_equal_i(reftable_buf_cmp(&key, &in.u.idx.last_key), 0);
      	n = reftable_record_encode(&in, dest, REFTABLE_HASH_SIZE_SHA1);
     -	check_int(n, >, 0);
     +	cl_assert(n > 0);
      
      	extra = reftable_record_val_type(&in);
    - 	m = reftable_record_decode(&out, key, extra, dest, REFTABLE_HASH_SIZE_SHA1,
    - 				   &scratch);
    +-	m = reftable_record_decode(&out, key, extra, dest, REFTABLE_HASH_SIZE_SHA1,
    +-				   &scratch);
     -	check_int(m, ==, n);
    ++	m = reftable_record_decode(&out, key, extra, dest,
    ++				   REFTABLE_HASH_SIZE_SHA1, &scratch);
     +	cl_assert_equal_i(m, n);
      
     -	check(reftable_record_equal(&in, &out, REFTABLE_HASH_SIZE_SHA1));
    -+	cl_assert(reftable_record_equal(&in, &out, REFTABLE_HASH_SIZE_SHA1) != 0);
    ++	cl_assert(reftable_record_equal(&in, &out,
    ++					REFTABLE_HASH_SIZE_SHA1) != 0);
      
      	reftable_record_release(&out);
      	reftable_buf_release(&key);
 9:  4a247de9e4 !  9:  8250eb25e8 t/unit-tests: convert reftable stack test to use clar
    @@ t/unit-tests/u-reftable-stack.c: static void t_read_file(void)
      
      	err = read_lines(fn, &names);
     -	check(!err);
    -+	cl_assert(err == 0);
    ++	cl_assert(!err);
      
      	for (size_t i = 0; names[i]; i++)
     -		check_str(want[i], names[i]);
    @@ t/unit-tests/u-reftable-stack.c: static void t_read_file(void)
      	struct reftable_ref_record *ref = arg;
     -	check(!reftable_writer_set_limits(wr, ref->update_index,
     -					  ref->update_index));
    -+	cl_assert(reftable_writer_set_limits(wr, ref->update_index,
    -+										 ref->update_index) == 0);
    ++	cl_assert_equal_i(reftable_writer_set_limits(wr,
    ++						     ref->update_index, ref->update_index), 0);
      	return reftable_writer_add_ref(wr, ref);
      }
      
    @@ t/unit-tests/u-reftable-stack.c: static void write_n_ref_tables(struct reftable_
      
     -		err = reftable_stack_add(st, &write_test_ref, &ref);
     -		check(!err);
    -+		cl_assert(reftable_stack_add(st, &write_test_ref, &ref) == 0);
    ++		cl_assert_equal_i(reftable_stack_add(st,
    ++						     &write_test_ref, &ref), 0);
      	}
      
      	st->opts.disable_auto_compact = disable_auto_compact;
    @@ t/unit-tests/u-reftable-stack.c: static int write_test_log(struct reftable_write
      
     -	check(!reftable_writer_set_limits(wr, wla->update_index,
     -					  wla->update_index));
    -+	cl_assert(reftable_writer_set_limits(wr, wla->update_index,
    -+										 wla->update_index) == 0);
    ++	cl_assert_equal_i(reftable_writer_set_limits(wr,
    ++						     wla->update_index,
    ++						     wla->update_index),  0);
      	return reftable_writer_add_log(wr, wla->log);
      }
      
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_add_one(void)
     -	err = stat(scratch.buf, &stat_result);
     -	check(!err);
     -	check_int((stat_result.st_mode & 0777), ==, opts.default_permissions);
    -+	cl_assert(reftable_buf_addstr(&scratch, dir) == 0);
    -+	cl_assert(reftable_buf_addstr(&scratch, "/tables.list") == 0);
    -+	cl_assert(stat(scratch.buf, &stat_result) == 0);
    -+	cl_assert_equal_i((stat_result.st_mode & 0777), opts.default_permissions);
    ++	cl_assert_equal_i(reftable_buf_addstr(&scratch, dir), 0);
    ++	cl_assert_equal_i(reftable_buf_addstr(&scratch,
    ++					      "/tables.list"), 0);
    ++	cl_assert_equal_i(stat(scratch.buf, &stat_result), 0);
    ++	cl_assert_equal_i((stat_result.st_mode & 0777),
    ++			  opts.default_permissions);
      
      	reftable_buf_reset(&scratch);
     -	check(!reftable_buf_addstr(&scratch, dir));
     -	check(!reftable_buf_addstr(&scratch, "/"));
    -+	cl_assert(reftable_buf_addstr(&scratch, dir) == 0);
    -+	cl_assert(reftable_buf_addstr(&scratch, "/") == 0);
    ++	cl_assert_equal_i(reftable_buf_addstr(&scratch, dir), 0);
    ++	cl_assert_equal_i(reftable_buf_addstr(&scratch, "/"), 0);
      	/* do not try at home; not an external API for reftable. */
     -	check(!reftable_buf_addstr(&scratch, st->tables[0]->name));
     +	cl_assert(!reftable_buf_addstr(&scratch, st->tables[0]->name));
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_uptodate(void)
     -
     -	err = reftable_stack_add(st2, write_test_ref, &ref2);
     -	check(!err);
    -+	cl_assert(reftable_new_stack(&st1, dir, &opts) == 0);
    -+	cl_assert(reftable_new_stack(&st2, dir, &opts) == 0);
    -+	cl_assert(reftable_stack_add(st1, write_test_ref, &ref1) == 0);
    -+	cl_assert_equal_i(reftable_stack_add(st2, write_test_ref, &ref2),
    -+					  REFTABLE_OUTDATED_ERROR);
    -+	cl_assert(reftable_stack_reload(st2) == 0);
    -+	cl_assert(reftable_stack_add(st2, write_test_ref, &ref2) == 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st1, dir, &opts), 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st2, dir, &opts), 0);
    ++	cl_assert_equal_i(reftable_stack_add(st1, write_test_ref,
    ++					     &ref1), 0);
    ++	cl_assert_equal_i(reftable_stack_add(st2, write_test_ref,
    ++					     &ref2), REFTABLE_OUTDATED_ERROR);
    ++	cl_assert_equal_i(reftable_stack_reload(st2), 0);
    ++	cl_assert_equal_i(reftable_stack_add(st2, write_test_ref,
    ++					     &ref2), 0);
      	reftable_stack_destroy(st1);
      	reftable_stack_destroy(st2);
      	clear_dir(dir);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_transaction_api(vo
      
     -	err = reftable_new_stack(&st, dir, &opts);
     -	check(!err);
    -+	cl_assert(reftable_new_stack(&st, dir, &opts) == 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
      
      	reftable_addition_destroy(add);
      
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_transaction_api(vo
     -
     -	err = reftable_addition_commit(add);
     -	check(!err);
    -+	cl_assert(reftable_stack_new_addition(&add, st, 0) == 0);
    -+	cl_assert(reftable_addition_add(add, write_test_ref, &ref) == 0);
    -+	cl_assert(reftable_addition_commit(add) == 0);
    ++	cl_assert_equal_i(reftable_stack_new_addition(&add, st, 0), 0);
    ++	cl_assert_equal_i(reftable_addition_add(add, write_test_ref,
    ++						&ref), 0);
    ++	cl_assert_equal_i(reftable_addition_commit(add), 0);
      
      	reftable_addition_destroy(add);
      
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_transaction_api(vo
     -	check(!err);
     -	check_int(REFTABLE_REF_SYMREF, ==, dest.value_type);
     -	check(reftable_ref_record_equal(&ref, &dest, REFTABLE_HASH_SIZE_SHA1));
    -+	cl_assert(reftable_stack_read_ref(st, ref.refname, &dest) == 0);
    ++	cl_assert_equal_i(reftable_stack_read_ref(st, ref.refname,
    ++						  &dest), 0);
     +	cl_assert_equal_i(REFTABLE_REF_SYMREF, dest.value_type);
    -+	cl_assert(reftable_ref_record_equal(&ref, &dest, REFTABLE_HASH_SIZE_SHA1) != 0);
    ++	cl_assert(reftable_ref_record_equal(&ref, &dest,
    ++					    REFTABLE_HASH_SIZE_SHA1) != 0);
      
      	reftable_ref_record_release(&dest);
      	reftable_stack_destroy(st);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_transaction_with_r
     -	check(!err);
     -	err = reftable_addition_commit(add);
     -	check(!err);
    -+	cl_assert(reftable_new_stack(&st1, dir, NULL) == 0);
    -+	cl_assert(reftable_new_stack(&st2, dir, NULL) == 0);
    -+	cl_assert(reftable_stack_new_addition(&add, st1, 0) == 0);
    -+	cl_assert(reftable_addition_add(add, write_test_ref, &refs[0]) == 0);
    -+	cl_assert(reftable_addition_commit(add) == 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st1, dir, NULL), 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st2, dir, NULL), 0);
    ++	cl_assert_equal_i(reftable_stack_new_addition(&add, st1, 0), 0);
    ++	cl_assert_equal_i(reftable_addition_add(add, write_test_ref,
    ++						&refs[0]), 0);
    ++	cl_assert_equal_i(reftable_addition_commit(add), 0);
      	reftable_addition_destroy(add);
      
      	/*
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_transaction_with_r
     -	err = reftable_addition_commit(add);
     -	check(!err);
     +	cl_assert_equal_i(reftable_stack_new_addition(&add, st2, 0),
    -+					  REFTABLE_OUTDATED_ERROR);
    -+	cl_assert(reftable_stack_new_addition(&add, st2,
    -+										  REFTABLE_STACK_NEW_ADDITION_RELOAD) == 0);
    -+	cl_assert(reftable_addition_add(add, write_test_ref, &refs[1]) == 0);
    -+	cl_assert(reftable_addition_commit(add) == 0);
    ++						      REFTABLE_OUTDATED_ERROR);
    ++	cl_assert_equal_i(reftable_stack_new_addition(&add, st2,
    ++						      REFTABLE_STACK_NEW_ADDITION_RELOAD), 0);
    ++	cl_assert_equal_i(reftable_addition_add(add, write_test_ref,
    ++						&refs[1]), 0);
    ++	cl_assert_equal_i(reftable_addition_commit(add), 0);
      	reftable_addition_destroy(add);
      
      	for (size_t i = 0; i < ARRAY_SIZE(refs); i++) {
     -		err = reftable_stack_read_ref(st2, refs[i].refname, &ref);
     -		check(!err);
     -		check(reftable_ref_record_equal(&refs[i], &ref, REFTABLE_HASH_SIZE_SHA1));
    -+		cl_assert(reftable_stack_read_ref(st2, refs[i].refname, &ref) == 0);
    ++		cl_assert_equal_i(reftable_stack_read_ref(st2,
    ++							  refs[i].refname, &ref) , 0);
     +		cl_assert(reftable_ref_record_equal(&refs[i], &ref,
    -+											REFTABLE_HASH_SIZE_SHA1) != 0);
    ++						    REFTABLE_HASH_SIZE_SHA1) != 0);
      	}
      
      	reftable_ref_record_release(&ref);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_transaction_with_r
      
     -	err = reftable_new_stack(&st, dir, &opts);
     -	check(!err);
    -+	cl_assert(reftable_new_stack(&st, dir, &opts) == 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
      
      	for (size_t i = 0; i <= n; i++) {
      		struct reftable_ref_record ref = {
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_transaction_api_pe
     -
     -		err = reftable_addition_commit(add);
     -		check(!err);
    -+		cl_assert(reftable_stack_new_addition(&add, st, 0) == 0);
    -+		cl_assert(reftable_addition_add(add, write_test_ref, &ref) == 0);
    -+		cl_assert(reftable_addition_commit(add) == 0);
    ++		cl_assert_equal_i(reftable_stack_new_addition(&add,
    ++							      st, 0), 0);
    ++		cl_assert_equal_i(reftable_addition_add(add,
    ++							write_test_ref, &ref), 0);
    ++		cl_assert_equal_i(reftable_addition_commit(add), 0);
      
      		reftable_addition_destroy(add);
      
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_auto_compaction_fa
     -	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(reftable_new_stack(&st, dir, &opts), 0);
    ++	cl_assert_equal_i(reftable_stack_add(st, write_test_ref,
    ++					     &ref), 0);
     +	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_update_index_check
     -
     -	err = reftable_stack_add(st, write_test_ref, &ref2);
     -	check_int(err, ==, REFTABLE_API_ERROR);
    -+	cl_assert(reftable_new_stack(&st, dir, &opts) == 0);
    -+	cl_assert(reftable_stack_add(st, write_test_ref, &ref1) == 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
     +	cl_assert_equal_i(reftable_stack_add(st, write_test_ref,
    -+										 &ref2), REFTABLE_API_ERROR);
    ++					     &ref1), 0);
    ++	cl_assert_equal_i(reftable_stack_add(st, write_test_ref,
    ++					     &ref2), REFTABLE_API_ERROR);
      	reftable_stack_destroy(st);
      	clear_dir(dir);
      }
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_update_index_check
     -		err = reftable_stack_add(st, write_error, &i);
     -		check_int(err, ==, i);
     -	}
    -+	cl_assert(reftable_new_stack(&st, dir, &opts) == 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
     +	for (i = -1; i != REFTABLE_EMPTY_TABLE_ERROR; i--)
    -+		cl_assert_equal_i(reftable_stack_add(st, write_error, &i), i);
    ++		cl_assert_equal_i(reftable_stack_add(st, write_error,
    ++						     &i), i);
      
      	reftable_stack_destroy(st);
      	clear_dir(dir);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_add(void)
      		refs[i].update_index = i + 1;
      		refs[i].value_type = REFTABLE_REF_VAL1;
     -		t_reftable_set_hash(refs[i].value.val1, i, REFTABLE_HASH_SHA1);
    -+		cl_reftable_set_hash(refs[i].value.val1, i, REFTABLE_HASH_SHA1);
    ++		cl_reftable_set_hash(refs[i].value.val1, i,
    ++				     REFTABLE_HASH_SHA1);
      
      		logs[i].refname = xstrdup(buf);
      		logs[i].update_index = N + i + 1;
      		logs[i].value_type = REFTABLE_LOG_UPDATE;
      		logs[i].value.update.email = xstrdup("identity@invalid");
     -		t_reftable_set_hash(logs[i].value.update.new_hash, i, REFTABLE_HASH_SHA1);
    -+		cl_reftable_set_hash(logs[i].value.update.new_hash, i, REFTABLE_HASH_SHA1);
    ++		cl_reftable_set_hash(logs[i].value.update.new_hash, i,
    ++				     REFTABLE_HASH_SHA1);
      	}
      
     -	for (i = 0; i < N; i++) {
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_add(void)
     -		check(!err);
     -	}
     +	for (i = 0; i < N; i++)
    -+		cl_assert(reftable_stack_add(st, write_test_ref, &refs[i]) == 0);
    ++		cl_assert_equal_i(reftable_stack_add(st, write_test_ref,
    ++					     &refs[i]), 0);
      
      	for (i = 0; i < N; i++) {
      		struct write_log_arg arg = {
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_add(void)
      		};
     -		int err = reftable_stack_add(st, write_test_log, &arg);
     -		check(!err);
    -+		cl_assert(reftable_stack_add(st, write_test_log, &arg) == 0);
    ++		cl_assert_equal_i(reftable_stack_add(st, write_test_log,
    ++						     &arg), 0);
      	}
      
     -	err = reftable_stack_compact_all(st, NULL);
     -	check(!err);
    -+	cl_assert(reftable_stack_compact_all(st, NULL) == 0);
    ++	cl_assert_equal_i(reftable_stack_compact_all(st, NULL), 0);
      
      	for (i = 0; i < N; i++) {
      		struct reftable_ref_record dest = { 0 };
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_add(void)
     -		check(!err);
     -		check(reftable_ref_record_equal(&dest, refs + i,
     -						 REFTABLE_HASH_SIZE_SHA1));
    -+		cl_assert(reftable_stack_read_ref(st, refs[i].refname, &dest) == 0);
    ++		cl_assert_equal_i(reftable_stack_read_ref(st,
    ++							  refs[i].refname, &dest), 0);
     +		cl_assert(reftable_ref_record_equal(&dest, refs + i,
    -+											REFTABLE_HASH_SIZE_SHA1) != 0);
    ++						    REFTABLE_HASH_SIZE_SHA1) != 0);
      		reftable_ref_record_release(&dest);
      	}
      
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_add(void)
     -		check(!err);
     -		check(reftable_log_record_equal(&dest, logs + i,
     -						 REFTABLE_HASH_SIZE_SHA1));
    -+		cl_assert(reftable_stack_read_log(st, refs[i].refname, &dest) == 0);
    ++		cl_assert_equal_i(reftable_stack_read_log(st,
    ++							  refs[i].refname, &dest), 0);
     +		cl_assert(reftable_log_record_equal(&dest, logs + i,
    -+											REFTABLE_HASH_SIZE_SHA1) != 0);
    ++						    REFTABLE_HASH_SIZE_SHA1) != 0);
      		reftable_log_record_release(&dest);
      	}
      
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_add(void)
     -	err = stat(path.buf, &stat_result);
     -	check(!err);
     -	check_int((stat_result.st_mode & 0777), ==, opts.default_permissions);
    -+	cl_assert(reftable_buf_addstr(&path, dir) == 0);
    -+	cl_assert(reftable_buf_addstr(&path, "/tables.list") == 0);
    -+	cl_assert(stat(path.buf, &stat_result) == 0);
    ++	cl_assert_equal_i(reftable_buf_addstr(&path, dir), 0);
    ++	cl_assert_equal_i(reftable_buf_addstr(&path, "/tables.list"), 0);
    ++	cl_assert_equal_i(stat(path.buf, &stat_result), 0);
     +	cl_assert_equal_i((stat_result.st_mode & 0777), opts.default_permissions);
      
      	reftable_buf_reset(&path);
     -	check(!reftable_buf_addstr(&path, dir));
     -	check(!reftable_buf_addstr(&path, "/"));
    -+	cl_assert(reftable_buf_addstr(&path, dir) == 0);
    -+	cl_assert(reftable_buf_addstr(&path, "/") == 0);
    ++	cl_assert_equal_i(reftable_buf_addstr(&path, dir), 0);
    ++	cl_assert_equal_i(reftable_buf_addstr(&path, "/"), 0);
      	/* do not try at home; not an external API for reftable. */
     -	check(!reftable_buf_addstr(&path, st->tables[0]->name));
     +	cl_assert(!reftable_buf_addstr(&path, st->tables[0]->name));
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_add(void)
     -	check(!err);
     -	check_int((stat_result.st_mode & 0777), ==, opts.default_permissions);
     +	cl_assert(!err);
    -+	cl_assert_equal_i((stat_result.st_mode & 0777), opts.default_permissions);
    ++	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_iterator(void)
      
     -	err = reftable_new_stack(&st, dir, &opts);
     -	check(!err);
    -+	cl_assert(reftable_new_stack(&st, dir, &opts) == 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
      
      	for (i = 0; i < N; i++) {
      		refs[i].refname = xstrfmt("branch%02"PRIuMAX, (uintmax_t)i);
      		refs[i].update_index = i + 1;
      		refs[i].value_type = REFTABLE_REF_VAL1;
     -		t_reftable_set_hash(refs[i].value.val1, i, REFTABLE_HASH_SHA1);
    -+		cl_reftable_set_hash(refs[i].value.val1, i, REFTABLE_HASH_SHA1);
    ++		cl_reftable_set_hash(refs[i].value.val1, i,
    ++				     REFTABLE_HASH_SHA1);
      
      		logs[i].refname = xstrfmt("branch%02"PRIuMAX, (uintmax_t)i);
      		logs[i].update_index = i + 1;
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_iterator(void)
      		logs[i].value.update.email = xstrdup("johndoe@invalid");
      		logs[i].value.update.message = xstrdup("commit\n");
     -		t_reftable_set_hash(logs[i].value.update.new_hash, i, REFTABLE_HASH_SHA1);
    -+		cl_reftable_set_hash(logs[i].value.update.new_hash, i, REFTABLE_HASH_SHA1);
    ++		cl_reftable_set_hash(logs[i].value.update.new_hash, i,
    ++				     REFTABLE_HASH_SHA1);
      	}
      
     -	for (i = 0; i < N; i++) {
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_iterator(void)
     -		check(!err);
     -	}
     +	for (i = 0; i < N; i++)
    -+		cl_assert(reftable_stack_add(st, write_test_ref, &refs[i]) == 0);
    ++		cl_assert_equal_i(reftable_stack_add(st,
    ++						     write_test_ref, &refs[i]), 0);
      
      	for (i = 0; i < N; i++) {
      		struct write_log_arg arg = {
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_iterator(void)
      
     -		err = reftable_stack_add(st, write_test_log, &arg);
     -		check(!err);
    -+		cl_assert(reftable_stack_add(st, write_test_log, &arg) == 0);
    ++		cl_assert_equal_i(reftable_stack_add(st,
    ++						     write_test_log, &arg), 0);
      	}
      
      	reftable_stack_init_ref_iterator(st, &it);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_iterator(void)
      			break;
     -		check(!err);
     -		check(reftable_ref_record_equal(&ref, &refs[i], REFTABLE_HASH_SIZE_SHA1));
    -+		cl_assert(err == 0);
    ++		cl_assert(!err);
     +		cl_assert(reftable_ref_record_equal(&ref, &refs[i],
    -+											REFTABLE_HASH_SIZE_SHA1) != 0);
    ++						    REFTABLE_HASH_SIZE_SHA1) != 0);
      		reftable_ref_record_release(&ref);
      	}
     -	check_int(i, ==, N);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_iterator(void)
      
     -	err = reftable_stack_init_log_iterator(st, &it);
     -	check(!err);
    -+	cl_assert(reftable_stack_init_log_iterator(st, &it) == 0);
    ++	cl_assert_equal_i(reftable_stack_init_log_iterator(st, &it), 0);
      
      	reftable_iterator_seek_log(&it, logs[0].refname);
      	for (i = 0; ; i++) {
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_iterator(void)
      			break;
     -		check(!err);
     -		check(reftable_log_record_equal(&log, &logs[i], REFTABLE_HASH_SIZE_SHA1));
    -+		cl_assert(err == 0);
    ++		cl_assert(!err);
     +		cl_assert(reftable_log_record_equal(&log, &logs[i],
    -+											REFTABLE_HASH_SIZE_SHA1) != 0);
    ++						    REFTABLE_HASH_SIZE_SHA1) != 0);
      		reftable_log_record_release(&log);
      	}
     -	check_int(i, ==, N);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_log_normalize(void
      
     -	err = reftable_new_stack(&st, dir, &opts);
     -	check(!err);
    -+	cl_assert(reftable_new_stack(&st, dir, &opts) == 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
      
      	input.value.update.message = (char *) "one\ntwo";
     -	err = reftable_stack_add(st, write_test_log, &arg);
     -	check_int(err, ==, REFTABLE_API_ERROR);
     +	cl_assert_equal_i(reftable_stack_add(st, write_test_log,
    -+										 &arg), REFTABLE_API_ERROR);
    ++					     &arg), REFTABLE_API_ERROR);
      
      	input.value.update.message = (char *) "one";
     -	err = reftable_stack_add(st, write_test_log, &arg);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_log_normalize(void
     -	err = reftable_stack_read_log(st, input.refname, &dest);
     -	check(!err);
     -	check_str(dest.value.update.message, "one\n");
    -+	cl_assert(reftable_stack_add(st, write_test_log, &arg) == 0);
    -+	cl_assert(reftable_stack_read_log(st, input.refname, &dest) == 0);
    ++	cl_assert_equal_i(reftable_stack_add(st, write_test_log,
    ++					     &arg), 0);
    ++	cl_assert_equal_i(reftable_stack_read_log(st, input.refname,
    ++						  &dest), 0);
     +	cl_assert_equal_s(dest.value.update.message, "one\n");
      
      	input.value.update.message = (char *) "two\n";
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_log_normalize(void
     -	err = reftable_stack_read_log(st, input.refname, &dest);
     -	check(!err);
     -	check_str(dest.value.update.message, "two\n");
    -+	cl_assert(reftable_stack_add(st, write_test_log, &arg) == 0);
    -+	cl_assert(reftable_stack_read_log(st, input.refname, &dest) == 0);
    ++	cl_assert_equal_i(reftable_stack_add(st, write_test_log,
    ++					     &arg), 0);
    ++	cl_assert_equal_i(reftable_stack_read_log(st, input.refname,
    ++						  &dest), 0);
     +	cl_assert_equal_s(dest.value.update.message, "two\n");
      
      	/* cleanup */
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_log_normalize(void
      
     -	err = reftable_new_stack(&st, dir, &opts);
     -	check(!err);
    -+	cl_assert(reftable_new_stack(&st, dir, &opts) == 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
      
      	/* even entries add the refs, odd entries delete them. */
      	for (i = 0; i < N; i++) {
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_tombstone(void)
      		if (i % 2 == 0) {
      			refs[i].value_type = REFTABLE_REF_VAL1;
     -			t_reftable_set_hash(refs[i].value.val1, i,
    +-					    REFTABLE_HASH_SHA1);
     +			cl_reftable_set_hash(refs[i].value.val1, i,
    - 					    REFTABLE_HASH_SHA1);
    ++					     REFTABLE_HASH_SHA1);
      		}
      
    + 		logs[i].refname = xstrdup(buf);
     @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_tombstone(void)
      		logs[i].update_index = 1;
      		if (i % 2 == 0) {
      			logs[i].value_type = REFTABLE_LOG_UPDATE;
     -			t_reftable_set_hash(logs[i].value.update.new_hash, i,
    -+			cl_reftable_set_hash(logs[i].value.update.new_hash, i,
    - 					    REFTABLE_HASH_SHA1);
    +-					    REFTABLE_HASH_SHA1);
    ++			cl_reftable_set_hash(logs[i].value.update.new_hash, i, REFTABLE_HASH_SHA1);
      			logs[i].value.update.email =
      				xstrdup("identity@invalid");
      		}
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_tombstone(void)
     -		check(!err);
     -	}
     +	for (i = 0; i < N; i++)
    -+		cl_assert(reftable_stack_add(st, write_test_ref, &refs[i]) == 0);
    ++		cl_assert_equal_i(reftable_stack_add(st, write_test_ref, &refs[i]), 0);
      
      	for (i = 0; i < N; i++) {
      		struct write_log_arg arg = {
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_tombstone(void)
      		};
     -		int err = reftable_stack_add(st, write_test_log, &arg);
     -		check(!err);
    -+		cl_assert(reftable_stack_add(st, write_test_log, &arg) == 0);
    ++		cl_assert_equal_i(reftable_stack_add(st,
    ++						     write_test_log, &arg), 0);
      	}
      
     -	err = reftable_stack_read_ref(st, "branch", &dest);
     -	check_int(err, ==, 1);
    -+	cl_assert_equal_i(reftable_stack_read_ref(st, "branch", &dest), 1);
    ++	cl_assert_equal_i(reftable_stack_read_ref(st, "branch",
    ++						  &dest), 1);
      	reftable_ref_record_release(&dest);
      
     -	err = reftable_stack_read_log(st, "branch", &log_dest);
     -	check_int(err, ==, 1);
    -+	cl_assert_equal_i(reftable_stack_read_log(st, "branch", &log_dest), 1);
    ++	cl_assert_equal_i(reftable_stack_read_log(st, "branch",
    ++						  &log_dest), 1);
      	reftable_log_record_release(&log_dest);
      
     -	err = reftable_stack_compact_all(st, NULL);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_tombstone(void)
     -
     -	err = reftable_stack_read_log(st, "branch", &log_dest);
     -	check_int(err, ==, 1);
    -+	cl_assert(reftable_stack_compact_all(st, NULL) == 0);
    -+	cl_assert_equal_i(reftable_stack_read_ref(st, "branch", &dest), 1);
    -+	cl_assert_equal_i(reftable_stack_read_log(st, "branch", &log_dest), 1);
    ++	cl_assert_equal_i(reftable_stack_compact_all(st, NULL), 0);
    ++	cl_assert_equal_i(reftable_stack_read_ref(st, "branch",
    ++						  &dest), 1);
    ++	cl_assert_equal_i(reftable_stack_read_log(st, "branch",
    ++						  &log_dest), 1);
      	reftable_ref_record_release(&dest);
      	reftable_log_record_release(&log_dest);
      
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_hash_id(void)
     -
     -	err = reftable_stack_add(st, write_test_ref, &ref);
     -	check(!err);
    -+	cl_assert(reftable_new_stack(&st, dir, &opts) == 0);
    -+	cl_assert(reftable_stack_add(st, write_test_ref, &ref) == 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
    ++	cl_assert_equal_i(reftable_stack_add(st, write_test_ref,
    ++					     &ref), 0);
      
      	/* can't read it with the wrong hash ID. */
     -	err = reftable_new_stack(&st32, dir, &opts32);
     -	check_int(err, ==, REFTABLE_FORMAT_ERROR);
    -+	cl_assert_equal_i(reftable_new_stack(&st32, dir, &opts32), REFTABLE_FORMAT_ERROR);
    ++	cl_assert_equal_i(reftable_new_stack(&st32, dir,
    ++					     &opts32), REFTABLE_FORMAT_ERROR);
      
      	/* check that we can read it back with default opts too. */
     -	err = reftable_new_stack(&st_default, dir, &opts_default);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_hash_id(void)
     -	check(!err);
     -
     -	check(reftable_ref_record_equal(&ref, &dest, REFTABLE_HASH_SIZE_SHA1));
    -+	cl_assert(reftable_new_stack(&st_default, dir, &opts_default) == 0);
    -+	cl_assert(reftable_stack_read_ref(st_default, "master", &dest) == 0);
    -+	cl_assert(reftable_ref_record_equal(&ref, &dest, REFTABLE_HASH_SIZE_SHA1) != 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st_default, dir,
    ++					     &opts_default), 0);
    ++	cl_assert_equal_i(reftable_stack_read_ref(st_default, "master",
    ++						  &dest), 0);
    ++	cl_assert(reftable_ref_record_equal(&ref, &dest,
    ++					    REFTABLE_HASH_SIZE_SHA1) != 0);
      	reftable_ref_record_release(&dest);
      	reftable_stack_destroy(st);
      	reftable_stack_destroy(st_default);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_hash_id(void)
      
     -	err = reftable_new_stack(&st, dir, &opts);
     -	check(!err);
    -+	cl_assert(reftable_new_stack(&st, dir, &opts) == 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
      
      	for (i = 1; i <= N; i++) {
      		char buf[256];
    @@ t/unit-tests/u-reftable-stack.c: static void t_reflog_expire(void)
      		logs[i].value.update.time = i;
      		logs[i].value.update.email = xstrdup("identity@invalid");
     -		t_reftable_set_hash(logs[i].value.update.new_hash, i,
    +-				    REFTABLE_HASH_SHA1);
     +		cl_reftable_set_hash(logs[i].value.update.new_hash, i,
    - 				    REFTABLE_HASH_SHA1);
    ++				     REFTABLE_HASH_SHA1);
      	}
      
    + 	for (i = 1; i <= N; i++) {
     @@ t/unit-tests/u-reftable-stack.c: static void t_reflog_expire(void)
      			.log = &logs[i],
      			.update_index = reftable_stack_next_update_index(st),
      		};
     -		int err = reftable_stack_add(st, write_test_log, &arg);
     -		check(!err);
    -+		cl_assert(reftable_stack_add(st, write_test_log, &arg) == 0);
    ++		cl_assert_equal_i(reftable_stack_add(st, write_test_log,
    ++						     &arg), 0);
      	}
      
     -	err = reftable_stack_compact_all(st, NULL);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reflog_expire(void)
     -
     -	err = reftable_stack_read_log(st, logs[11].refname, &log);
     -	check(!err);
    -+	cl_assert(reftable_stack_compact_all(st, NULL) == 0);
    -+	cl_assert(reftable_stack_compact_all(st, &expiry) == 0);
    -+	cl_assert_equal_i(reftable_stack_read_log(st, logs[9].refname, &log), 1);
    -+	cl_assert(reftable_stack_read_log(st, logs[11].refname, &log) == 0);
    ++	cl_assert_equal_i(reftable_stack_compact_all(st, NULL), 0);
    ++	cl_assert_equal_i(reftable_stack_compact_all(st, &expiry), 0);
    ++	cl_assert_equal_i(reftable_stack_read_log(st, logs[9].refname,
    ++						  &log), 1);
    ++	cl_assert_equal_i(reftable_stack_read_log(st, logs[11].refname,
    ++						  &log), 0);
      
      	expiry.min_update_index = 15;
     -	err = reftable_stack_compact_all(st, &expiry);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reflog_expire(void)
     -
     -	err = reftable_stack_read_log(st, logs[16].refname, &log);
     -	check(!err);
    -+	cl_assert(reftable_stack_compact_all(st, &expiry) == 0);
    -+	cl_assert_equal_i(reftable_stack_read_log(st, logs[14].refname, &log), 1);
    -+	cl_assert(reftable_stack_read_log(st, logs[16].refname, &log) == 0);
    ++	cl_assert_equal_i(reftable_stack_compact_all(st, &expiry), 0);
    ++	cl_assert_equal_i(reftable_stack_read_log(st, logs[14].refname,
    ++						  &log), 1);
    ++	cl_assert_equal_i(reftable_stack_read_log(st, logs[16].refname,
    ++						  &log), 0);
      
      	/* cleanup */
      	reftable_stack_destroy(st);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reflog_expire(void)
      static int write_nothing(struct reftable_writer *wr, void *arg UNUSED)
      {
     -	check(!reftable_writer_set_limits(wr, 1, 1));
    -+	cl_assert(reftable_writer_set_limits(wr, 1, 1) == 0);
    ++	cl_assert_equal_i(reftable_writer_set_limits(wr, 1, 1), 0);
      	return 0;
      }
      
    @@ t/unit-tests/u-reftable-stack.c: static void t_reflog_expire(void)
     -
     -	err = reftable_new_stack(&st2, dir, &opts);
     -	check(!err);
    -+	cl_assert(reftable_new_stack(&st, dir, &opts) == 0);
    -+	cl_assert(reftable_stack_add(st, write_nothing, NULL) == 0);
    -+	cl_assert(reftable_new_stack(&st2, dir, &opts) == 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
    ++	cl_assert_equal_i(reftable_stack_add(st, write_nothing,
    ++					     NULL), 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st2, dir, &opts), 0);
      	clear_dir(dir);
      	reftable_stack_destroy(st);
      	reftable_stack_destroy(st2);
    @@ t/unit-tests/u-reftable-stack.c: static int fastlogN(uint64_t sz, uint64_t N)
      
     -	err = reftable_new_stack(&st, dir, &opts);
     -	check(!err);
    -+	cl_assert(reftable_new_stack(&st, dir, &opts) == 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
      
      	for (i = 0; i < N; i++) {
      		char name[100];
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_auto_compaction(vo
      
     -	err = reftable_new_stack(&st, dir, &opts);
     -	check(!err);
    -+	cl_assert(reftable_new_stack(&st, dir, &opts) == 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
      
      	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_wi
      
     -	err = reftable_new_stack(&st, dir, &opts);
     -	check(!err);
    -+	cl_assert(reftable_new_stack(&st, dir, &opts) == 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
      
      	write_n_ref_tables(st, 5);
     -	check_int(st->merged->tables_len, ==, 5);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_auto_compaction_wi
      
     -	err = reftable_new_stack(&st, dir, &opts);
     -	check(!err);
    -+	cl_assert(reftable_new_stack(&st, dir, &opts) == 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
      
      	for (i = 0; i <= n; i++) {
      		struct reftable_ref_record ref = {
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_add_performs_auto_
      
     -		err = reftable_stack_add(st, write_test_ref, &ref);
     -		check(!err);
    -+		cl_assert(reftable_stack_add(st, write_test_ref, &ref) == 0);
    ++		cl_assert_equal_i(reftable_stack_add(st,
    ++						     write_test_ref, &ref), 0);
      
      		/*
      		 * The stack length should grow continuously for all runs where
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_compaction_with_lo
      
     -	err = reftable_new_stack(&st, dir, &opts);
     -	check(!err);
    -+	cl_assert(reftable_new_stack(&st, dir, &opts) == 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
      
      	write_n_ref_tables(st, 3);
     -	check_int(st->merged->tables_len, ==, 3);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_compaction_with_lo
      
     -	err = reftable_new_stack(&st1, dir, &opts);
     -	check(!err);
    -+	cl_assert(reftable_new_stack(&st1, dir, &opts) == 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st1, dir, &opts), 0);
      	write_n_ref_tables(st1, 3);
      
     -	err = reftable_new_stack(&st2, dir, &opts);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_compaction_with_lo
     -
     -	err = reftable_stack_compact_all(st1, NULL);
     -	check(!err);
    -+	cl_assert(reftable_new_stack(&st2, dir, &opts) == 0);
    -+	cl_assert(reftable_stack_compact_all(st1, NULL) == 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st2, dir, &opts), 0);
    ++	cl_assert_equal_i(reftable_stack_compact_all(st1, NULL), 0);
      
      	reftable_stack_destroy(st1);
      	reftable_stack_destroy(st2);
    @@ t/unit-tests/u-reftable-stack.c: static void unclean_stack_close(struct reftable
      
     -	err = reftable_new_stack(&st1, dir, &opts);
     -	check(!err);
    -+	cl_assert(reftable_new_stack(&st1, dir, &opts) == 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st1, dir, &opts), 0);
      	write_n_ref_tables(st1, 3);
      
     -	err = reftable_new_stack(&st2, dir, &opts);
    @@ t/unit-tests/u-reftable-stack.c: static void unclean_stack_close(struct reftable
     -
     -	err = reftable_stack_compact_all(st1, NULL);
     -	check(!err);
    -+	cl_assert(reftable_new_stack(&st2, dir, &opts) == 0);
    -+	cl_assert(reftable_stack_compact_all(st1, NULL) == 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st2, dir, &opts), 0);
    ++	cl_assert_equal_i(reftable_stack_compact_all(st1, NULL), 0);
      
      	unclean_stack_close(st1);
      	unclean_stack_close(st2);
    @@ t/unit-tests/u-reftable-stack.c: static void unclean_stack_close(struct reftable
     -	err = reftable_stack_clean(st3);
     -	check(!err);
     -	check_int(count_dir_entries(dir), ==, 2);
    -+	cl_assert(reftable_new_stack(&st3, dir, &opts) == 0);
    -+	cl_assert(reftable_stack_clean(st3) == 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st3, dir, &opts), 0);
    ++	cl_assert_equal_i(reftable_stack_clean(st3), 0);
     +	cl_assert_equal_i(count_dir_entries(dir), 2);
      
      	reftable_stack_destroy(st1);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_read_across_reload
      	/* 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);
    ++	cl_assert_equal_i(reftable_new_stack(&st1, dir, &opts), 0);
      	write_n_ref_tables(st1, 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);
    ++	cl_assert_equal_i(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);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_reload_with_missin
      	/* 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);
    ++	cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
      	write_n_ref_tables(st, 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);
    -+	cl_assert(reftable_iterator_seek_ref(&it, "") == 0);
    ++	cl_assert_equal_i(reftable_iterator_seek_ref(&it, ""), 0);
      
      	/*
      	 * Update the tables.list file with some garbage data, while reusing
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_reload_with_missin
      	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);
    ++	cl_assert_equal_i(rename(table_path.buf, st->list_file), 0);
      
      	err = reftable_stack_reload(st);
     -	check_int(err, ==, -4);
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_reload_with_missin
     -	check_str(rec.refname, "refs/heads/branch-0001");
     -	err = reftable_iterator_next_ref(&it, &rec);
     -	check_int(err, >, 0);
    -+	cl_assert(reftable_iterator_next_ref(&it, &rec) == 0);
    ++	cl_assert_equal_i(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_equal_i(reftable_iterator_next_ref(&it, &rec), 0);
     +	cl_assert_equal_s(rec.refname, "refs/heads/branch-0001");
     +	cl_assert(reftable_iterator_next_ref(&it, &rec) > 0);
      
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_stack_reload_with_missin
      	struct reftable_ref_record *ref = arg;
     -	check(!reftable_writer_set_limits(wr, ref->update_index, ref->update_index));
     -	check(!reftable_writer_add_ref(wr, ref));
    -+	cl_assert(reftable_writer_set_limits(wr, ref->update_index,
    -+										 ref->update_index) == 0);
    -+	cl_assert(reftable_writer_add_ref(wr, ref) == 0);
    ++	cl_assert_equal_i(reftable_writer_set_limits(wr,
    ++						     ref->update_index, ref->update_index), 0);
    ++	cl_assert_equal_i(reftable_writer_add_ref(wr, ref), 0);
      	return reftable_writer_set_limits(wr, ref->update_index, ref->update_index);
      }
      
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_invalid_limit_updates(vo
      
     -	err = reftable_new_stack(&st, dir, &opts);
     -	check(!err);
    -+	cl_assert(reftable_new_stack(&st, dir, &opts) == 0);
    ++	cl_assert_equal_i(reftable_new_stack(&st, dir, &opts), 0);
      
      	reftable_addition_destroy(add);
      
     -	err = reftable_stack_new_addition(&add, st, 0);
     -	check(!err);
    -+	cl_assert(reftable_stack_new_addition(&add, st, 0) == 0);
    ++	cl_assert_equal_i(reftable_stack_new_addition(&add, st, 0), 0);
      
      	/*
      	 * write_limits_after_ref also updates the update indexes after adding
    @@ t/unit-tests/u-reftable-stack.c: static void t_reftable_invalid_limit_updates(vo
      	 */
     -	err = reftable_addition_add(add, write_limits_after_ref, &ref);
     -	check_int(err, ==, REFTABLE_API_ERROR);
    -+	cl_assert_equal_i(reftable_addition_add(add, write_limits_after_ref, &ref),
    -+					  REFTABLE_API_ERROR);
    ++	cl_assert_equal_i(reftable_addition_add(add,
    ++						write_limits_after_ref, &ref), REFTABLE_API_ERROR);
      
      	reftable_addition_destroy(add);
      	reftable_stack_destroy(st);

10: bf271f4ddf ! 10: 8469fe3c0f t/unit-tests: finalize migration of reftable-related tests
@@ Commit message
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.
+ 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.
+ unit-testing setup. test-lib.{c,h} remains unchanged in our build
+ system as some files particularly t/helper/test-example-tap.c depends
+ on it in order to run, and removing that would be beyond the scope of
+ this patch.

@@ t/unit-tests/u-reftable-stack.c: void test_reftable_stack__add(void)

## t/unit-tests/u-reftable-table.c ##
@@
- #include "test-lib.h"
+ #include "unit-test.h"
-#include "lib-reftable-clar.h"
+#include "lib-reftable.h"
#include "reftable/blocksource.h"

Signature · 1 line
2.43.0
#1 lore raw

PATCH v4 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

PATCH v4 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
#3 lore raw

PATCH v4 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
#4 lore raw

PATCH v4 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
#5 lore raw

PATCH v4 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
#6 lore raw

PATCH v4 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} | 75 +++++++++----------
 3 files changed, 39 insertions(+), 45 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 +35 -40

170 lines not on this page · raw message

Signature · 1 line
2.43.0
#7 lore raw

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

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

Quoted 13 lines · Seyi Kuforiji
Makefile +1 -1
index 3cccc73073..0227fdb3e1 100644
@@ -1368,6 +1368,7 @@ CLAR_TEST_SUITES += u-reftable-basics
...
@@ -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 am sure I pointed this breakage out, locally fixed it in my tree, and told you about the consequences of such breakage. Next time please make sure you fetch back from what upstream has its 'seen' and start your work from that state.

In addition, perhaps you should fix your editor settings to avoid files with such an incomplete line at the end. There may be other incomplete lines in this seris.

And a possible #leftoverbits is probably to teach the whitespace error checking code to optionally flag a new incomplete line as an error (this is obviously way outside the topic of this series).

Thanks.

#8 lore raw

PATCH v4 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} | 405 ++++++++----------
 3 files changed, 179 insertions(+), 230 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 +177 -228

959 lines not on this page · raw message

Signature · 1 line
2.43.0
#9 lore raw

PATCH v4 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} | 250 +++++++++---------
 3 files changed, 130 insertions(+), 122 deletions(-)
 rename t/unit-tests/{t-reftable-record.c => u-reftable-record.c} (62%)
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 +130 -120

454 lines not on this page · raw message

Signature · 1 line
2.43.0
#10 lore raw

PATCH v4 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} | 780 ++++++++----------
 3 files changed, 333 insertions(+), 454 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 +330 -450

1,474 lines not on this page · raw message

Signature · 1 line
2.43.0
#11 lore raw

Re: [PATCH v4 09/10] t/unit-tests: convert reftable stack test to use clar

t/meson.build clar_test_suites = [ · line 16

Quoted 9 lines · Seyi Kuforiji
t/meson.build +1 -0
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',

This change belongs into the previous commit.

t/meson.build clar_test_suites = [ · line 20

Quoted 4 lines
t/meson.build +1 -0
+  'unit-tests/u-reftable-stack.c',
   'unit-tests/u-reftable-table.c',
   'unit-tests/u-reftable-tree.c',
   'unit-tests/u-strbuf.c',

Patrick

#12 lore raw

PATCH v4 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. test-lib.{c,h} remains unchanged in our build system as some files particularly t/helper/test-example-tap.c depends on it in order to run, and removing that would be beyond the scope of this patch.

---
 Makefile                            |   8 +--
 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, 39 insertions(+), 180 deletions(-)
 delete mode 100644 t/unit-tests/lib-reftable-clar.c
 delete mode 100644 t/unit-tests/lib-reftable-clar.h
Makefile +3 -5
index 8ed8f234f4..25e6558b7b 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)
@@ -3971,4 +3969,4 @@ $(LIBGIT_HIDDEN_EXPORT): $(LIBGIT_PARTIAL_EXPORT)
 	$(OBJCOPY) --localize-hidden $^ $@
 
 contrib/libgit-sys/libgitpub.a: $(LIBGIT_HIDDEN_EXPORT)
-	$(AR) $(ARFLAGS) $@ $^
\ No newline at end of file
+	$(AR) $(ARFLAGS) $@ $^
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 97a1348563..f4bded7d26 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 62b02baa14..54cb7fc2a7 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 d55792ca6f..f8a28f6e07 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 9aac74a011..4d8c4be5f1 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 650b0aa0d3..6c8c0d5374 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 0e3e3f4f4a..e4ea57138e 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"
@@ -497,7 +497,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 839107d8a4..14fae8b199 100644
@@ -1,5 +1,5 @@
 #include "unit-test.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
#13 lore raw
In reply to Seyi Kuforiji
Quoted 7 lines · Seyi Kuforiji

This 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 v4:
- some code refactoring and cleanup based on review.

Nothing seems to have happened to the topic (other than one obvious breakage pointed out on 06/10) and it has been more than a month and a half. What's the status of this topic?

Thanks.

#14 lore raw
Quoted 7 lines · Junio C Hamano
Quoted 5 lines · Seyi Kuforiji

This 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.

Quoted 6 lines
Quoted 2 lines

Changes in v4:
- some code refactoring and cleanup based on review.

Nothing seems to have happened to the topic (other than one obvious breakage pointed out on 06/10) and it has been more than a month and a half. What's the status of this topic?

Sorry, I completely lost this from my radar. There's a single line that's part of the wrong commit, but other than that I think this series is good enough now.

Thanks for the ping!

Patrick

#15 lore raw

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

In reply to Seyi Kuforiji

From: Seyi Kufoiji <[email protected]>

Hello,

This 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 v5:
- some code refactoring and cleanup based on review.

Thanks
Seyi

Seyi Kuforiji (5):
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                                      |  13 +-
 t/Makefile                                    |   1 -
 t/meson.build                                 |  34 +-
 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 +-
 ...ble-readwrite.c => u-reftable-readwrite.c} | 403 ++++-----
 ...-reftable-record.c => u-reftable-record.c} | 250 +++---
 ...{t-reftable-stack.c => u-reftable-stack.c} | 780 ++++++++----------
 ...{t-reftable-table.c => u-reftable-table.c} |  73 +-
 15 files changed, 711 insertions(+), 1022 deletions(-)
 delete mode 100644 t/unit-tests/lib-reftable-clar.c
 delete mode 100644 t/unit-tests/lib-reftable-clar.h
 rename t/unit-tests/{t-reftable-readwrite.c => u-reftable-readwrite.c} (68%)
 rename t/unit-tests/{t-reftable-record.c => u-reftable-record.c} (62%)
 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} (75%)

Range-diff against v4:
1: cf8b0471fd ! 1: 7c159bd2fe t/unit-tests: convert reftable table test to use clar

    @@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable-clar.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
    +@@ Makefile: $(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 ##
     @@ t/meson.build: clar_test_suites = [
2:  cbe70c5c23 = 2:  3ae3b2cf9c t/unit-tests: convert reftable readwrite test to use clar
3:  38e2198eac ! 3:  d4303eb913 t/unit-tests: convert reftable record test to use clar

@@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/test-lib.o

## t/meson.build ##
-@@ t/meson.build: 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-table.c',
- 'unit-tests/u-reftable-tree.c',
- 'unit-tests/u-strbuf.c',
@@ t/meson.build: clar_unit_tests = executable('unit-tests',
test('unit-tests', clar_unit_tests)

4: 8de9dbbd3b ! 4: df582f6e2c t/unit-tests: convert reftable stack test to use clar

    @@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
     
      ## t/meson.build ##
     @@ t/meson.build: 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-record.c',
     +  'unit-tests/u-reftable-stack.c',
        'unit-tests/u-reftable-table.c',
        'unit-tests/u-reftable-tree.c',
5:  a69c3370ee ! 5:  9340e7ce88 t/unit-tests: finalize migration of reftable-related tests
    @@ Makefile: CLAR_TEST_SUITES += u-urlmatch-normalization
      
      # 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)
    +@@ Makefile: $(LIBGIT_HIDDEN_EXPORT): $(LIBGIT_PARTIAL_EXPORT)
    + 	$(OBJCOPY) --localize-hidden $^ $@
    + 
    + contrib/libgit-sys/libgitpub.a: $(LIBGIT_HIDDEN_EXPORT)
    +-	$(AR) $(ARFLAGS) $@ $^
    + \ No newline at end of file
    ++	$(AR) $(ARFLAGS) $@ $^
     
      ## t/Makefile ##
     @@ t/Makefile: check-meson:
Signature · 1 line
2.43.0
#16 lore raw

PATCH v5 1/5 t/unit-tests: convert reftable table test to use clar

From: Seyi Kuforiji <[email protected]>

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} | 75 +++++++++----------
 3 files changed, 39 insertions(+), 45 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 +35 -40

170 lines not on this page · raw message

Signature · 1 line
2.43.0
#17 lore raw

PATCH v5 2/5 t/unit-tests: convert reftable readwrite test to use clar

In reply to Seyi Kufoiji

From: Seyi Kuforiji <[email protected]>

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} | 405 ++++++++----------
 3 files changed, 179 insertions(+), 230 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 +177 -228

959 lines not on this page · raw message

Signature · 1 line
2.43.0
#18 lore raw

PATCH v5 3/5 t/unit-tests: convert reftable record test to use clar

In reply to Seyi Kufoiji

From: Seyi Kuforiji <[email protected]>

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} | 250 +++++++++---------
 3 files changed, 130 insertions(+), 122 deletions(-)
 rename t/unit-tests/{t-reftable-record.c => u-reftable-record.c} (62%)
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 +130 -120

454 lines not on this page · raw message

Signature · 1 line
2.43.0
#19 lore raw

PATCH v5 4/5 t/unit-tests: convert reftable stack test to use clar

In reply to Seyi Kufoiji

From: Seyi Kuforiji <[email protected]>

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} | 780 ++++++++----------
 3 files changed, 333 insertions(+), 454 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 +330 -450

1,474 lines not on this page · raw message

Signature · 1 line
2.43.0
#20 lore raw

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

In reply to Seyi Kuforiji

Hello,

This 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 v5:
- some code refactoring and cleanup based on review.

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                                      |  20 +-
 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} | 403 ++++-----
 ...-reftable-record.c => u-reftable-record.c} | 250 +++---
 ...{t-reftable-stack.c => u-reftable-stack.c} | 780 ++++++++----------
 ...{t-reftable-table.c => u-reftable-table.c} |  73 +-
 14 files changed, 1117 insertions(+), 1331 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} (68%)
 rename t/unit-tests/{t-reftable-record.c => u-reftable-record.c} (62%)
 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} (75%)

Range-diff against v4:

 -:  ---------- >  1:  4a04557ae3 t/unit-tests: implement clar specific reftable test helper functions
 -:  ---------- >  2:  2c576ddd11 t/unit-tests: convert reftable basics test to use clar test framework
 -:  ---------- >  3:  04d54fef89 t/unit-tests: convert reftable block test to use clar
 -:  ---------- >  4:  06eba27f8e t/unit-tests: convert reftable merged test to use clar
 -:  ---------- >  5:  eaa8b8d636 t/unit-tests: convert reftable pq test to use clar
 1:  7c159bd2fe !  6:  cf8b0471fd t/unit-tests: convert reftable table test to use clar
    @@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable-clar.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
    -@@ Makefile: $(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 ##
     @@ t/meson.build: clar_test_suites = [
 2:  3ae3b2cf9c =  7:  cbe70c5c23 t/unit-tests: convert reftable readwrite test to use clar
 3:  d4303eb913 !  8:  38e2198eac t/unit-tests: convert reftable record test to use clar

@@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/test-lib.o

## t/meson.build ##
+@@ t/meson.build: 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-table.c',
+ 'unit-tests/u-reftable-tree.c',
+ 'unit-tests/u-strbuf.c',
@@ t/meson.build: clar_unit_tests = executable('unit-tests',
test('unit-tests', clar_unit_tests)

4: df582f6e2c ! 9: 8de9dbbd3b t/unit-tests: convert reftable stack test to use clar

    @@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
     
      ## t/meson.build ##
     @@ t/meson.build: 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-record.c',
     +  'unit-tests/u-reftable-stack.c',
        'unit-tests/u-reftable-table.c',
        'unit-tests/u-reftable-tree.c',
 5:  9340e7ce88 ! 10:  a69c3370ee t/unit-tests: finalize migration of reftable-related tests
    @@ Makefile: CLAR_TEST_SUITES += u-urlmatch-normalization
      
      # 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)
    -@@ Makefile: $(LIBGIT_HIDDEN_EXPORT): $(LIBGIT_PARTIAL_EXPORT)
    - 	$(OBJCOPY) --localize-hidden $^ $@
    - 
    - contrib/libgit-sys/libgitpub.a: $(LIBGIT_HIDDEN_EXPORT)
    --	$(AR) $(ARFLAGS) $@ $^
    - \ No newline at end of file
    -+	$(AR) $(ARFLAGS) $@ $^
     
      ## t/Makefile ##
     @@ t/Makefile: check-meson:
Signature · 1 line
2.43.0
#21 lore raw

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

From: Seyi Kuforiji <[email protected]>

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
#22 lore raw

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

In reply to Seyi Kufoiji

From: Seyi Kuforiji <[email protected]>

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
#23 lore raw

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

In reply to Seyi Kufoiji

From: Seyi Kuforiji <[email protected]>

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
#24 lore raw

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

In reply to Seyi Kufoiji

From: Seyi Kuforiji <[email protected]>

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
#25 lore raw

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

In reply to Seyi Kufoiji

From: Seyi Kuforiji <[email protected]>

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
#26 lore raw

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

In reply to Seyi Kufoiji

From: Seyi Kuforiji <[email protected]>

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

---
 Makefile                                      |  2 +-
 t/meson.build                                 |  5 +-
 ...{t-reftable-table.c => u-reftable-table.c} | 75 +++++++++----------
 3 files changed, 38 insertions(+), 44 deletions(-)
 rename t/unit-tests/{t-reftable-table.c => u-reftable-table.c} (75%)
Makefile +1 -1
index 3cccc73073..e4b90052be 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
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 +35 -40

170 lines not on this page · raw message

Signature · 1 line
2.43.0
#27 lore raw

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

In reply to Seyi Kufoiji

From: Seyi Kuforiji <[email protected]>

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} | 405 ++++++++----------
 3 files changed, 179 insertions(+), 230 deletions(-)
 rename t/unit-tests/{t-reftable-readwrite.c => u-reftable-readwrite.c} (68%)
Makefile +1 -1
index e4b90052be..1c91787b6a 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 +177 -228

959 lines not on this page · raw message

Signature · 1 line
2.43.0
#28 lore raw

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

In reply to Seyi Kufoiji

From: Seyi Kuforiji <[email protected]>

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

---
 Makefile                                      |   1 -
 t/meson.build                                 |   2 +-
 ...-reftable-record.c => u-reftable-record.c} | 250 +++++++++---------
 3 files changed, 131 insertions(+), 122 deletions(-)
 rename t/unit-tests/{t-reftable-record.c => u-reftable-record.c} (62%)
Makefile +0 -1
index 1c91787b6a..dd0bc2642d 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 +1 -1
index 5189176472..a15b396e42 100644
@@ -13,6 +13,7 @@ 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-table.c',
   'unit-tests/u-reftable-tree.c',
   'unit-tests/u-strbuf.c',
@@ -61,7 +62,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 +130 -120

454 lines not on this page · raw message

Signature · 1 line
2.43.0
#29 lore raw

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

In reply to Seyi Kufoiji

From: Seyi Kuforiji <[email protected]>

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                                 |   4 +-
 ...{t-reftable-stack.c => u-reftable-stack.c} | 780 ++++++++----------
 3 files changed, 332 insertions(+), 454 deletions(-)
 rename t/unit-tests/{t-reftable-stack.c => u-reftable-stack.c} (59%)
Makefile +1 -1
index dd0bc2642d..cbbb2ec05a 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 +1 -3
index a15b396e42..fcbb659263 100644
@@ -14,6 +14,7 @@ clar_test_suites = [
   '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',
@@ -62,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
@@ -1164,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 +330 -450

1,474 lines not on this page · raw message

Signature · 1 line
2.43.0
#30 lore raw

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

In reply to Seyi Kufoiji

From: Seyi Kuforiji <[email protected]>

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. test-lib.{c,h} remains unchanged in our build system as some files particularly t/helper/test-example-tap.c depends on it in order to run, and removing that would be beyond the scope of this patch.

---
 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 cbbb2ec05a..25e6558b7b 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 97a1348563..f4bded7d26 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 62b02baa14..54cb7fc2a7 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 d55792ca6f..f8a28f6e07 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 9aac74a011..4d8c4be5f1 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 650b0aa0d3..6c8c0d5374 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 0e3e3f4f4a..e4ea57138e 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"
@@ -497,7 +497,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 839107d8a4..14fae8b199 100644
@@ -1,5 +1,5 @@
 #include "unit-test.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
#31 lore raw
In reply to Seyi Kufoiji
Quoted 6 lines · Seyi Kufoiji

Range-diff against v4:

 -:  ---------- >  1:  4a04557ae3 t/unit-tests: implement clar specific reftable test helper functions
 -:  ---------- >  2:  2c576ddd11 t/unit-tests: convert reftable basics test to use clar test framework
 -:  ---------- >  3:  04d54fef89 t/unit-tests: convert reftable block test to use clar
 -:  ---------- >  4:  06eba27f8e t/unit-tests: convert reftable merged test to use clar
 -:  ---------- >  5:  eaa8b8d636 t/unit-tests: convert reftable pq test to use clar

Something here went wrong. :) But the remainder of the range-diff looks exactly like I'd expect it to:

- The Meson change gets moved to the correct commit.

- The missing newline got fixed up.

Thanks!

Patrick

Quoted 63 lines

1: 7c159bd2fe ! 6: cf8b0471fd t/unit-tests: convert reftable table test to use clar

    @@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable-clar.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
    -@@ Makefile: $(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 ##
     @@ t/meson.build: clar_test_suites = [
 2:  3ae3b2cf9c =  7:  cbe70c5c23 t/unit-tests: convert reftable readwrite test to use clar
 3:  d4303eb913 !  8:  38e2198eac t/unit-tests: convert reftable record test to use clar

@@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/test-lib.o

## t/meson.build ##
+@@ t/meson.build: 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-table.c',
+ 'unit-tests/u-reftable-tree.c',
+ 'unit-tests/u-strbuf.c',
@@ t/meson.build: clar_unit_tests = executable('unit-tests',
test('unit-tests', clar_unit_tests)

4: df582f6e2c ! 9: 8de9dbbd3b t/unit-tests: convert reftable stack test to use clar

    @@ Makefile: CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
     
      ## t/meson.build ##
     @@ t/meson.build: 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-record.c',
     +  'unit-tests/u-reftable-stack.c',
        'unit-tests/u-reftable-table.c',
        'unit-tests/u-reftable-tree.c',
 5:  9340e7ce88 ! 10:  a69c3370ee t/unit-tests: finalize migration of reftable-related tests
    @@ Makefile: CLAR_TEST_SUITES += u-urlmatch-normalization
      
      # 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)
    -@@ Makefile: $(LIBGIT_HIDDEN_EXPORT): $(LIBGIT_PARTIAL_EXPORT)
    - 	$(OBJCOPY) --localize-hidden $^ $@
    - 
    - contrib/libgit-sys/libgitpub.a: $(LIBGIT_HIDDEN_EXPORT)
    --	$(AR) $(ARFLAGS) $@ $^
    - \ No newline at end of file
    -+	$(AR) $(ARFLAGS) $@ $^
     
      ## t/Makefile ##
     @@ t/Makefile: check-meson:
Signature · 1 line
2.43.0
#32 lore raw
Quoted 8 lines · Patrick Steinhardt

Something here went wrong. :) But the remainder of the range-diff looks exactly like I'd expect it to:

- The Meson change gets moved to the correct commit.

- The missing newline got fixed up.

Thanks!

Looking good.

Let's mark the topic for 'next'.

Thanks, both of you.