#!/usr/bin/env bash set -euo pipefail ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)" TMP="$(mktemp -d)" trap 'rm -rf "$TMP"' EXIT mkdir -p "$TMP/home/.local/lib/omarchy-citizen" "$TMP/bin" "$TMP/home/Downloads" CALLS="$TMP/calls.log" cat > "$TMP/home/.local/lib/omarchy-citizen/omarchy-citizen-backend" <<'BACKEND' #!/usr/bin/env bash set -u printf '%s\n' "$*" >> "${FAKE_CALLS:?}" case "${1:-status}" in game-status) cat <&2; exit 3 ;; esac BACKEND chmod +x "$TMP/home/.local/lib/omarchy-citizen/omarchy-citizen-backend" cat > "$TMP/bin/xdg-terminal-exec" <<'TERM' #!/usr/bin/env bash printf 'terminal:%s\n' "$*" >> "${FAKE_CALLS:?}" exit 0 TERM cat > "$TMP/bin/uwsm-app" <<'UWSM' #!/usr/bin/env bash [[ "${1:-}" == "--" ]] && shift exec "$@" UWSM cat > "$TMP/bin/notify-send" <<'NOTIFY' #!/usr/bin/env bash exit 0 NOTIFY cat > "$TMP/bin/xdg-user-dir" <<'XDG' #!/usr/bin/env bash printf '%s/Downloads\n' "$HOME" XDG chmod +x "$TMP/bin/"* export HOME="$TMP/home" export XDG_CONFIG_HOME="$HOME/.config" export XDG_DATA_HOME="$HOME/.local/share" export XDG_STATE_HOME="$HOME/.local/state" export XDG_CACHE_HOME="$HOME/.cache" export PATH="$TMP/bin:/usr/bin:/bin" export FAKE_CALLS="$CALLS" # 1. Status must be fully routed through the Go backend without missing shell functions. out="$(bash "$ROOT/citizenctl" status 2>&1)" grep -q '^plugin_version=0.8.1$' <<<"$out" grep -q '^health=install$' <<<"$out" grep -q '^managed_wine_version=11.14-1$' <<<"$out" ! grep -qi 'command not found' <<<"$out" # 2. The complete setup terminal action must call all owned backend stages. : > "$CALLS" bash "$ROOT/citizenctl" install-stack-terminal >/dev/null 2>&1 grep -q '^autopilot enable$' "$CALLS" grep -q '^doctor$' "$CALLS" grep -q '^game-install$' "$CALLS" grep -q '^maintain$' "$CALLS" # 3. Primary setup routing must open the visible setup terminal. : > "$CALLS" FAKE_HEALTH=install bash "$ROOT/citizenctl" primary >/dev/null 2>&1 grep -q 'terminal:.*install-stack-terminal' "$CALLS" # 4. A ready installation launches through the Go backend directly. : > "$CALLS" FAKE_HEALTH=ready FAKE_PREFIX_STATE=ready FAKE_LAUNCHER_STATE=ready FAKE_GAME_STATE=ready \ bash "$ROOT/citizenctl" primary >/dev/null 2>&1 grep -q '^game-launch$' "$CALLS" # 5. Repair routing remains visible. : > "$CALLS" FAKE_HEALTH=repair bash "$ROOT/citizenctl" primary >/dev/null 2>&1 grep -q 'terminal:.*repair-stack-terminal' "$CALLS" # 6. Plugin updater wrapper must not collide with the combined status function. : > "$CALLS" bash "$ROOT/citizenctl" plugin-update-check >/dev/null 2>&1 grep -q '^check$' "$CALLS" echo 'citizenctl smoke tests: OK'