Merge branch 'sk/reftable-clarify-tests'
authorJunio C Hamano <gitster@pobox.com>
Fri, 1 Aug 2025 18:27:14 +0000 (1 11:27 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 1 Aug 2025 18:27:14 +0000 (1 11:27 -0700)
The reftable unit tests are now ported to the "clar" unit testing
framework.

* sk/reftable-clarify-tests:
  t/unit-tests: finalize migration of reftable-related tests
  t/unit-tests: convert reftable stack test to use clar
  t/unit-tests: convert reftable record test to use clar
  t/unit-tests: convert reftable readwrite test to use clar
  t/unit-tests: convert reftable table test to use clar
  t/unit-tests: convert reftable pq test to use clar
  t/unit-tests: convert reftable merged test to use clar
  t/unit-tests: convert reftable block test to use clar
  t/unit-tests: convert reftable basics test to use clar test framework
  t/unit-tests: implement clar specific reftable test helper functions

1  2 
Makefile
t/meson.build

diff --combined Makefile
+++ b/Makefile
@@@ -114,6 -114,8 +114,6 @@@ include shared.ma
  #
  # Define NO_INTPTR_T if you don't have intptr_t or uintptr_t.
  #
 -# Define NO_UINTMAX_T if you don't have uintmax_t.
 -#
  # Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
  # Patrick Mauritz).
  #
@@@ -1083,8 -1085,8 +1083,8 @@@ LIB_OBJS += notes.
  LIB_OBJS += object-file-convert.o
  LIB_OBJS += object-file.o
  LIB_OBJS += object-name.o
 -LIB_OBJS += object-store.o
  LIB_OBJS += object.o
 +LIB_OBJS += odb.o
  LIB_OBJS += oid-array.o
  LIB_OBJS += oidmap.o
  LIB_OBJS += oidset.o
@@@ -1362,30 -1364,27 +1362,28 @@@ CLAR_TEST_SUITES += u-oid-arra
  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-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
  CLAR_TEST_SUITES += u-strcmp-offset
 +CLAR_TEST_SUITES += u-string-list
  CLAR_TEST_SUITES += u-strvec
  CLAR_TEST_SUITES += u-trailer
  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.o
+ CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.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
- 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
  
  # 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)
@@@ -1917,6 -1916,9 +1915,6 @@@ endi
  ifdef NO_INTPTR_T
        COMPAT_CFLAGS += -DNO_INTPTR_T
  endif
 -ifdef NO_UINTMAX_T
 -      BASIC_CFLAGS += -Duintmax_t=uint32_t
 -endif
  ifdef NO_SOCKADDR_STORAGE
  ifdef NO_IPV6
        BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in
@@@ -3469,14 -3471,11 +3467,14 @@@ endi
  coccicheck-test: $(COCCI_TEST_RES_GEN)
  
  coccicheck: coccicheck-test
 +
  ifdef SPATCH_CONCAT_COCCI
 -coccicheck: contrib/coccinelle/ALL.cocci.patch
 +COCCICHECK_PATCH_MUST_BE_EMPTY_FILES = contrib/coccinelle/ALL.cocci.patch
  else
 -coccicheck: $(COCCICHECK_PATCHES_INTREE)
 +COCCICHECK_PATCH_MUST_BE_EMPTY_FILES = $(COCCICHECK_PATCHES_INTREE)
  endif
 +coccicheck: $(COCCICHECK_PATCH_MUST_BE_EMPTY_FILES)
 +      ! grep -q ^ $(COCCICHECK_PATCH_MUST_BE_EMPTY_FILES) /dev/null
  
  # See contrib/coccinelle/README
  coccicheck-pending: coccicheck-test
diff --combined t/meson.build
@@@ -8,10 -8,17 +8,18 @@@ 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-block.c',
+   'unit-tests/u-reftable-merged.c',
+   'unit-tests/u-reftable-pq.c',
+   'unit-tests/u-reftable-readwrite.c',
+   'unit-tests/u-reftable-record.c',
+   'unit-tests/u-reftable-stack.c',
+   'unit-tests/u-reftable-table.c',
    'unit-tests/u-reftable-tree.c',
    'unit-tests/u-strbuf.c',
    'unit-tests/u-strcmp-offset.c',
 +  'unit-tests/u-string-list.c',
    'unit-tests/u-strvec.c',
    'unit-tests/u-trailer.c',
    'unit-tests/u-urlmatch-normalization.c',
@@@ -20,7 -27,8 +28,8 @@@
  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.c'
  ]
  
  clar_decls_h = custom_target(
@@@ -52,35 -60,8 +61,8 @@@ clar_unit_tests = executable('unit-test
    sources: clar_sources + clar_test_suites,
    dependencies: [libgit_commonmain],
  )
 -test('unit-tests', clar_unit_tests)
 +test('unit-tests', clar_unit_tests, kwargs: test_kwargs)
  
- 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',
-   '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
-   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(),
-     kwargs: test_kwargs,
-   )
- endforeach
  subdir('helper')
  
  integration_tests = [
    't0060-path-utils.sh',
    't0061-run-command.sh',
    't0062-revision-walking.sh',
 -  't0063-string-list.sh',
    't0066-dir-iterator.sh',
    't0067-parse_pathspec_file.sh',
    't0068-for-each-repo.sh',
    't1015-read-index-unmerged.sh',
    't1016-compatObjectFormat.sh',
    't1020-subdirectory.sh',
 -  't1021-rerere-in-workdir.sh',
    't1022-read-tree-partial-clone.sh',
    't1050-large.sh',
    't1051-large-conversion.sh',
@@@ -1116,7 -1099,6 +1098,7 @@@ benchmarks = 
    'perf/p1450-fsck.sh',
    'perf/p1451-fsck-skip-list.sh',
    'perf/p1500-graph-walks.sh',
 +  'perf/p1501-rev-parse-oneline.sh',
    'perf/p2000-sparse-operations.sh',
    'perf/p3400-rebase.sh',
    'perf/p3404-rebase-interactive.sh',
  # 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,
@@@ -1212,7 -1192,7 +1192,7 @@@ foreach integration_test : integration_
      workdir: meson.current_source_dir(),
      env: test_environment,
      depends: test_dependencies + bin_wrappers,
 -    timeout: 0,
 +    kwargs: test_kwargs,
    )
  endforeach
  
@@@ -1231,4 -1211,4 +1211,4 @@@ if perl.found() and time.found(
        timeout: 0,
      )
    endforeach
- endif
+ endif