test: unify _wait_log into Session.wait_for (phase 6)
All 16 assert _wait_log(s, rx, timeout) sites become s.wait_for(rx, timeout); every caller only asserted truthiness, and both poll the whole log identically, so behavior is unchanged (failures now report the pattern plus a log tail instead of a custom one-liner). Sites on _wait_log's 15s default keep timeout=15.0 explicitly since wait_for defaults to 20s. The helper is deleted. Full suite: 152 passed, 2 skipped.
This commit is contained in:
parent
838876ff65
commit
33526c7a4e
1 changed files with 16 additions and 45 deletions
|
|
@ -1032,12 +1032,9 @@ def test_standalone_headless_locked_pointer_release():
|
|||
with _run_standalone({}, "%s --constrain locked '#ff0000'" % WL, wait="app0") as s:
|
||||
_assert_alive(s)
|
||||
s.warp(300, 300)
|
||||
assert _wait_log(s, r"\[constraint\] locked on surface",
|
||||
timeout=15.0), \
|
||||
"locked constraint never activated"
|
||||
s.wait_for(r"\[constraint\] locked on surface", timeout=15.0)
|
||||
s.tap(C)
|
||||
assert _wait_log(s, r"\[constraint\] destroyed", timeout=15.0), \
|
||||
"constraint destroy never ran"
|
||||
s.wait_for(r"\[constraint\] destroyed", timeout=15.0)
|
||||
_assert_alive(s, "compositor died on constraint release")
|
||||
|
||||
|
||||
|
|
@ -4017,8 +4014,7 @@ def test_x11_client_requests_driven():
|
|||
# init, heavyweight under load), so give the server its own budget
|
||||
# before the client's claim budget starts.
|
||||
s.wait_for(r"\[xwayland\] ready display=:(\d+)", timeout=30.0)
|
||||
assert _wait_log(s, r"\[claim\] app=0", timeout=30.0), \
|
||||
f"xreqs window never claimed:\n{s.read_log()[-500:]}"
|
||||
s.wait_for(r"\[claim\] app=0", timeout=30.0)
|
||||
# Settle the startup crown (last mapper promotes itself under load)
|
||||
# before asserting which tab booted active.
|
||||
s.wait_for(r"\[diag\] map app=0")
|
||||
|
|
@ -4026,10 +4022,8 @@ def test_x11_client_requests_driven():
|
|||
if s.active() != 1:
|
||||
s.chord_ack(ALT, UP)
|
||||
s.wait_active(1)
|
||||
assert _wait_log(s, r"client fullscreen=1", timeout=25.0), \
|
||||
"X11 fullscreen request never mirrored"
|
||||
assert _wait_log(s, r"active app=0", timeout=25.0), \
|
||||
"X11 raise never took focus"
|
||||
s.wait_for(r"client fullscreen=1", timeout=25.0)
|
||||
s.wait_for(r"active app=0", timeout=25.0)
|
||||
# The WM_DELETE close tears the tab down: a fresh active line for
|
||||
# the survivor proves it (the startup line is stale).
|
||||
before = s.active_count()
|
||||
|
|
@ -4052,8 +4046,7 @@ def test_x11_unmapped_window_destroyed_untracked():
|
|||
with _run_kick(
|
||||
["sh -c 'sleep 1; exec %s unmapped'" % XR,
|
||||
"%s --app-id keep '#0000ff' 320x240" % WL], wait="any") as s:
|
||||
assert _wait_log(s, r"destroyed unmapped", timeout=20.0), \
|
||||
f"pending X11 surface never tore down:\n{s.read_log()[-500:]}"
|
||||
s.wait_for(r"destroyed unmapped", timeout=20.0)
|
||||
time.sleep(1.0)
|
||||
_assert_alive(s, "compositor died on unmapped destroy")
|
||||
|
||||
|
|
@ -4084,15 +4077,13 @@ def test_x11_or_menu_move_repositions(tmp_path):
|
|||
stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL, start_new_session=True,
|
||||
preexec_fn=_preexec_death(os.getpid()))
|
||||
assert _wait_log(s, r"map app=1", timeout=15.0), \
|
||||
f"X11 frame never mapped:\n{s.read_log()[-500:]}"
|
||||
s.wait_for(r"map app=1", timeout=15.0)
|
||||
menu = subprocess.Popen(
|
||||
[XM, "menu", "6", "move"], env=xenv,
|
||||
stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL, start_new_session=True,
|
||||
preexec_fn=_preexec_death(os.getpid()))
|
||||
assert _wait_log(s, r"\[or\] move", timeout=15.0), \
|
||||
f"OR menu move never repositioned:\n{s.read_log()[-500:]}"
|
||||
s.wait_for(r"\[or\] move", timeout=15.0)
|
||||
menu.wait(timeout=15.0)
|
||||
menu = None
|
||||
time.sleep(0.5)
|
||||
|
|
@ -4141,8 +4132,7 @@ def test_xwayland_server_restart_survived(xwayland_session):
|
|||
time.sleep(0.2)
|
||||
assert xpid is not None, "embedded Xwayland process never found"
|
||||
os.kill(xpid, signal.SIGKILL)
|
||||
assert _wait_log(s, r"Restarting Xwayland", timeout=15.0), \
|
||||
"Xwayland never restarted after the kill"
|
||||
s.wait_for(r"Restarting Xwayland", timeout=15.0)
|
||||
time.sleep(1.0)
|
||||
_assert_alive(s, "compositor died with Xwayland")
|
||||
assert s.active() == 1, "Wayland tab lost active after Xwayland restart"
|
||||
|
|
@ -4551,8 +4541,7 @@ def test_standalone_headless_foreign_activate(tmp_path):
|
|||
% (WL, out)) as s:
|
||||
# The startup tab is the trailing (black) foreign tab, so any
|
||||
# "active app=0" line can only come from our activate request.
|
||||
assert _wait_log(s, r"active app=0", timeout=15.0), \
|
||||
f"taskbar activate never switched to testwin:\n{s.read_log()[-500:]}"
|
||||
s.wait_for(r"active app=0", timeout=15.0)
|
||||
_assert_alive(s, "compositor died on foreign activate")
|
||||
|
||||
|
||||
|
|
@ -5076,18 +5065,6 @@ def test_standalone_headless_xdg_activation_focus(tmp_path):
|
|||
_assert_alive(s, "compositor exited on activate")
|
||||
|
||||
|
||||
def _wait_log(s, rx, timeout=15.0):
|
||||
"""Wait until the compositor log matches rx; return the match or None."""
|
||||
pat = re.compile(rx)
|
||||
deadline = time.monotonic() + timeout
|
||||
while time.monotonic() < deadline:
|
||||
m = pat.search(s.read_log())
|
||||
if m:
|
||||
return m
|
||||
time.sleep(0.1)
|
||||
return None
|
||||
|
||||
|
||||
def test_standalone_headless_or_menu_owner_closed(tmp_path):
|
||||
"""An override-redirect menu's focus owner is freed before the menu is
|
||||
dismissed: closing the menu's owner tab and then unmapping the menu must
|
||||
|
|
@ -5121,8 +5098,7 @@ def test_standalone_headless_or_menu_owner_closed(tmp_path):
|
|||
stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL, start_new_session=True,
|
||||
preexec_fn=_preexec_death(os.getpid()))
|
||||
assert _wait_log(s, r"map app=1", timeout=15.0), \
|
||||
f"X11 frame never mapped:\n{s.read_log()[-500:]}"
|
||||
s.wait_for(r"map app=1", timeout=15.0)
|
||||
# Make the frame's tab active (it normally maps focused already).
|
||||
for _ in range(6):
|
||||
m = re.findall(r"active app=(\d+)", s.read_log())
|
||||
|
|
@ -5138,12 +5114,10 @@ def test_standalone_headless_or_menu_owner_closed(tmp_path):
|
|||
stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL, start_new_session=True,
|
||||
preexec_fn=_preexec_death(os.getpid()))
|
||||
assert _wait_log(s, r"or associate", timeout=15.0), \
|
||||
f"OR menu never associated:\n{s.read_log()[-500:]}"
|
||||
s.wait_for(r"or associate", timeout=15.0)
|
||||
# Close the owner tab, then let the menu unmap (release path).
|
||||
_oneshot_virtual_key(s.socket, "56:1,111:1,111:0,56:0")
|
||||
assert _wait_log(s, r"closing tab", timeout=15.0), \
|
||||
"owner tab never closed"
|
||||
s.wait_for(r"closing tab", timeout=15.0)
|
||||
menu.wait(timeout=25.0)
|
||||
time.sleep(1.0)
|
||||
_assert_alive(s, "compositor died on menu dismiss")
|
||||
|
|
@ -5176,10 +5150,8 @@ def test_standalone_headless_popup_chain_kill(tmp_path):
|
|||
|
||||
# Client A: wait until the nested sub-popup maps, then kill -9.
|
||||
a = pop_client(30)
|
||||
assert _wait_log(s, r"geo=200x100", timeout=15.0), \
|
||||
f"P1 never mapped:\n{s.read_log()[-500:]}"
|
||||
assert _wait_log(s, r"geo=150x80", timeout=15.0), \
|
||||
f"nested P2 never mapped:\n{s.read_log()[-500:]}"
|
||||
s.wait_for(r"geo=200x100", timeout=15.0)
|
||||
s.wait_for(r"geo=150x80", timeout=15.0)
|
||||
a.kill()
|
||||
a.wait(timeout=10.0)
|
||||
a = None
|
||||
|
|
@ -5187,8 +5159,7 @@ def test_standalone_headless_popup_chain_kill(tmp_path):
|
|||
_assert_alive(s, "compositor died on popup client kill")
|
||||
# Client B: a fresh chain maps again on the same compositor.
|
||||
b = pop_client(4)
|
||||
assert _wait_log(s, r"geo=150x80", timeout=15.0), \
|
||||
f"fresh nested popup never mapped:\n{s.read_log()[-500:]}"
|
||||
s.wait_for(r"geo=150x80", timeout=15.0)
|
||||
b.wait(timeout=15.0)
|
||||
b = None
|
||||
time.sleep(0.5)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue