SPB Git

Repository Public

test.sh 2.6 KB 45 lines shellscript

1#!/bin/bash2# ORIX Docs3# File: Scripts/test.sh4# Description: Runs every automated check and writes docs/reports/test-results.json with the real counts:5#              engine tests (Swift Testing, serial), the interaction self-test (real key and mouse events in the app) and the recovery test.6#              Usage: Scripts/test.sh [engines|app|all]7#8# Author: Simon-Pierre Boucher9# Contact: contact@spboucher.ai10set -uo pipefail11cd "$(dirname "$0")/.."12WHAT="${1:-all}"; mkdir -p docs/reports build13ENGINE_LOG=build/engine-tests.log; SELF=build/selftest.json14engines() {15  # Serial: laying out documents from every pool thread at once can stall in the system font registry.16  (cd Packages/ORIXDocsKit && ORIX_SLOW_TESTS="${ORIX_SLOW_TESTS:-}" swift test --scratch-path "${ORIX_SCRATCH:-/tmp/orixdocs-main}" --no-parallel 2>&1) | sed 's/\x1b\[[0-9;]*m//g' > "$ENGINE_LOG"17  grep -E "✘|Test run with" "$ENGINE_LOG" | tail -2018}19app() {20  Scripts/build.sh debug >/dev/null21  APP="build/DerivedData/Build/Products/Debug/ORIX Docs.app/Contents/MacOS/ORIX Docs"22  rm -f "$SELF"23  "$APP" -ApplePersistenceIgnoreState YES -ORIXTemplate blank -ORIXSelfTest "$PWD/$SELF" -checkSpelling NO -AppleLanguages "(en)" >/dev/null 2>&1 &24  PID=$!; for _ in $(seq 1 120); do kill -0 $PID 2>/dev/null || break; sleep 1; done; kill -9 $PID 2>/dev/null25  Scripts/recovery-test.sh > build/recovery.log 2>&1; echo "recovery: $(tail -1 build/recovery.log)"26}27[[ "$WHAT" == "engines" || "$WHAT" == "all" ]] && engines28[[ "$WHAT" == "app" || "$WHAT" == "all" ]] && app29/usr/bin/python3 - "$ENGINE_LOG" "$SELF" build/recovery.log <<'PY'30import json, re, sys, os, datetime31out = {"date": datetime.datetime.now().astimezone().isoformat(timespec="seconds")}32log = open(sys.argv[1]).read() if os.path.exists(sys.argv[1]) else ""33m = re.findall(r"Test run with (\d+) tests? in (\d+) suites? (passed|failed)", log)34if m:35    # One "Test run" line per test target: total them.36    out["engine"] = {"targets": len(m), "tests": sum(int(x[0]) for x in m), "suites": sum(int(x[1]) for x in m),37                     "result": "passed" if all(x[2] == "passed" for x in m) else "failed", "issues": len(re.findall(r"^✘ Test .* recorded an issue", log, re.M))}38if os.path.exists(sys.argv[2]):39    s = json.load(open(sys.argv[2])); out["interaction"] = {"scenarios": s["passed"] + s["failed"], "passed": s["passed"], "failed": s["failed"]}40if os.path.exists(sys.argv[3]):41    out["recovery"] = open(sys.argv[3]).read().strip().splitlines()[-1]42json.dump(out, open("docs/reports/test-results.json", "w"), indent=2)43print(json.dumps(out, indent=2))44PY45
Files main
Menu

Theme