Fix the bar visibility toggle and make the acceptance suite cover 4.0.2 security hardening
(cherry picked from commit 432b5e3e24)
111 lines
3.6 KiB
Bash
Executable File
111 lines
3.6 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# In-guest acceptance suite. Runs inside a live Omarchy session (typically a
|
|
# VM installed by omarchy-iso-test, reached over SSH) and verifies that the
|
|
# desktop actually works: session health, application launches, and shell
|
|
# surfaces (launcher, emoji picker, menu).
|
|
#
|
|
# Artifacts (screenshots, logs) land in $OMARCHY_ACCEPTANCE_DIR.
|
|
|
|
set -euo pipefail
|
|
|
|
ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
|
|
TEST_DIR="$ROOT/test/acceptance.d"
|
|
|
|
export OMARCHY_ACCEPTANCE_DIR="${OMARCHY_ACCEPTANCE_DIR:-/tmp/omarchy-acceptance}"
|
|
mkdir -p "$OMARCHY_ACCEPTANCE_DIR"
|
|
|
|
# Discover the graphical session so the suite works over SSH, where none of
|
|
# the session environment is inherited.
|
|
export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"
|
|
export DBUS_SESSION_BUS_ADDRESS="${DBUS_SESSION_BUS_ADDRESS:-unix:path=$XDG_RUNTIME_DIR/bus}"
|
|
# The suite acts on the running session, and qs matches shell instances by
|
|
# config path — pointed at any other tree, every omarchy-shell call reads as
|
|
# "not running". So default OMARCHY_PATH to the tree the session was started
|
|
# from, then this checkout for standalone use, then the installed tree for
|
|
# when only test/ was synced in (omarchy-iso-test's --sync-omarchy).
|
|
if [[ -z ${OMARCHY_PATH:-} ]]; then
|
|
OMARCHY_PATH=$(systemctl --user show-environment 2>/dev/null | sed -n 's/^OMARCHY_PATH=//p' | tail -1)
|
|
fi
|
|
if [[ -z $OMARCHY_PATH ]]; then
|
|
OMARCHY_PATH=$ROOT
|
|
fi
|
|
if [[ ! -f $OMARCHY_PATH/shell/shell.qml && -f /usr/share/omarchy/shell/shell.qml ]]; then
|
|
OMARCHY_PATH=/usr/share/omarchy
|
|
fi
|
|
export OMARCHY_PATH
|
|
|
|
export PATH="$OMARCHY_PATH/bin:$PATH"
|
|
|
|
if [[ -z ${DISPLAY:-} ]]; then
|
|
display=$(systemctl --user show-environment | sed -n 's/^DISPLAY=//p' | head -1)
|
|
export DISPLAY="${display:-:0}"
|
|
fi
|
|
|
|
if [[ -z ${LANG:-} ]]; then
|
|
locale_name=$(systemctl --user show-environment | sed -n 's/^LANG=//p' | head -1)
|
|
export LANG="${locale_name:-C.UTF-8}"
|
|
fi
|
|
|
|
# First boot may still be settling; wait for Hyprland to come up.
|
|
boot_deadline=$((SECONDS + ${OMARCHY_ACCEPTANCE_BOOT_TIMEOUT:-300}))
|
|
|
|
wait_for_session() {
|
|
local signature
|
|
|
|
while true; do
|
|
signature=$(ls -t "$XDG_RUNTIME_DIR/hypr" 2>/dev/null | head -1)
|
|
|
|
if [[ -n $signature ]]; then
|
|
export HYPRLAND_INSTANCE_SIGNATURE="$signature"
|
|
hyprctl -j monitors >/dev/null 2>&1 && return 0
|
|
fi
|
|
|
|
if ((SECONDS >= boot_deadline)); then
|
|
echo "not ok - Hyprland session never came up" >&2
|
|
exit 1
|
|
fi
|
|
|
|
sleep 2
|
|
done
|
|
}
|
|
|
|
wait_for_session
|
|
printf 'ok - Hyprland session is up (signature %s)\n' "$HYPRLAND_INSTANCE_SIGNATURE"
|
|
|
|
if [[ -z ${WAYLAND_DISPLAY:-} ]]; then
|
|
display=$(find "$XDG_RUNTIME_DIR" -maxdepth 1 -name "wayland-*" ! -name "*.lock" -printf '%f\n' 2>/dev/null | head -1)
|
|
export WAYLAND_DISPLAY="${display:-wayland-1}"
|
|
fi
|
|
|
|
shopt -s nullglob
|
|
tests=()
|
|
for test in "$TEST_DIR"/*-test.sh; do
|
|
[[ $(basename "$test") == "base-test.sh" ]] && continue
|
|
tests+=("$test")
|
|
done
|
|
shopt -u nullglob
|
|
|
|
if (( ${#tests[@]} == 0 )); then
|
|
echo "No acceptance tests found in $TEST_DIR" >&2
|
|
exit 1
|
|
fi
|
|
|
|
status=0
|
|
suite_started=$SECONDS
|
|
for test in "${tests[@]}"; do
|
|
test_started=$SECONDS
|
|
printf '==> %s\n' "${test#$ROOT/}"
|
|
if ! timeout "${OMARCHY_ACCEPTANCE_TEST_TIMEOUT:-420}" bash "$test"; then
|
|
status=1
|
|
fi
|
|
printf ' completed in %ss\n' "$((SECONDS - test_started))"
|
|
done
|
|
|
|
if ((status != 0)); then
|
|
printf 'not ok - acceptance suite failed in %ss (artifacts in %s)\n' "$((SECONDS - suite_started))" "$OMARCHY_ACCEPTANCE_DIR" >&2
|
|
exit $status
|
|
fi
|
|
|
|
printf 'ok - acceptance suite passed in %ss (artifacts in %s)\n' "$((SECONDS - suite_started))" "$OMARCHY_ACCEPTANCE_DIR"
|