joeylib2/scripts/verify-web-tilebank.sh
2026-10-13 14:01:46 -05:00

44 lines
1.5 KiB
Bash
Executable file

#!/usr/bin/env bash
# Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License.
# See LICENSE.md for license information.
# SPDX-License-Identifier: MIT
#
# verify-web-tilebank.sh - Tile-bank gate for the web port: proves the web
# build loads the DOS bake (its stage is the same chunky 4bpp) exactly and
# refuses a bank baked for any other target.
#
# Runs TILEBANK's page (examples/tilebank, its DATA/tilebank packed into
# TILEBANK.data by make/web.mk) in headless Chromium through
# scripts/lib/webDriver.mjs. Its TILEBANK line in joeylog.txt must say PASS
# with both hashes equal to the host gate's and every other target refused
# (scripts/lib/tileBankGate.sh).
#
# Usage: scripts/verify-web-tilebank.sh
# Requires: a host cc, Chromium, emsdk's node; build/web/bin/TILEBANK (make web).
set -uo pipefail
repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
source "$repo/scripts/lib/joeyEnv.sh"
source "$repo/scripts/lib/tileBankGate.sh"
source "$repo/scripts/lib/webGate.sh"
webNeed
dir=$repo/build/web/bin/TILEBANK
lineSeconds=60
tileBankNeedBuild "$dir/TILEBANK.html" "$dir/DATA/tilebank" "make web"
tileBankReference
work=$(mktemp -d -t joeylib-web-tilebank.XXXXXX)
cleanup() {
webStop
rm -rf "$work"
}
trap cleanup EXIT
webServe "$dir"
if ! webDrive "TILEBANK.html" --seconds "$lineSeconds" --until "TILEBANK: " --log "$work/joeylog.txt"; then
echo "verify-web-tilebank: FAIL - no TILEBANK line within ${lineSeconds}s" >&2
exit 1
fi
tileBankJudge "$work/joeylog.txt"