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

@@ -5,8 +5,8 @@ and records the metadata of everything it finds into a plain-text snapshot file.
> **This is a hobby project. It is not ready for production use.**
>
> It is written for learning and for personal use, has no test suite, no stable
> snapshot format, and no backwards-compatibility guarantees. Do not build a
> It is written for learning and for personal use, and has no stable snapshot
> format and no backwards-compatibility guarantees. Do not build a
> backup or auditing process on top of it. Several rough edges are known and
> listed under [Known limitations](#known-limitations) — read that section
> before using it on anything you care about.
@@ -40,6 +40,14 @@ make # produces build/fsnap
make clean
```
`make test` runs the suite in [tests/run.sh](tests/run.sh): 91 black-box checks
driving the built binary over the tree shapes [SPEC.md](SPEC.md) §22 asks for —
regular and empty files, nested directories, symlinks, broken symlinks, hard
links, FIFOs, sockets, unusual filenames and permission errors — plus the
parser cases from §14 and §15 and the `diff` classifications. It is POSIX sh
with no dependencies, and skips rather than fails what the environment cannot
provide.
`make install` copies the binary to `$(BINDIR)`, which defaults to
`/usr/local/bin`; `make uninstall` removes it again. Both honour `DESTDIR` for
staged installs:
@@ -195,8 +203,6 @@ These are actual, reproduced problems, not hypotheticals:
- **`list` counts the lines in a separate pass over the file.** If the snapshot
grows between the counting pass and the parsing pass, the records past the
original count are silently ignored and `list` still exits `0`.
- **No test suite.** There is currently no `tests/` directory or automated
coverage for the tree shapes listed in [SPEC.md](SPEC.md) §22.
## Roadmap
@@ -218,7 +224,6 @@ Rough order of intent, no timeline:
filesystem, distinguishing `ENOENT`, `EACCES`, `ENOTDIR` and `ELOOP`
rather than collapsing them ([SPEC.md](SPEC.md) §18).
- [ ] Honour `TMPDIR` instead of hardcoding `/tmp`.
- [ ] Add a test suite and wire it into the `Makefile`.
## License