| 1 | #!/bin/sh |
| 2 | # Repeatable native engine, wire compatibility, and Apple adapter checks. |
| 3 | set -eu |
| 4 | cd "$(dirname "$0")/../.." |
| 5 | core_only=0 |
| 6 | mutations=0 |
| 7 | for argument in "$@"; do |
| 8 | case "$argument" in |
| 9 | --core-only) core_only=1 ;; |
| 10 | --mutations) mutations=1 ;; |
| 11 | *) echo "usage: $0 [--core-only] [--mutations]" >&2; exit 2 ;; |
| 12 | esac |
| 13 | done |
| 14 | if [ "$core_only" = 0 ] && [ "$(uname -s)" != Darwin ]; then |
| 15 | echo "Apple checks require macOS; use --core-only for native engine and wire checks." >&2 |
| 16 | exit 2 |
| 17 | fi |
| 18 | if [ -n "${DOCS_LLVM_LIBRARY_PATH:-}" ]; then export DYLD_LIBRARY_PATH="$DOCS_LLVM_LIBRARY_PATH"; fi |
| 19 | CARGO=${CARGO:-cargo} |
| 20 | # The apps' copy of internal/fonts (manifest and TTFs) must match it. |
| 21 | python3 native/scripts/sync-fonts.py --check |
| 22 | # A localised key with "\(…)" in it is looked up as a format ("…%lld"), |
| 23 | # finds nothing, and shows the raw key (the 0.1.9 style menu). Build such |
| 24 | # keys as a plain String first. |
| 25 | if grep -rnE 'LocalizedStringKey\("[^"]*\\\(|(Text|Label|Button)\("[^"]*\\\([^"]*", *bundle:' native/apple/Sources; then |
| 26 | echo "interpolated localisation key (see above): build the key as a String first" >&2 |
| 27 | exit 1 |
| 28 | fi |
| 29 | "$CARGO" build --locked --manifest-path native/crdt/Cargo.toml --release --target wasm32-unknown-unknown --lib |
| 30 | "$CARGO" test --locked --manifest-path native/crdt/Cargo.toml |
| 31 | "$CARGO" test --locked --manifest-path native/host/Cargo.toml |
| 32 | |
| 33 | npm ci --prefix fixtures --ignore-scripts --no-audit --no-fund |
| 34 | native_check_dir=$(mktemp -d "${TMPDIR:-/tmp}/docs-native-check.XXXXXX") |
| 35 | trap 'rm -rf "$native_check_dir"' EXIT HUP INT TERM |
| 36 | # Long documents: a 200-page document with 10,000 edits from twenty clients |
| 37 | # opens and takes typing through the bounded host on its production fuel |
| 38 | # budget (the old fixed budget refused it). Release: the interpreter is slow |
| 39 | # in a debug build. |
| 40 | node fixtures/generate-large-doc.mjs 200 "$native_check_dir/long.bin" 10000 |
| 41 | DOCS_LARGE_DOCUMENT="$native_check_dir/long.bin" "$CARGO" test --locked --release --manifest-path native/host/Cargo.toml --test sandbox -- --ignored |
| 42 | "$CARGO" run --locked --quiet --manifest-path native/crdt/Cargo.toml --bin wire_fixture -- "$native_check_dir/native.bin" |
| 43 | node fixtures/native-wire.mjs "$native_check_dir/native.bin" "$native_check_dir/browser.bin" |
| 44 | "$CARGO" run --locked --quiet --manifest-path native/crdt/Cargo.toml --bin wire_fixture -- "$native_check_dir/native.bin" "$native_check_dir/browser.bin" |
| 45 | "$CARGO" run --locked --quiet --manifest-path native/crdt/Cargo.toml --bin rule_wire_probe -- "$native_check_dir/rule" |
| 46 | node native/scripts/check-rule-wire.mjs "$native_check_dir/rule" |
| 47 | # #145: an undo-kept item under a paragraph a peer deletes is collected with |
| 48 | # it, as in Yjs. Yjs replays the native stream and snapshots (gc on and off), |
| 49 | # and the native editor reads Yjs's states back. |
| 50 | "$CARGO" run --locked --quiet --manifest-path native/crdt/Cargo.toml --bin gc_undo_kept_probe -- "$native_check_dir/gc-undo-kept" |
| 51 | node native/scripts/check-gc-undo-kept-wire.mjs "$native_check_dir/gc-undo-kept" |
| 52 | "$CARGO" run --locked --quiet --manifest-path native/crdt/Cargo.toml --bin gc_undo_kept_probe -- "$native_check_dir/gc-undo-kept" --check |
| 53 | "$CARGO" run --locked --quiet --manifest-path native/crdt/Cargo.toml --bin update_wire_probe -- "$native_check_dir/update" |
| 54 | node native/scripts/check-update-wire.mjs "$native_check_dir/update" |
| 55 | "$CARGO" run --locked --quiet --manifest-path native/crdt/Cargo.toml --bin update_wire_probe -- --browser "$native_check_dir/update" |
| 56 | if [ "$core_only" = 0 ]; then |
| 57 | native/scripts/build-crdt.sh |
| 58 | swift test --package-path native/apple |
| 59 | fi |
| 60 | if [ "$mutations" = 1 ]; then python3 native/scripts/check-mutations.py; fi |
| 61 | echo "Native checks passed (core-only=$core_only)." |
| 62 | |