Run make try against a temporary directory (closes #12)
check / check (push) Successful in 3m36s

`make try` ran against a fixed directory on one person's machine. It
failed for anyone else, and where that directory existed it rewrote the
checksum attributes and modification times of real files.

It now writes three small files into a new directory from `mktemp -d`,
runs the same sequence of commands on it, and removes it with an EXIT
trap. All steps run in one shell, so the trap also removes the
directory when a step fails.

`TODO.md`: the `try` sentence leaves Next Step and is recorded under
Completed Steps.

Model: opus-5-5
This commit was merged in pull request #14.
This commit is contained in:
2026-10-06 01:59:55 +02:00
parent 9f3af05c91
commit 6a0dfa9f2c
2 changed files with 22 additions and 14 deletions
+18 -11
View File
@@ -1,7 +1,5 @@
.PHONY: default bootstrap setup test lint fmt fmt-check check docker hooks build clean try
TESTDIR := $(HOME)/Documents/_SYSADMIN/cyberdyne
# The version `make build` stamps into the binary: the git tag or short
# commit, -dirty with uncommitted changes. `make build VERSION=x` stamps x,
# which is how the Dockerfile passes its version in.
@@ -45,13 +43,22 @@ build: clean
clean:
@rm -f attrsum
# Runs the binary on three small files in a new temporary directory, which
# the trap removes when the recipe ends, also when a step fails. The check
# after clear is expected to fail, so its exit status is ignored.
try: build
./attrsum sum add -v $(TESTDIR)
./attrsum check -v $(TESTDIR)
./attrsum clear -v $(TESTDIR)
-./attrsum check -v $(TESTDIR)
./attrsum sum add -v $(TESTDIR)
./attrsum check -v $(TESTDIR)
touch $(TESTDIR)/*
./attrsum sum update -v $(TESTDIR)
./attrsum check -v $(TESTDIR)
@set -ex; \
dir=$$(mktemp -d); \
trap 'rm -rf "$$dir"' EXIT; \
echo one >"$$dir/a"; \
echo two >"$$dir/b"; \
echo three >"$$dir/c"; \
./attrsum sum add -v "$$dir"; \
./attrsum check -v "$$dir"; \
./attrsum clear -v "$$dir"; \
./attrsum check -v "$$dir" || true; \
./attrsum sum add -v "$$dir"; \
./attrsum check -v "$$dir"; \
touch "$$dir"/*; \
./attrsum sum update -v "$$dir"; \
./attrsum check -v "$$dir"