SPB Git

Repository Public

recovery-test.sh 1.5 KB 28 lines shellscript

1#!/bin/bash2# ORIX Docs3# File: Scripts/recovery-test.sh4# Description: Crash-recovery check. Types into a saved document through real key events, waits for autosave in place, kills the5#              process with SIGKILL (no chance to save), then reopens the file and compares its text. Prints PASS or FAIL.6#7# Author: Simon-Pierre Boucher8# Contact: contact@spboucher.ai9set -uo pipefail10cd "$(dirname "$0")/.."11APP="${ORIX_APP:-build/DerivedData/Build/Products/Debug/ORIX Docs.app}/Contents/MacOS/ORIX Docs"12WORK="$(mktemp -d)"; DOC="$WORK/recovery.orixdoc"; OUT="$WORK/text.txt"13COMMON=(-ApplePersistenceIgnoreState YES -checkSpelling NO -AppleLanguages "(en)")14"$APP" "${COMMON[@]}" -ORIXTemplate blank -ORIXSaveTo "$DOC" -ORIXSnapshot "$WORK/s.png" -ORIXSnapshotDelay 2.5 >/dev/null 2>&115[[ -f "$DOC" ]] || { echo "FAIL: the document was not created"; exit 1; }16BEFORE=$(shasum -a 256 "$DOC" | cut -d' ' -f1)17"$APP" "${COMMON[@]}" -ORIXOpen "$DOC" -ORIXAutosaveDelay 2 -ORIXType "Unsaved but recoverable 42" >/dev/null 2>&1 &18PID=$!19sleep "${ORIX_RECOVERY_WAIT:-9}"20kill -9 "$PID" 2>/dev/null; wait "$PID" 2>/dev/null21AFTER=$(shasum -a 256 "$DOC" | cut -d' ' -f1)22"$APP" "${COMMON[@]}" -ORIXOpen "$DOC" -ORIXDumpText "$OUT" >/dev/null 2>&123TEXT="$(cat "$OUT" 2>/dev/null)"24echo "file changed on disk before the kill: $([[ "$BEFORE" != "$AFTER" ]] && echo yes || echo no)"25echo "text after reopening: '$TEXT'"26rm -rf "$WORK"27if [[ "$TEXT" == *"Unsaved but recoverable 42"* ]]; then echo "PASS: autosaved text survived SIGKILL"; else echo "FAIL: typed text was lost"; exit 1; fi28
Files main
Menu

Theme