| 1 | #!/bin/sh |
| 2 | # Base's screenshot gate (rastrillo/native RastrilloSnapshots): the look |
| 3 | # (the sky at its still pose, the surfaces, the type scale, the marks) and |
| 4 | # Ask (the mockups' thread, its states and cards), light and dark, and on |
| 5 | # iPhone at the default size and AX3. |
| 6 | # |
| 7 | # native/scripts/snapshots.sh [compare|record] [mac|iphone|all] |
| 8 | # |
| 9 | # compare (the default) fails on any changed, missing or stale picture; |
| 10 | # record redraws the baselines in apple/Tests/BaseSnapshots/__Snapshots__/. |
| 11 | # Review the contact sheets, apple/.build/snapshots/base-*/index.html, |
| 12 | # before committing a recording, beside the approved mockups |
| 13 | # (.superpowers/mockups/native/, git-ignored). |
| 14 | # |
| 15 | # Not in .amadan/ci.d: baselines are exact only on the OS and simulator |
| 16 | # runtime that drew them (ENVIRONMENT beside them says which). The runner |
| 17 | # scripts are rastrillo/native's own, from the pinned checkout; the iPhone |
| 18 | # half runs on its "Rastrillo Snapshots" simulator under its lock. Drawn |
| 19 | # with Timeless Sans when `make fonts` has fetched it; a run without it |
| 20 | # draws DM Sans, and fails against baselines drawn in Timeless. |
| 21 | set -eu |
| 22 | cd "$(dirname "$0")/.." |
| 23 | mode=${1:-compare} |
| 24 | platforms=${2:-all} |
| 25 | case "$mode" in compare|record) ;; *) echo "usage: $0 [compare|record] [mac|iphone|all]" >&2; exit 2 ;; esac |
| 26 | case "$platforms" in mac|iphone|all) ;; *) echo "usage: $0 [compare|record] [mac|iphone|all]" >&2; exit 2 ;; esac |
| 27 | scripts/fonts-into-bundle.sh |
| 28 | swift package --package-path apple resolve |
| 29 | shared=${OFICINA_NATIVE_PACKAGE_PATH:-apple/.build/checkouts/native} |
| 30 | case "$shared" in /*) ;; *) shared="$(pwd)/$shared" ;; esac |
| 31 | tools="$shared/tools" |
| 32 | |
| 33 | failed=0 |
| 34 | case "$platforms" in mac|all) |
| 35 | (cd apple && swift build --build-tests) |
| 36 | if ! (cd apple && "$tools/snapshots-mac.sh" "$mode" BaseSnapshots); then failed=1; fi ;; |
| 37 | esac |
| 38 | case "$platforms" in iphone|all) |
| 39 | xcodegen generate --spec ios/project.yml |
| 40 | if ! (cd apple && SNAPSHOT_DERIVED_DATA=.build/xcode "$tools/snapshots-iphone.sh" "$mode" BasePhoneSnapshots BasePhoneSnapshots \ |
| 41 | -project ../ios/BasePhone.xcodeproj -test-timeouts-enabled YES -default-test-execution-time-allowance 120); then |
| 42 | failed=1 |
| 43 | fi ;; |
| 44 | esac |
| 45 | exit "$failed" |
| 46 | |