Repository navigation
Commit 062207f
committed
test(hack): run the unit bats suite under bats(1)
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 <[email protected]>1 parent 2823b76 commit 062207f
4 files changed
Lines changed: 69 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
59 | 67 | | |
60 | 68 | | |
61 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
| 111 | + | |
110 | 112 | | |
| 113 | + | |
111 | 114 | | |
112 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
113 | 127 | | |
114 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
115 | 136 | | |
116 | 137 | | |
117 | 138 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
29 | 45 | | |
30 | 46 | | |
31 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | | - | |
154 | | - | |
155 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
156 | 163 | | |
157 | 164 | | |
158 | 165 | | |
| |||
161 | 168 | | |
162 | 169 | | |
163 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
164 | 179 | | |
165 | 180 | | |
166 | 181 | | |
167 | 182 | | |
168 | 183 | | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
173 | 190 | | |
174 | 191 | | |
175 | 192 | | |
| |||
0 commit comments