AtlatestRepositorysigil-websocket

sigil-websocket / tree / scriptsrun-integration-tests.sh

1#!/usr/bin/env bash
2#
3# Run the native WebSocket integration harnesses.
4#
5# These are NOT discovered by `sigil test`, which globs test-*.sgl and so finds
6# only the unit tests. Until this script was wired into .kiln/ci.sgv the
7# integration suite never ran in CI at all -- and a gate that never runs cannot
8# fail, which is indistinguishable from a gate that always passes.
9#
10# Deliberately globs test-native-websocket-*.sh only. The wasm harness has
11# different prerequisites (binaryen, a wasm runtime) and is not wired here.
12set -u
14cd "$(dirname "$0")/.." || exit 1
16# SETUP-FAILED is a distinct outcome from a red test, and must not be reported
17# as one. These harnesses drive their servers from Node; if it is absent the
18# tests did not fail, they never ran, and saying so is the difference between
19# "the code is broken" and "this runner cannot answer the question".
21# THIS IS THE WEAKER, PRESENCE-ONLY FORM, KNOWINGLY. `command -v` answers "is
22# there a file by that name on PATH", not "can it do the job" -- a node that
23# exists but is too old passes here and fails the suite, and the red then gets
24# attributed to the code under test rather than to the toolchain. The estate's
25# golden-image bake asks the behavioural version (azoth.works
26# bin/build-golden-image.sh, `FEATURE node-global-websocket PRESENT`) and
27# refuses to promote an image that fails it.
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 a
32# behavioural arm rather than be trusted as-is.
33if ! command -v node > /dev/null 2>&1; then
34 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 1
37fi
38echo "node: $(node --version)"
40status=0
41ran=0
42for t in test/integration/test-native-websocket-*.sh; do
43 [ -f "$t" ] || continue
44 ran=$((ran + 1))
45 echo "== $t"
46 if sh "$t"; then
47 echo " ok"
48 else
49 echo " FAILED: $t"
50 status=1
51 fi
52done
54# A floor as well as a cap: a glob that matches nothing exits 0 and reads
55# exactly like a clean run. Four harnesses exist; expect to have run them.
56if [ "$ran" -lt 4 ]; then
57 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 1
60fi
62echo "integration harnesses run: $ran, status: $status"
63exit "$status"