mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-03 02:27:01 +09:00
hack/cozytest.sh serves two populations that want opposite things from a runner: 32 hermetic unit tests of hack/*.sh, and 3 live-cluster imperative tests. This moves the unit half to real bats and leaves the live half where it is; the hack/e2e-*.bats filter already in BATS_UNIT_FILES is what keeps them apart. The unit files need no edits. They pass under vanilla bats 1.13 unchanged because their authors wrote to the intersection of both runners -- no run, no $status, no skip, repo-root-relative paths. Measured on this tree: 328 tests, 0 failures, 26s under `bats -j 8` against cozytest's 63s serial. What this buys, none of which cozytest offers: --filter-status failed to rerun only the previous failures, JUnit so CI annotates the failing test instead of requiring a log read, -j, and deletion of a bespoke awk parser whose rewrite rules void helper exit codes, corrupt heredoc fixtures on a column-0 brace, and collide test names after sanitization. Two consequences worth naming, neither covered by the issue: bats is a new dependency. cozytest is pure bash+awk, so no runner image or contributor machine has ever needed anything else. The checks job installs it from a pinned tag rather than the distro package, whose version varies by base image, and the make target says so plainly when it is absent. GNU parallel stays optional -- BATS_JOBS resolves to 1 without it, since `bats -j` exits non-zero rather than degrading. The pre-commit lane is the second consumer and does NOT get bats. That job lints changed YAML and Markdown on a runner with no bats, and the new hook's path filter covers .github/workflows/, so a workflow edit would drag the whole 328-test shell suite into a lint lane and duplicate the checks job that already runs `make unit-tests`. It is skipped there by id, keeping the hook a local-developer gate. The tested shell changes. cozytest is #!/bin/sh, which is dash on the CI runner, and bats runs bash. Seven POSIX scripts that tests source rather than execute -- seaweedfs-naming-audit.sh, promote-rewrite-tags.sh, lib/image-refs.sh, the three e2e-capture scripts and cozystack-version.sh -- therefore lose a runtime dash check they had by accident. Four shell=bash files under e2e-chainsaw/_lib gain correct fidelity for the same reason. The static replacement is the shellcheck gate in item 5 of #3453, which does not exist yet. set -u is not restored here. bats enforces -e but not -u, and there is no runner-level way to inject it: --setup-suite-file does not reach test files, and SHELLOPTS=nounset is exported, so it leaks into the scripts under test and drops two tests. Restoring it needs a per-file load and is the layer above this one. Refs: #3453 Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>