AtlatestRepositorysigil-websocket
sigil-websocket / tree / scriptsrun-integration-tests.sh
1
#!/usr/bin/env bash2
#3
# Run the native WebSocket integration harnesses.4
#5
# These are NOT discovered by `sigil test`, which globs test-*.sgl and so finds6
# only the unit tests. Until this script was wired into .kiln/ci.sgv the7
# integration suite never ran in CI at all -- and a gate that never runs cannot8
# fail, which is indistinguishable from a gate that always passes.9
#10
# Deliberately globs test-native-websocket-*.sh only. The wasm harness has11
# different prerequisites (binaryen, a wasm runtime) and is not wired here.12
set -u14
cd "$(dirname "$0")/.." || exit 116
# SETUP-FAILED is a distinct outcome from a red test, and must not be reported17
# as one. These harnesses drive their servers from Node; if it is absent the18
# tests did not fail, they never ran, and saying so is the difference between19
# "the code is broken" and "this runner cannot answer the question".20
#21
# THIS IS THE WEAKER, PRESENCE-ONLY FORM, KNOWINGLY. `command -v` answers "is22
# there a file by that name on PATH", not "can it do the job" -- a node that23
# exists but is too old passes here and fails the suite, and the red then gets24
# attributed to the code under test rather than to the toolchain. The estate's25
# golden-image bake asks the behavioural version (azoth.works26
# bin/build-golden-image.sh, `FEATURE node-global-websocket PRESENT`) and27
# refuses to promote an image that fails it.28
#29
# Presence is adequate *here* because these four harnesses use only node:30
# builtins and child_process.spawn -- no global WebSocket, no modern-only API.31
# If a harness is ever added that needs more, this check must grow a32
# behavioural arm rather than be trusted as-is.33
if ! command -v node > /dev/null 2>&1; then34
echo "SETUP-FAILED: node is not on PATH, so the integration harnesses cannot run."35
echo " These tests did NOT fail -- they did not execute. Do not read this as a pass."36
exit 137
fi38
echo "node: $(node --version)"40
status=041
ran=042
for t in test/integration/test-native-websocket-*.sh; do43
[ -f "$t" ] || continue44
ran=$((ran + 1))45
echo "== $t"46
if sh "$t"; then47
echo " ok"48
else49
echo " FAILED: $t"50
status=151
fi52
done54
# A floor as well as a cap: a glob that matches nothing exits 0 and reads55
# exactly like a clean run. Four harnesses exist; expect to have run them.56
if [ "$ran" -lt 4 ]; then57
echo "SETUP-FAILED: matched $ran integration harnesses, expected at least 4."58
echo " An empty or partial glob passes for free; refusing to report success."59
exit 160
fi62
echo "integration harnesses run: $ran, status: $status"63
exit "$status"