mirror of
https://github.com/fscotto/fsnap.git
synced 2026-11-26 03:09:51 +00:00
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:
8
Makefile
8
Makefile
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user