Cotton code
27 lines · 1.7 KB · ShellRaw
#!/usr/bin/env bash# The fan's picture check (architect, 14 Oct 2026): a page's picture and the# live page that replaces it must line up, so a settled fan never jumps. On# the caller's own simulator, with the Home preview already installed# (ui-tests-stub.sh --home-preview), the fan turns to the first three tiles# that draw a page in place and compares each live page — its first frames# and once settled — with the painter's picture of it, at one pixel a point.# Fails when more than LIMIT percent of pixels differ for any of them.# usage: scripts/home-preview/check-pictures.sh <simulator udid> [limit percent, default 1.0]set -euo pipefailSIM="$1"; LIMIT="${2:-1.0}"APP=com.cottondb.homepreviewPRED='subsystem == "com.cottondb.fan" AND category == "check"'xcrun simctl terminate "$SIM" "$APP" >/dev/null 2>&1 || truexcrun simctl launch "$SIM" "$APP" -fan-picture-check >/dev/null# The check logs "done" when it has compared all three; the stream gives up# after three minutes on its own.xcrun simctl spawn "$SIM" log stream --timeout 3m --style compact --predicate "$PRED" 2>/dev/null \  | grep --line-buffered -m1 "picture check: done" >/dev/null || trueLINES="$(xcrun simctl spawn "$SIM" log show --last 4m --style compact --predicate "$PRED" 2>/dev/null \  | grep -o 'picture check: .*' || true)"echo "$LINES"WORST="$(echo "$LINES" | sed -n 's/^picture check: done worst \([0-9.]*\)%$/\1/p' | tail -1)"[ -n "$WORST" ] || { echo "check-pictures: the check never finished"; exit 2; }awk -v w="$WORST" -v l="$LIMIT" 'BEGIN { exit !(w <= l) }' \  && echo "check-pictures: worst ${WORST}% <= ${LIMIT}% — the pictures line up" \  || { echo "check-pictures: worst ${WORST}% > ${LIMIT}% — a picture does not line up with its live page"; exit 1; }