diff --git a/tests/quickshell/settings-commit-reset-contract.sh b/tests/quickshell/settings-commit-reset-contract.sh index a1e4352..21bf264 100755 --- a/tests/quickshell/settings-commit-reset-contract.sh +++ b/tests/quickshell/settings-commit-reset-contract.sh @@ -61,6 +61,26 @@ restore() { } trap restore EXIT +# This contract shares its harness file with settings-hyprland-write-contract, +# and Quickshell identifies an instance by config path -- so if that run's +# instance is still alive, the IPC wait below is satisfied by ITS target. That +# direction is the dangerous one: this contract believes the compositor seam is +# stubbed, so it would happily drive the DAILY DESKTOP's real compositor while +# reporting isolation. Refuse to start rather than find out. +harness_instances() { + # rg -c prints nothing when there are no matches, so an unguarded + # substitution yields "" rather than "0". + local count + count="$(qs list 2>/dev/null | rg -c "^ Config path: $harness\$" || true)" + printf '%s' "${count:-0}" +} +for _ in $(seq 1 50); do + [[ "$(harness_instances)" == "0" ]] && break + sleep 0.1 +done +[[ "$(harness_instances)" == "0" ]] \ + || fail 'another instance of the settings harness is still running -- this contract would drive it instead of its own isolated one, and that instance may be writing to the real compositor' + XDG_CONFIG_HOME="$config_home" XDG_STATE_HOME="$state_home" \ PANAMA_SETTINGS_TEST_ISOLATE_COMPOSITOR=1 qs -p "$harness" --daemonize >/dev/null for _ in $(seq 1 40); do diff --git a/tests/quickshell/settings-hyprland-write-contract.sh b/tests/quickshell/settings-hyprland-write-contract.sh index 9fa9ad0..d69846f 100755 --- a/tests/quickshell/settings-hyprland-write-contract.sh +++ b/tests/quickshell/settings-hyprland-write-contract.sh @@ -77,6 +77,32 @@ target_auto_hdr_int=$([[ "$target_auto_hdr" == true ]] && printf 1 || printf 0) target_vrr=$([[ "$original_vrr" == 3 ]] && printf 0 || printf 3) target_direct=$([[ "$original_direct" == 2 ]] && printf 0 || printf 2) +# settings-commit-reset-contract drives the SAME harness file with +# PANAMA_SETTINGS_TEST_ISOLATE_COMPOSITOR=1, where the compositor write seam is +# stubbed out. Quickshell identifies an instance by its config path, so if that +# run's instance has not fully exited, the `ipc show` wait below is satisfied by +# ITS target -- and every write in this contract lands on the isolated instance +# and never reaches the compositor. That is exactly what "a typed batch did not +# reach the compositor" looks like when this fails in a full suite run but +# passes on its own. +# +# So wait for the harness to be clear first, and say so plainly if it is not, +# rather than silently talking to the wrong shell. +harness_instances() { + # rg -c prints nothing at all when there are no matches, so an unguarded + # substitution yields "" rather than "0" and every comparison against a + # count fails. + local count + count="$(qs list 2>/dev/null | rg -c "^ Config path: $harness\$" || true)" + printf '%s' "${count:-0}" +} +for _ in $(seq 1 50); do + [[ "$(harness_instances)" == "0" ]] && break + sleep 0.1 +done +[[ "$(harness_instances)" == "0" ]] \ + || fail 'another instance of the settings harness is still running -- this contract would talk to it instead of its own, and its writes may be deliberately stubbed' + XDG_CONFIG_HOME="$config_home" qs -p "$harness" --daemonize >/dev/null for _ in $(seq 1 40); do if qs_for_harness ipc show 2>/dev/null | rg -q '^target settings-system-test$'; then