NEXT.md prints the banner with the restarts in source order; the walk is innermost-first, so it is the other way round. A --dev build under timeout is enough to settle that, and settles the two place and global snippets with it.
59 lines
2.1 KiB
Bash
59 lines
2.1 KiB
Bash
#!/bin/sh
|
|
# Every Flan program shown on index.html is in this directory, and this script
|
|
# runs all of them and compares what they print against the .out file beside
|
|
# them. An example that does not compile is worse than no example, so the page
|
|
# quotes only what this script has been green on.
|
|
#
|
|
# $ dune build && sh web/examples/check.sh
|
|
#
|
|
# FLAN overrides the compiler; the default is the one dune just built.
|
|
here=$(cd "$(dirname "$0")" && pwd)
|
|
root=$(cd "$here/../.." && pwd)
|
|
FLAN=${FLAN:-$root/_build/default/bin/main.exe}
|
|
tmp=${TMPDIR:-/tmp}/flan-web-check.$$
|
|
|
|
cd "$here" || exit 1
|
|
fail=0
|
|
ok() { echo "ok $1"; }
|
|
bad() { echo "FAIL $1"; fail=1; }
|
|
|
|
for f in *.flan; do
|
|
# Two programs are not run by `flan run`; each is checked its own way below.
|
|
[ "$f" = shimdemo.flan ] && continue # calls raylib
|
|
[ "$f" = breakdemo.flan ] && continue # stops and waits, on purpose
|
|
got=$( { "$FLAN" run "$f"; echo "exit $?"; } 2>&1 )
|
|
if [ "$got" = "$(cat "${f%.flan}.out")" ]; then ok "$f"; else
|
|
bad "$f"
|
|
printf '%s\n' "$got" | diff -u "${f%.flan}.out" - || true
|
|
fi
|
|
done
|
|
|
|
# shimdemo.flan is the declare-c example: what it demonstrates is the C the
|
|
# compiler writes, so it is checked by generating that rather than by running.
|
|
if "$FLAN" shim shimdemo.flan | grep -q 'GetMousePosition(void)'; then
|
|
ok "shimdemo.flan (flan shim)"
|
|
else
|
|
bad "shimdemo.flan (flan shim)"
|
|
fi
|
|
|
|
# breakdemo.flan is the break loop: an unhandled error stops the program and
|
|
# waits for someone to pick a restart, so it never exits on its own. It needs
|
|
# a --dev build (the hook lives in vendor/agent) and it is killed after a few
|
|
# seconds; what is checked is the banner it printed before it stopped.
|
|
if command -v timeout >/dev/null 2>&1; then
|
|
if "$FLAN" build breakdemo.flan --dev -o "$tmp" >/dev/null 2>&1; then
|
|
got=$(timeout 5 "$tmp" 2>&1)
|
|
rm -f "$tmp"
|
|
if [ "$got" = "$(cat breakdemo.out)" ]; then ok "breakdemo.flan (break loop)"; else
|
|
bad "breakdemo.flan (break loop)"
|
|
printf '%s\n' "$got" | diff -u breakdemo.out - || true
|
|
fi
|
|
else
|
|
bad "breakdemo.flan (build --dev)"
|
|
fi
|
|
else
|
|
echo "skip breakdemo.flan (no timeout(1))"
|
|
fi
|
|
|
|
exit $fail
|