Add a test suite and a make test target

91 black-box checks in tests/run.sh, driving the built binary because
that is the only interface the tool has. POSIX sh, no dependencies, no
framework; TAP-ish output and a non-zero exit when anything fails.

Covers the tree shapes SPEC.md section 22 asks for -- regular and empty
files, nested directories, symlinks, broken symlinks, symlinks to
directories, hard links, FIFOs, sockets, unusual filenames and permission
errors -- the parser cases from sections 14 and 15, the diff
classifications, argument handling, and the resource rules from sections
9 and 11. What the environment cannot provide is skipped, not failed.

Every bug fixed in this branch is pinned by a test: the 2^32 comparison
truncation, the symlink checksum, target-before-fingerprint ordering, the
mkstemp template unlink, errno surviving a cleanup failure, the empty
snapshot in diff, and create over each entry type that used to abort it.

Invocations run under timeout(1) where it exists. Without it a walker
regression makes create block on a FIFO forever, which hangs the suite
instead of failing it -- found by reintroducing exactly that bug.

Checked by mutation: seven deliberate regressions, one per fix, each
caught by the test written for it, with the baseline green either side.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018KyCHPAxWzqa3vHKdXJkgx
This commit is contained in:
Fabio Scotto di Santolo
2026-08-26 16:13:27 +02:00
parent 0417bd825a
commit aad607e5f0
3 changed files with 475 additions and 6 deletions

View File

@@ -40,10 +40,12 @@ SOURCES := \
src/list.c \
src/diff.c
TESTS := tests/run.sh
OBJECTS := $(SOURCES:%.c=$(BUILD_DIR)/%.o)
DEPENDENCIES := $(OBJECTS:.o=.d)
.PHONY: all clean run install uninstall
.PHONY: all clean run test install uninstall
all: $(TARGET)
@@ -57,6 +59,10 @@ $(BUILD_DIR)/%.o: %.c
run: $(TARGET)
./$(TARGET)
# Black-box: the suite drives the built binary, so it needs nothing but sh.
test: $(TARGET)
@FSNAP='$(CURDIR)/$(TARGET)' sh $(TESTS)
install: $(TARGET)
$(INSTALL) -d $(DESTDIR)$(BINDIR)
$(INSTALL) -m 755 $(TARGET) $(DESTDIR)$(BINDIR)/$(NAME)