macOS / Tests (AppleSilicon) (push) Canceled after 0s
macOS / Tests (Intel) (push) Canceled after 0s
macOS / Build (AppleSilicon) (push) Canceled after 0s
macOS / Build (Intel) (push) Canceled after 0s
macOS / Publish the GitHub Release (push) Canceled after 0s
88 lines
2.9 KiB
Bash
Executable File
88 lines
2.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Launch the built LinTunes.app against a throwaway library and check it
|
|
# stays up, then (if the app supports it) quits cleanly.
|
|
#
|
|
# packaging/mac/smoke_test.sh build/mac/dist/LinTunes.app [seconds]
|
|
#
|
|
# The library comes from scripts/make_dev_library.py (never a real one),
|
|
# built with the app's own ffmpeg. Every per-machine folder points into a
|
|
# temporary directory (XDG_* win over ~/Library in lintunes/paths.py), so
|
|
# the runner's home is never touched.
|
|
#
|
|
# Clean exit: the app is started with LINTUNES_QUIT_AFTER_MS. If main.py
|
|
# honours it, the app must exit 0 on its own; if it doesn't (yet), the
|
|
# test only proves the app stayed up, then stops it, and says so.
|
|
set -euo pipefail
|
|
|
|
APP="${1:?usage: smoke_test.sh path/to/LinTunes.app [seconds]}"
|
|
SECONDS_UP="${2:-20}"
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
EXE="$APP/Contents/MacOS/LinTunes"
|
|
[ -x "$EXE" ] || { echo "no executable at $EXE" >&2; exit 1; }
|
|
|
|
WORK="$(mktemp -d)"
|
|
trap 'rm -rf "$WORK"' EXIT
|
|
export XDG_CONFIG_HOME="$WORK/config" XDG_DATA_HOME="$WORK/share" \
|
|
XDG_CACHE_HOME="$WORK/cache"
|
|
export QT_QPA_PLATFORM="${QT_QPA_PLATFORM:-offscreen}"
|
|
|
|
echo "==> Bundled tools run"
|
|
"$APP/Contents/MacOS/ffmpeg" -hide_banner -version | sed -n 1p
|
|
"$APP/Contents/MacOS/fpcalc" -version
|
|
|
|
echo "==> Throwaway library"
|
|
# The generator imports lintunes (mutagen): build.sh's venv has it.
|
|
PY="${PYTHON:-$ROOT/build/mac/venv/bin/python}"
|
|
[ -x "$PY" ] || PY=python3
|
|
PATH="$APP/Contents/MacOS:$PATH" "$PY" "$ROOT/scripts/make_dev_library.py" \
|
|
--out "$WORK/lib" >/dev/null
|
|
DATA="$WORK/lib/data"
|
|
[ -f "$DATA/library.json" ] || { echo "make_dev_library made no library" >&2; exit 1; }
|
|
|
|
echo "==> Launching for ${SECONDS_UP}s"
|
|
LOG="$WORK/app.log"
|
|
LINTUNES_QUIT_AFTER_MS=$((SECONDS_UP * 1000)) \
|
|
"$EXE" --data-dir "$DATA" >"$LOG" 2>&1 &
|
|
PID=$!
|
|
|
|
fail() {
|
|
echo "SMOKE TEST FAILED: $*" >&2
|
|
echo "---- app output ----" >&2
|
|
cat "$LOG" >&2
|
|
kill -9 "$PID" 2>/dev/null || true
|
|
exit 1
|
|
}
|
|
|
|
for _ in $(seq "$SECONDS_UP"); do
|
|
sleep 1
|
|
kill -0 "$PID" 2>/dev/null || {
|
|
wait "$PID" && status=0 || status=$?
|
|
fail "the app exited after less than ${SECONDS_UP}s (status $status)"
|
|
}
|
|
done
|
|
echo "still running after ${SECONDS_UP}s"
|
|
|
|
# Give a self-quit up to 30 s to finish.
|
|
for _ in $(seq 30); do
|
|
kill -0 "$PID" 2>/dev/null || break
|
|
sleep 1
|
|
done
|
|
if kill -0 "$PID" 2>/dev/null; then
|
|
echo "NOTE: the app ignores LINTUNES_QUIT_AFTER_MS, so a clean exit wasn't tested; stopping it."
|
|
kill -TERM "$PID" 2>/dev/null || true
|
|
sleep 3
|
|
kill -9 "$PID" 2>/dev/null || true
|
|
wait "$PID" 2>/dev/null || true
|
|
else
|
|
wait "$PID" && status=0 || status=$?
|
|
[ "$status" -eq 0 ] || fail "the app quit with status $status"
|
|
echo "quit cleanly"
|
|
fi
|
|
|
|
if grep -q "Traceback (most recent call last)" "$LOG"; then
|
|
fail "a Python traceback was logged"
|
|
fi
|
|
echo "---- app output (tail) ----"
|
|
tail -n 40 "$LOG"
|
|
echo "SMOKE TEST PASSED"
|