dymokomi/luce-browser-engine
Source of release 0.6.0
0.6.0 / test.sh
#!/bin/sh
# Type-check every module of luce-browser-engine with warnings as errors, then run the unit tests
# of every module. Stops at the first failing step.
set -e
cd "$(dirname "$0")"
# Every hand-written fragment is laid out as the pinned compiler's formatter lays it out (the
# skeleton generator's types_* and stubs/ fragments are not).
echo "== luce-base fmt --check"
for file in $(git ls-files '*.lucb' | grep -v -e '/types_' -e '/stubs/' -e '/generated'); do
luce-base fmt "$file" --check > /dev/null || { echo "$file is not formatted (luce-base fmt $file --write)"; exit 1; }
done
for module in src/web src/webview src/webview_api tools/gen_css_values tools/embed_css tools/gen_dom_tree tools/gen_aria_roles tools/site_sweep tests/web_test; do
echo "== luce-base check $module -W"
# -W makes any warning fail the check, so any output at all fails the run, except warnings in
# the code of another package (luce-png and luce-raster, which web_test uses, have some at
# their pinned commits; they are theirs to fix): those are shown, and the module must then
# check without -W.
status=0
output=$(luce-base check "$module" -W 2>&1) || status=$?
pattern='^luce-base: luce_[a-z_]+/src/[^ ]*: warning: '
dependency_warnings=$(printf '%s\n' "$output" | grep -E "$pattern" || true)
output=$(printf '%s\n' "$output" | grep -v -E "$pattern" || true)
if [ -n "$output" ]; then
echo "$output"
exit 1
fi
if [ "$status" -ne 0 ]; then
[ -n "$dependency_warnings" ] || exit 1
printf '%s\n' "$dependency_warnings" | sed 's/^/(another package) /'
luce-base check "$module"
fi
done
# Unit tests (the regions' `tests_*` fragments). `luce-base test MODULE` runs the tests of MODULE
# and of every module of the package it imports, in one process: src/webview's run web's too, under
# the default profile and then the diagnostic one (see web_test below); tests/web_test's, which
# imports web but not webview, run web's a third time.
for profile in default diagnostic; do
echo "== luce-base test src/webview --profile $profile"
luce-base test src/webview --profile "$profile"
done
echo "== luce-base test tests/web_test"
luce-base test tests/web_test
# The value-dependent generated fragments (web/generated/math_functions.lucb, ...) are written by
# tools/gen_css_values from data/css, the embedded style sheets (web/generated/*_style_sheet_source.lucb)
# by tools/embed_css; regenerate them and compare with the committed ones.
echo "== tools/gen_css_values, tools/embed_css: regenerate web/generated's CSS fragments and compare"
mkdir -p build
generated=$(mktemp -d)
trap 'rm -rf "$generated"' EXIT
luce-base build tools/gen_css_values -o build/gen_css_values
build/gen_css_values data/css "$generated"
luce-base build tools/embed_css -o build/embed_css
build/embed_css data/css "$generated"
for file in "$generated"/*.lucb; do
cmp "$file" "src/web/generated/$(basename "$file")"
done
# The DOM of the media controls (web/generated/html/media_controls_dom.lucb) is written by
# tools/gen_dom_tree from data/html/MediaControls.html and the engine's tag and attribute names.
echo "== tools/gen_dom_tree: regenerate web/generated/html/media_controls_dom.lucb and compare"
mkdir -p "$generated/html"
luce-base build tools/gen_dom_tree -o build/gen_dom_tree
build/gen_dom_tree data/html src/web "$generated/html"
cmp "$generated/html/media_controls_dom.lucb" src/web/generated/html/media_controls_dom.lucb
# The ARIA role classes' functions (web/generated/aria/aria_roles.lucb) are written by
# tools/gen_aria_roles from data/aria/AriaRoles.json.
echo "== tools/gen_aria_roles: regenerate web/generated/aria/aria_roles.lucb and compare"
mkdir -p "$generated/aria"
luce-base build tools/gen_aria_roles -o build/gen_aria_roles
build/gen_aria_roles data/aria "$generated/aria"
cmp "$generated/aria/aria_roles.lucb" src/web/generated/aria/aria_roles.lucb
# Ladybird's Layout, Ref, Crash and Screenshot tests (the copy in tests/libweb) through the headless runner,
# one worker process per test, against tests/expected_failures: an unexpected failure or an
# unexpected pass fails the run (DESIGN.md ยง6). After a change that makes tests pass or fail,
# review build/web_test_results and run `build/web_test --update-failures`.
echo "== web_test layout ref crash screenshot"
# The diagnostic profile fills `---` storage with 0xaa and checks frees, so a read of a field nobody
# wrote fails every time its path runs instead of depending on what the stack held (5141632).
luce-base build tests/web_test -o build/web_test --profile diagnostic
build/web_test layout ref crash screenshot