From 200fc16ba29bb9277bd161a88f0edbc62129b23f Mon Sep 17 00:00:00 2001 From: Levi Neuwirth Date: Tue, 1 Sep 2026 12:21:32 +0200 Subject: [PATCH] fix(gui-1b): assert B4's off-Linux inertness where the effect would be The inertness stopped at a seam. `middle_click_paste_source() .unwrap_or(PasteSource::Clipboard)` at the call site restores the rejected fallback and passes every row: the helper still returns `None`, and Linux still receives PRIMARY. A contract asserted only in the function that decides it is not asserted on the path that acts on it. The end-to-end row drops its `cfg(target_os = "linux")` and asserts the complete transcript on both platforms: one PRIMARY paste on Linux, and off Linux NO paste of any selection and no local effect either. One honest limit is recorded on the row rather than left implied. On a Linux host that `unwrap_or` never engages --- the source is already `Some(Primary)` --- so no row on this machine can fire that mutant, and a green local run says nothing about it. The `else` branch is what catches it, and it runs on the non-Linux CI legs. Forcing the source to `None` everywhere fires two rows locally, which is the closest demonstration available here. Also repairs the neighbouring test's documentation, which my insertion had split: `an_unused_button_produces_no_effect_of_any_kind` was left with "row that calls it claimed-and-dropped" while its opening two lines had been absorbed into the B4 row's comment. Both are contiguous blocks again. Two process notes, because both recurred: - This is the THIRD insertion in this lane to damage an adjacent test's docs or attributes. The cause is anchoring a splice on a `fn` or doc line without checking what precedes it; from here I anchor above the doc block and read the neighbour back after inserting. - The previous commit's message claimed the `cfg` removal it did not contain: an edit script died partway, wrote nothing, and I committed on the strength of a later partial edit. Amended rather than left standing, and the file is now verified per claim rather than per script exit. --- pmacs-gpu/src/main.rs | 61 +++++++++++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 16 deletions(-) diff --git a/pmacs-gpu/src/main.rs b/pmacs-gpu/src/main.rs index 04bfe80..55514eb 100644 --- a/pmacs-gpu/src/main.rs +++ b/pmacs-gpu/src/main.rs @@ -4971,8 +4971,6 @@ mod input_routing_tests { ); } - /// P2 — a button the frontend has no semantics for reaches no body: - /// nothing local, nothing outbound. The counterpart to the routing /// B4 END TO END — a middle press driven through /// `dispatch_window_event` sends **exactly one** `Paste`, carrying /// the **PRIMARY** payload, and its release sends none. @@ -4986,8 +4984,22 @@ mod input_routing_tests { /// The two selections carry **distinguishable** contents, which is /// the whole point — a row whose PRIMARY and CLIPBOARD stubs said /// the same thing would pass with the wrong one read. + /// + /// **It asserts the whole transcript on BOTH platforms**, not just + /// Linux. A Linux-only row leaves the off-Linux contract to a helper + /// test, and + /// `middle_click_paste_source().unwrap_or(PasteSource::Clipboard)` + /// at the call site then restores the rejected clipboard fallback + /// while every row stays green: the helper still returns `None` and + /// Linux still gets PRIMARY. The inertness has to be asserted where + /// the effect would appear. + /// + /// **Where that mutant is actually caught, stated honestly:** on a + /// Linux host the `unwrap_or` never engages — the source is already + /// `Some(Primary)` — so no row on this machine can fire it, and a + /// green local run is not evidence about it. The `else` branch below + /// is what catches it, and it runs on the **non-Linux CI legs**. #[test] - #[cfg(target_os = "linux")] fn b4_a_middle_press_sends_exactly_one_paste_carrying_primary() { use winit::event::{ElementState, MouseButton}; let mut h = EffectHarness::new(); @@ -5003,19 +5015,34 @@ mod input_routing_tests { .iter() .filter(|e| matches!(e, pmacs_protocol::FrontendEvent::Paste { .. })) .collect(); - assert_eq!( - pastes.len(), - 1, - "exactly one paste, got {:?}", - step.outbound - ); - match pastes[0] { - pmacs_protocol::FrontendEvent::Paste { data, .. } => assert_eq!( - data.as_slice(), - b"PRIMARY-payload", - "B4 pastes the PRIMARY selection, not the clipboard" - ), - other => panic!("expected a Paste, got {other:?}"), + if cfg!(target_os = "linux") { + assert_eq!( + pastes.len(), + 1, + "exactly one paste, got {:?}", + step.outbound + ); + match pastes[0] { + pmacs_protocol::FrontendEvent::Paste { data, .. } => assert_eq!( + data.as_slice(), + b"PRIMARY-payload", + "B4 pastes the PRIMARY selection, not the clipboard" + ), + other => panic!("expected a Paste, got {other:?}"), + } + } else { + assert!( + pastes.is_empty(), + "off Linux the gesture is INERT: B4 rules PRIMARY on Linux \ + and nothing else, so no paste of any selection may appear \ + here. Got {:?}", + step.outbound + ); + assert!( + step.local.is_empty(), + "and no local effect either: {:?}", + step.local + ); } let release = h.feed(&mouse_input(ElementState::Released, MouseButton::Middle)); @@ -5028,6 +5055,8 @@ mod input_routing_tests { ); } + /// P2 — a button the frontend has no semantics for reaches no body: + /// nothing local, nothing outbound. The counterpart to the routing /// row that calls it claimed-and-dropped. #[test] fn an_unused_button_produces_no_effect_of_any_kind() {