test(tests): run backported Bats suites under bats-core

Fixes picked from main now bring unit suites written for bats-core:
they load hack/test_helper.bash and rely on Bats calling setup() and
setting BATS_TEST_TMPDIR. release-1.6 runs every hack/*.bats through
cozytest.sh, which has no load, so such a suite fails with
"load: not found" and keeps the backport batch red.

Main moved every unit suite to Bats in #3849, which also edited each
existing suite. Only the runner part comes over here: the helper, the
pinned bats-core install in the checks job, and a bats-unit-tests
target that runs the suites loading the helper under bats. The other
suites keep running through cozytest.sh under /bin/sh and nounset, so
the 49 suites release-1.6 has today run exactly as before, and the 13
of them that source production shell scripts keep their dash coverage.

Tested with make bats-unit-tests and dash as the recipe shell, on
release-1.6 alone (49 suites, 527 tests through cozytest.sh, none
under bats, the same as before) and with the open backport batch and
its conflict resolutions on top (50 suites, 532 tests through
cozytest.sh, 10 suites, 73 tests under bats, all passing).

Refs: #3849
Assisted-By: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
This commit is contained in:
Myasnikov Daniil committed 2026-11-26 11:29:41 +00:00
1 parent cf4d2d85f7
commit 186106d2e9
3 files changed
+45 -5

No files matched your search

+15 -1
View File
@@ -205,11 +205,25 @@ jobs:
with:
fetch-depth: 0
# Ephemeral runners don't carry the helm-unittest plugin the persistent
# self-hosted runner accreted. Install if absent (idempotent).
# self-hosted runner accreted. Install if absent (idempotent). bats-core
# runs the unit suites that load hack/test_helper.bash; pinned like on
# main, and the tag's commit is verified because archive bytes can change.
- name: Set up test toolchain
env:
BATS_VERSION: "1.14.0"
BATS_COMMIT: eb7f42f8d608ac693d7a4b67474f6714ea68cfc5
run: |
helm plugin list 2>/dev/null | grep -q unittest \
|| helm plugin install https://github.com/helm-unittest/helm-unittest
if ! bats --version 2>/dev/null | grep -qx "Bats $BATS_VERSION"; then
bats_parent=$(mktemp -d "$RUNNER_TEMP/bats-core.XXXXXX")
bats_source="$bats_parent/source"
git clone --quiet --depth=1 --branch "v$BATS_VERSION" \
https://github.com/bats-core/bats-core.git "$bats_source"
test "$(git -C "$bats_source" rev-parse HEAD)" = "$BATS_COMMIT"
sudo "$bats_source/install.sh" /usr/local
fi
bats --version | grep -qx "Bats $BATS_VERSION"
- name: Run unit tests
run: make unit-tests
- name: Run controller Go tests