Files
kernalix7--winpodx/tests/test_tray_reverse_open_lifecycle.py
wehub-resource-sync 3e779be6f3
CI / lint (push) Failing after 13m4s
CI / test (3.11, ubuntu-latest) (push) Failing after 2m4s
CI / test (3.13, ubuntu-latest) (push) Successful in 13m30s
CI / test (3.14, ubuntu-latest) (push) Successful in 17m21s
CI / test (3.12, ubuntu-latest) (push) Successful in 17m55s
CI / discover-apps-ps (push) Successful in 1m56s
CI / test (3.9, ubuntu-latest) (push) Successful in 13m17s
CI / test (3.10, ubuntu-latest) (push) Successful in 26m21s
CI / audit (push) Successful in 13m38s
Deploy site / deploy (push) Has been cancelled
CI / test (3.14, ubuntu-24.04-arm) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:32:37 +08:00

38 lines
1.4 KiB
Python

# SPDX-License-Identifier: MIT
"""#691: reverse-open listener lifecycle must be owned by the tray.
Source-shape guards (CI has no display): the tray must (a) self-heal the
listener at startup -- previously only ``pod start`` / the app-launch
``ensure_ready`` path did, so a GUI/tray-only start left Windows->Linux
"Open with" silently dead -- and (b) stop the listener deliberately on Quit
instead of relying on the ``pkill python.*winpodx.*gui`` collateral kill
(the double-forked daemon inherits its parent's argv, so it only matched
when it happened to be started from the GUI).
"""
from __future__ import annotations
from pathlib import Path
TRAY = Path(__file__).resolve().parent.parent / "src" / "winpodx" / "desktop" / "tray.py"
def _src() -> str:
return TRAY.read_text(encoding="utf-8")
def test_tray_startup_ensures_listener() -> None:
src = _src()
assert "ensure_listener_running(cfg)" in src
# off the UI thread -- ensure forks + waits for a ready sentinel
idx = src.index("def _ensure_reverse_open_listener")
spawn = "threading.Thread(target=_ensure_reverse_open_listener, daemon=True).start()"
assert spawn in src[idx:]
def test_quit_stops_listener_before_pkill() -> None:
src = _src()
stop_at = src.index("stop_listener()")
pkill_at = src.index('"pkill"')
assert stop_at < pkill_at, "Quit must stop the listener deliberately, before the pkill"