SPB Git

Repository Public

restore-check.sh 2.4 KB 25 lines shellscript

1#!/usr/bin/env bash2# Author: Simon-Pierre Boucher — contact@spboucher.ai3# File: Scripts/restore-check.sh4# Description: Checks window restoration of the Debug build with real key presses and a real quit (cliclick + System Events): navigates two main windows, quits keeping windows, relaunches, and prints the windows before and after. They must be identical.5#6# Usage: Scripts/restore-check.sh      (needs cliclick and Accessibility permission for the terminal; uses the 5058 test backend)7set -uo pipefail8cat > /tmp/vq-winb.swift <<'SWIFT'9import CoreGraphics10import Foundation11let pid = Int(CommandLine.arguments[1])!12let list = CGWindowListCopyWindowInfo([.optionOnScreenOnly, .excludeDesktopElements], kCGNullWindowID) as? [[String: Any]] ?? []13for w in list where (w["kCGWindowOwnerPID"] as? Int) == pid && (w["kCGWindowLayer"] as? Int) == 0 { let b = w["kCGWindowBounds"] as! [String: Any]; print(w["kCGWindowNumber"]!, w["kCGWindowName"] ?? "", b["X"]!, b["Y"]!, b["Width"]!, b["Height"]!) }14SWIFT15cd "$(dirname "$0")/.."; eval "$(Scripts/dev-session.sh)"; DD="${VQ_DERIVED:-$HOME/Library/Developer/VQuant/DerivedData}"; APP="$DD/Build/Products/Debug/VQuant.app"; BIN="DerivedData/Build/Products/Debug/VQuant.app/Contents/MacOS/VQuant"16for p in $(pgrep -f "$BIN"); do kill $p; done; sleep 217quit() { osascript -e 'tell application "System Events" to tell (first process whose unix id is '$1') to click menu item "Quit VQuant" of menu 1 of menu bar item "VQuant" of menu bar 1' >/dev/null 2>&1; sleep 4; }18launch() { open -n "$APP" --env VQ_SERVER="$VQ_SERVER" --env VQ_DEV_TOKEN="$VQ_DEV_TOKEN" --args -VQInMemory -ApplePersistenceIgnoreState NO -NSQuitAlwaysKeepsWindows YES; sleep 10; PID=$(pgrep -f "$BIN" | head -1); osascript -e 'tell application "System Events" to set frontmost of (first process whose unix id is '$PID') to true'; sleep 0.5; }19launch20# navigate the frontmost main window, then a new one, by shortcuts (what a person does)21osascript -e 'tell application "System Events" to tell (first process whose unix id is '$PID') to perform action "AXRaise" of (first window whose name is "Charting")' 2>/dev/null; sleep 0.522cliclick kd:cmd t:4 ku:cmd; sleep 2; cliclick kd:cmd t:n ku:cmd; sleep 3; cliclick kd:cmd t:7 ku:cmd; sleep 223echo "-- before quit"; swift /tmp/vq-winb.swift $PID | cut -d' ' -f2- | sort; sleep 3; quit $PID; pgrep -f "$BIN" >/dev/null || echo quit-ok24launch; echo "-- after relaunch"; swift /tmp/vq-winb.swift $PID | cut -d' ' -f2- | sort25
Files main
Menu

Theme