aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_thumb_ui.py
diff options
context:
space:
mode:
authorblasty <blasty@local>2026-08-07 21:23:44 +0200
committerblasty <blasty@local>2026-08-07 21:23:44 +0200
commit32ab74b03e9a50274396b4a32aae8baece7628a1 (patch)
tree547d9d1efe77411faca8e3df3e2fdad147fa8c5d /tests/test_thumb_ui.py
parentStruct editor: '/' fuzzy-filters the struct list (diff)
downloadida-tui-32ab74b03e9a50274396b4a32aae8baece7628a1.tar.gz
ida-tui-32ab74b03e9a50274396b4a32aae8baece7628a1.tar.xz
ida-tui-32ab74b03e9a50274396b4a32aae8baece7628a1.zip
tests: gate on real signals, not sleeps (117s -> 49s)
The suite spent its time in two kinds of guess. **Flat pauses.** ~140 `pause(d)` calls were 20.4s of the pilot's 62s, and `test_trace_ui` was 13.5s of `pilot.pause(1.0)` out of 19.6s. `Ctx.pause` is now `settle` (`d` is the upper bound, not the cost) and the other suites' sleeps became gates on the thing the check is about. `Ctx.sleep` stays for what a timer really drives. **Textual's keypress path.** `Pilot.press` calls `wait_for_idle` twice per key, which sleeps in 20ms granules until process time stops advancing -- 84ms per keypress here, 23s of the pilot's 43s. `_fixtures.fast_keys()` replaces it with the gate the suites already use: send the keys, then settle. Deleting the heuristic *without* that broke nine checks, so it was doing a job, badly. Four checks turned out to be riding on those sleeps: they read geometry or a repaint (`si.region`, `gv._minimap_rect()`, glyphs off `gv.render_line`, a repaint trace), and a settled app has not necessarily been laid out or painted. They now wait for the frame. The debounced function filter (`set_timer(0.08)`) likewise waits for its effect. Also fixed two waits on signals that never arrive: the comment wait in `rename` carried a `dec.loaded_ea == app._cur.ea` conjunct that cost 9s of timeout and then let the check pass vacuously, and `listing_view` -- the one entry under "Known-flaky" -- waited on `lst.total`, which is true before a single row exists. `--profile` reports, per scenario, seconds settling / waiting / pressing, and names any wait that expired with its line number. It is how the above was found and how the next 20s should be. Verified: 4 full `tests/run.py` runs, 800 passed each, 49.0-49.2s (was 117.4s); 4 consecutive pilot runs, 313 passed each, 21.2s (was 63.7s).
Diffstat (limited to 'tests/test_thumb_ui.py')
-rw-r--r--tests/test_thumb_ui.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/tests/test_thumb_ui.py b/tests/test_thumb_ui.py
index fed08a7..f12fbc4 100644
--- a/tests/test_thumb_ui.py
+++ b/tests/test_thumb_ui.py
@@ -20,10 +20,14 @@ import sys
import tempfile
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from textual.widgets import Static # noqa: E402
+from _fixtures import fast_keys # noqa: E402
from idatui._sync import settle # noqa: E402
+
+fast_keys() # ~85ms -> ~2ms per keypress; see _fixtures.fast_keys
from idatui.app import DecompView, IdaTui, ListingView # noqa: E402
PASS = FAIL = 0
@@ -95,7 +99,7 @@ async def run() -> int:
lst.focus()
lst.cursor = lst.model.index_of_ea(0)
lst._scroll_cursor_into_view()
- await pilot.pause(0.3)
+ await settle(app)
check("starts undefined at the entry", lst.model.get(lst.cursor).kind == "unknown",
f"{lst.model.get(lst.cursor).text!r}")
@@ -104,7 +108,10 @@ async def run() -> int:
# the Thumb prologue.
m0 = lst.model
await pilot.press("c")
- await pilot.pause(2.5)
+ # A refusal produces no new signal to wait for, so the gate is "the app
+ # finished reacting" -- 2.5s of hoping bought nothing a drained worker
+ # queue doesn't say better.
+ await settle(app)
h = lst.model.get(lst.model.index_of_ea(0))
check("`c` alone does not produce the Thumb prologue",
h is None or h.kind != "code" or "PUSH" not in h.text.upper(),
@@ -167,7 +174,7 @@ async def run() -> int:
lst.focus()
lst.cursor = lst.model.index_of_ea(0)
lst._scroll_cursor_into_view()
- await pilot.pause(0.3)
+ await settle(app)
m = lst.model
await pilot.press("t")
await settle(app, lambda: "64-bit" in status_of(app), timeout=60)
@@ -181,7 +188,7 @@ async def run() -> int:
# the reason, which is the only part that tells you what to do — with it
# missing, F5 doing nothing is indistinguishable from a bug in the TUI.
lst.cursor = lst.model.index_of_ea(0)
- await pilot.pause(0.2)
+ await settle(app)
mp = lst.model
await pilot.press("p")
# The function appearing in the index IS the signal; the model identity
@@ -214,7 +221,7 @@ async def run() -> int:
check("a 32-bit ARM database finds functions by itself",
len(app._func_index) > 5, f"n={len(app._func_index)}")
await pilot.press("escape")
- await pilot.pause(0.5)
+ await settle(app, lambda: type(app.screen).__name__ == "Screen")
f = app._func_index.all_loaded()[0]
app._goto_ea(f.addr, push=True)
await wait(lambda: app._cur is not None
@@ -248,14 +255,14 @@ async def run() -> int:
len(app._func_index) == 0, f"n={len(app._func_index)}")
if type(app.screen).__name__ != "Screen":
await pilot.press("escape")
- await pilot.pause(0.5)
+ await settle(app, lambda: type(app.screen).__name__ == "Screen")
app._goto_ea(0, push=True)
lst = app.query_one(ListingView)
await wait(lambda: lst.model is not None, pilot, 60)
lst.focus()
lst.cursor = lst.model.index_of_ea(0)
lst._scroll_cursor_into_view()
- await pilot.pause(0.3)
+ await settle(app)
await pilot.press("T")
await wait(lambda: app._func_index is not None
and len(app._func_index) >= 3, pilot, 90)