mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-28 13:02:21 +01:00
48 lines
1.4 KiB
Shell
Executable file
48 lines
1.4 KiB
Shell
Executable file
#!/bin/sh
|
|
set -eu
|
|
|
|
# Launches a packaged Hex.app with throwaway Application Support for a few
|
|
# seconds and fails if it exits early, or if a bundled Sparkle cannot start.
|
|
# Permission prompts and onboarding may appear; nothing is granted or kept.
|
|
if [ "$#" -ne 1 ]; then
|
|
echo "Usage: $0 <Hex.app path>" >&2
|
|
exit 1
|
|
fi
|
|
|
|
bundle=$1
|
|
seconds=${HEX_SMOKE_SECONDS:-15}
|
|
support=$(mktemp -d "${TMPDIR:-/tmp}/hex-smoke.XXXXXX")
|
|
pid=
|
|
trap '[ -z "$pid" ] || kill -KILL "$pid" 2>/dev/null || true; rm -rf "$support"' EXIT HUP INT TERM
|
|
|
|
fail() {
|
|
echo "Hex smoke test failed: $*" >&2
|
|
cat "$support/logs/process.log" >&2 2>/dev/null || cat "$support/output.log" >&2 || true
|
|
exit 1
|
|
}
|
|
|
|
HEX_APPLICATION_SUPPORT_DIR="$support" "$bundle/Contents/MacOS/hex" > "$support/output.log" 2>&1 &
|
|
pid=$!
|
|
sleep "$seconds"
|
|
if ! kill -0 "$pid" 2>/dev/null; then
|
|
status=0
|
|
wait "$pid" || status=$?
|
|
pid=
|
|
fail "exited with status $status within $seconds seconds"
|
|
fi
|
|
[ -s "$support/logs/process.log" ] || fail "wrote no process log"
|
|
if [ -d "$bundle/Contents/Frameworks/Sparkle.framework" ] \
|
|
&& grep -Fq 'could not start Sparkle updater' "$support/logs/process.log"; then
|
|
fail "Sparkle did not start"
|
|
fi
|
|
|
|
kill -INT "$pid"
|
|
waited=0
|
|
while kill -0 "$pid" 2>/dev/null && [ "$waited" -lt 10 ]; do
|
|
sleep 1
|
|
waited=$((waited + 1))
|
|
done
|
|
if kill -0 "$pid" 2>/dev/null; then
|
|
echo "Hex was still running 10 seconds after SIGINT; killed it." >&2
|
|
fi
|
|
echo "Hex ran for $seconds seconds from $bundle."
|