Skip to content

Commit dfbce67

Browse files
committed
Gate the macOS window probe on the code, not on the runner's session
A macos-14 runner was measured to have no ordinary application windows at all, so a probe that asserted a count would be asserting a property of the runner image rather than of this project — and would go red the day that image happens to open one. It now asserts that the backend is selected, the Quartz query runs and every window it does return can be described, and reports the counts either side of the layer filter so an empty session and a filter that dropped everything stay told apart.
1 parent 688dd2b commit dfbce67

2 files changed

Lines changed: 24 additions & 16 deletions

File tree

‎.github/workflows/platform-smoke.yml‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,5 @@ jobs:
8484
# So the flag is off and this is a gate now: EXPECTED in the script
8585
# holds what was measured, and a capability appearing or disappearing
8686
# turns this red and names which one.
87-
# Back in --measure for one round: the window-management probe is new
88-
# and its value is not in EXPECTED yet. Asserting a value nobody has
89-
# measured would be the guess this whole script exists to avoid.
90-
- name: Measure the macOS backend against a real window server
91-
run: python test/verify/macos_verify.py --measure
87+
- name: Verify the macOS backend against a real window server
88+
run: python test/verify/macos_verify.py

‎test/verify/macos_verify.py‎

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@
6161
"keyboard-post": True,
6262
"accessibility-tree": True,
6363
"recorder-absent": True,
64+
# True means "the code answered", not "the runner had windows": a
65+
# macos-14 runner was measured to have none at the application layer, so
66+
# the count is reported and not asserted.
67+
"window-management": True,
6468
}
6569

6670
_results: List[Tuple[str, bool, str]] = []
@@ -215,25 +219,32 @@ def probe_recorder() -> Outcome:
215219
def probe_window_management() -> Outcome:
216220
"""Quartz lists windows without a grant; acting on one needs Accessibility.
217221
218-
Listing is what this measures, because it is the half that has to work
219-
before any of the rest means anything — and because a runner with no
220-
windows at all would make every window command untestable here.
222+
What is asserted is that the *code* answers — the backend is selected, the
223+
Quartz query runs, and every window it returns can be described. What is
224+
only *reported* is how many there are, because that is a property of the
225+
runner's session rather than of this project: a GitHub macOS runner was
226+
measured to have no ordinary application windows at all. Gating on a
227+
count would go red the day the runner image happens to open one.
221228
"""
222229
import je_auto_control as ac
223230
from je_auto_control.wrapper.window_backends import get_backend
224231

225232
backend = get_backend()
226233
if not backend.available:
227234
return Outcome(False, f"backend {backend.name!r} reports unavailable")
235+
# Before the layer filter, so "the session is empty" and "the filter
236+
# dropped everything" are told apart rather than guessed at.
237+
raw = len(backend._window_info())
228238
windows = ac.list_windows()
229-
if not windows:
230-
return Outcome(False, f"backend {backend.name!r} listed no windows")
231-
window_id, title = windows[0]
232-
rect = backend.window_rect(window_id)
233-
pid = backend.window_process_id(window_id)
234-
return Outcome(rect is not None and pid > 0,
235-
f"{len(windows)} window(s); first {title!r} "
236-
f"rect={rect} pid={pid}")
239+
described = []
240+
for window_id, title in windows[:3]:
241+
described.append((title, backend.window_rect(window_id),
242+
backend.window_process_id(window_id)))
243+
complete = all(rect is not None and pid > 0
244+
for _title, rect, pid in described)
245+
return Outcome(complete,
246+
f"{raw} on-screen window(s) from Quartz, {len(windows)} at "
247+
f"the application layer; described {described}")
237248

238249

239250
PROBES: List[Tuple[str, Callable[[], Outcome]]] = [

0 commit comments

Comments
 (0)