mirror of
https://github.com/by-sonic/tglock.git
synced 2026-11-05 23:31:58 +03:00
ci(android): retry UIAutomator dumps that write nothing (#64)
On the loaded API 35 emulator `uiautomator dump` intermittently writes no
file ("could not get idle state"). tap_label passed that straight to
`cat` and failed the whole smoke on the first miss, while the launch loop
already retried. The beta.16 commit failed four runs in a row this way;
the identical tree passed on its PR. Only the dump is retried — crash,
ANR, service and listener assertions are unchanged.
Co-authored-by: babin <Thartewerner536e@engineer.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -37,7 +37,11 @@ def ui_dump(label):
|
|||||||
# Dump first, then read the file; never tap coordinates inferred from a
|
# Dump first, then read the file; never tap coordinates inferred from a
|
||||||
# screenshot, a previous Activity, or assumed phone dimensions.
|
# screenshot, a previous Activity, or assumed phone dimensions.
|
||||||
adb("shell", "rm", "-f", "/sdcard/tglock-ui.xml")
|
adb("shell", "rm", "-f", "/sdcard/tglock-ui.xml")
|
||||||
adb("shell", "uiautomator", "dump", "/sdcard/tglock-ui.xml")
|
status = adb("shell", "uiautomator", "dump", "/sdcard/tglock-ui.xml", check=False)
|
||||||
|
if not adb("shell", "ls", "/sdcard/tglock-ui.xml", check=False).endswith("tglock-ui.xml"):
|
||||||
|
# On a loaded emulator UIAutomator intermittently reports "could not get
|
||||||
|
# idle state" and writes nothing. That is the tool, not the app.
|
||||||
|
raise subprocess.SubprocessError(f"uiautomator dump failed: {status}")
|
||||||
text = adb("shell", "cat", "/sdcard/tglock-ui.xml")
|
text = adb("shell", "cat", "/sdcard/tglock-ui.xml")
|
||||||
(EVIDENCE / f"{label}.xml").write_text(text, encoding="utf-8")
|
(EVIDENCE / f"{label}.xml").write_text(text, encoding="utf-8")
|
||||||
return ET.fromstring(text)
|
return ET.fromstring(text)
|
||||||
@@ -58,8 +62,12 @@ def label_node(tree, label):
|
|||||||
|
|
||||||
|
|
||||||
def tap_label(label, stage):
|
def tap_label(label, stage):
|
||||||
for attempt in range(3):
|
for attempt in range(5):
|
||||||
point = label_node(ui_dump(f"{stage}-{attempt}"), label)
|
try:
|
||||||
|
point = label_node(ui_dump(f"{stage}-{attempt}"), label)
|
||||||
|
except (subprocess.SubprocessError, ET.ParseError) as error:
|
||||||
|
(EVIDENCE / f"{stage}-{attempt}.error.txt").write_text(str(error), encoding="utf-8")
|
||||||
|
point = None
|
||||||
if point is not None:
|
if point is not None:
|
||||||
adb("shell", "input", "tap", str(point[0]), str(point[1]))
|
adb("shell", "input", "tap", str(point[0]), str(point[1]))
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user