diff --git a/tests/quickshell/displays-contract.sh b/tests/quickshell/displays-contract.sh index a7fda87..767e9cc 100755 --- a/tests/quickshell/displays-contract.sh +++ b/tests/quickshell/displays-contract.sh @@ -113,6 +113,25 @@ config_home="$(mktemp -d /tmp/panama-displays-config.XXXXXX)" run() { XDG_CONFIG_HOME="$config_home" qs -p "$harness" "$@"; } status() { run ipc call displays-test status; } +# The shipped geometry, read from the Hyprland config rather than from the +# running compositor. +# +# Everything below captures "original" from what it observes at start, which is +# correct only if the display is already in a good state. A previous run that +# failed mid-revert leaves the display changed, and the next run then captures +# THAT as the original and faithfully restores the desktop to a broken value. +# One flake becomes permanent. So refuse to run from a state that does not match +# what the config says, rather than laundering it. +shipped_scale="$(sed -n 's/^local shipped_scale *= *\([0-9.]*\).*/\1/p' \ + "$repo_dir/config/dot/hypr/monitors.lua" | head -1)" +[[ -n "$shipped_scale" ]] || fail 'could not read the shipped scale from monitors.lua -- the guard below depends on it, and skipping it silently is how a dirty baseline gets laundered' +if [[ -n "$shipped_scale" ]]; then + live_scale="$(hyprctl -j monitors | jq -r '.[0].scale')" + if ! awk -v a="$live_scale" -v b="$shipped_scale" 'BEGIN { exit !(a == b) }'; then + fail "the display is at scale $live_scale but the config ships $shipped_scale -- refusing to capture a dirty state as the baseline. Restore it first: hyprctl eval 'hl.monitor({ output = \"DP-2\", mode = \"4500x3000@60\", scale = $shipped_scale, transform = 0 })'" + fi +fi + original_mode="" original_scale="" original_transform="" diff --git a/tests/quickshell/focus-session-expiry.sh b/tests/quickshell/focus-session-expiry.sh index 178087f..f9efa7a 100755 --- a/tests/quickshell/focus-session-expiry.sh +++ b/tests/quickshell/focus-session-expiry.sh @@ -13,6 +13,20 @@ cleanup() { trap cleanup EXIT qs ipc call focus end >/dev/null 2>&1 || true + +# focus start records the caffeine state it found so end() can hand it back, and +# the assertion below requires caffeine to finish off. Both are only true if +# caffeine starts off. +# +# This test kills and restarts the live shell, so an interrupted run leaves +# caffeine on with nothing to turn it back off. The next run then records +# "previously on", faithfully restores it, and fails -- and every run after +# that fails identically, with the desktop quietly unable to idle or lock the +# whole time. Refuse to start from that state rather than latching it in. +if [[ "$(qs ipc call caffeine status 2>/dev/null)" != "false" ]]; then + fail 'caffeine is on before the session starts -- this test cannot distinguish "restored correctly" from "never released". Turn it off first: qs ipc call caffeine toggle' +fi + qs ipc call focus start >/dev/null state_file=$(find "${XDG_STATE_HOME:-$HOME/.local/state}/quickshell/by-shell" -name focus-session.json -print -quit)