mirror of
https://github.com/cozystack/cozystack.git
synced 2026-10-23 11:37:29 +09:00
The shell translator rewrites test bodies and loses Bats reporting. The unit lane needs complete TAP results and JUnit reports without changing how live-cluster suites run. Sourced production helpers still need a dash pass, and unit test bodies need nounset without exporting shell options into subprocesses. Assisted-by: LLM Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
38 lines
1.6 KiB
Bash
38 lines
1.6 KiB
Bash
#!/usr/bin/env bats
|
|
# Bats owns per-test parallelism; Make also schedules the non-Bats targets.
|
|
|
|
load test_helper
|
|
|
|
@test "the Bats invocation receives every discovered unit file exactly once" {
|
|
tmp=$(mktemp -d)
|
|
mkdir "$tmp/bin"
|
|
printf '%s\n' '#!/bin/sh' 'printf "%s\n" "$@" >> "$BATS_ARG_LOG"' > "$tmp/bin/bats"
|
|
chmod +x "$tmp/bin/bats"
|
|
expected=$(MAKEFLAGS= MAKELEVEL= make --no-print-directory -s print-bats-unit-files)
|
|
[ -n "$expected" ]
|
|
MAKEFLAGS= MAKELEVEL= PATH="$tmp/bin:$PATH" BATS_ARG_LOG="$tmp/args" \
|
|
make --no-print-directory -s BATS_JOBS=4 "BATS_REPORT_DIR=$tmp/reports" bats-unit-tests
|
|
actual=$(grep '^hack/.*\.bats$' "$tmp/args")
|
|
[ "$actual" = "$expected" ] || {
|
|
echo "Bats did not receive the discovered unit files exactly once" >&2
|
|
cat "$tmp/args" >&2
|
|
false
|
|
}
|
|
[ "$(sed -n '1,2p' "$tmp/args")" = "$(printf '%s\n' -j 4)" ]
|
|
rm -rf "$tmp"
|
|
}
|
|
|
|
@test "PR workflow schedules unit and controller targets with four Make jobs and -k" {
|
|
# -k is what lets test-controllers start when a unit-tests prerequisite
|
|
# fails first; without it a red Bats file hides the Go controller suite.
|
|
grep -qF 'run: make unit-tests test-controllers test-controllers-envtest -j4 -k --output-sync=target' \
|
|
.github/workflows/pull-requests.yaml || {
|
|
echo "PR checks do not use the bounded four-slot make invocation" >&2
|
|
exit 1
|
|
}
|
|
[ "$(grep -c 'run: make test-controllers' .github/workflows/pull-requests.yaml)" -eq 0 ] || {
|
|
echo "controller tests still run in a separate sequential workflow step" >&2
|
|
exit 1
|
|
}
|
|
}
|