PureXML/scripts/check-wasm.sh
Mihaela Mihaljevic ac85dd36de feat(xpath,xslt,wasm): evaluation budget, tailored collation, WASI runtime proof
PureXML.XPath.Budget is the configurable counterpart of libxml2's
fixed 10M node-set cap (libxml2Compatible preset included), thrown as
a located QueryError instead of a silent refusal, default unbounded.
xsl:sort honors lang with tailored alphabet orders for Polish and
Russian derived from the conformance golds, case-folded. The WASM
gate executes all 985 tests under wasmtime on an actual WASI runtime,
wired into CI; the first run caught a real wasm32 trap (Int is 32
bits there, so format-number's digit extraction trapped at 2^31
despite the 2^53 guard; internals are now Int64 and the xsl:number
bound is platform-correct). Xalan baseline 127 -> 125. Closes #143,
closes #144.
2026-06-11 06:26:13 +02:00

40 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
SDK_ID="${SWIFT_WASM_SDK_ID:-swift-6.3.2-RELEASE_wasm}"
SWIFT_SELECTOR="${SWIFT_WASM_SWIFT_SELECTOR:-+6.3.2}"
swift_command() {
if command -v swiftly >/dev/null 2>&1; then
swiftly run swift "$@" "$SWIFT_SELECTOR"
else
swift "$@"
fi
}
if ! swift_command sdk list | grep -qx "$SDK_ID"; then
echo "wasm: missing Swift SDK '$SDK_ID'" >&2
echo "wasm: install the SDK or set SWIFT_WASM_SDK_ID" >&2
exit 2
fi
swift_command build --swift-sdk "$SDK_ID"
swift_command build -c release --swift-sdk "$SDK_ID"
# Runtime proof (#144): when wasmtime is available, the full test suite
# executes on an actual WASI runtime; the first such run caught a real
# wasm32 trap (32-bit Int conversion in format-number). Build-only when
# wasmtime is absent, with a notice.
if command -v wasmtime >/dev/null 2>&1; then
swift_command build --build-tests --swift-sdk "$SDK_ID"
TEST_BINARY="$(ls .build/wasm32-*/debug/*PackageTests.xctest 2>/dev/null | head -1)"
if [ -n "$TEST_BINARY" ]; then
wasmtime run --dir . "$TEST_BINARY" --testing-library swift-testing
else
echo "wasm: test binary not found; skipping runtime execution" >&2
fi
else
echo "wasm: wasmtime not installed; build-only (install wasmtime for the runtime proof)" >&2
fi