Copying a snippet into HTML is where a documented language stops being the real one. Each block on the page is a program here with its recorded output beside it, and check.sh is what says the page is still true after a change.
38 lines
1.2 KiB
Bash
38 lines
1.2 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}
|
|
|
|
cd "$here" || exit 1
|
|
fail=0
|
|
for f in *.flan; do
|
|
# shimdemo.flan calls raylib, so it is not run. What it demonstrates is the
|
|
# C the compiler writes, which is checked below by generating that instead.
|
|
[ "$f" = shimdemo.flan ] && continue
|
|
got=$( { "$FLAN" run "$f"; echo "exit $?"; } 2>&1 )
|
|
if [ "$got" = "$(cat "${f%.flan}.out")" ]; then
|
|
echo "ok $f"
|
|
else
|
|
echo "FAIL $f"
|
|
printf '%s\n' "$got" | diff -u "${f%.flan}.out" - || true
|
|
fail=1
|
|
fi
|
|
done
|
|
|
|
if "$FLAN" shim shimdemo.flan | grep -q 'GetMousePosition(void)'; then
|
|
echo "ok shimdemo.flan (flan shim)"
|
|
else
|
|
echo "FAIL shimdemo.flan (flan shim)"
|
|
fail=1
|
|
fi
|
|
|
|
exit $fail
|