Skip to content

Commit 69b7fcd

Browse files
committed
fix(scripts): delete the smoke pass's last dump before a new one
uiautomator leaves the previous file in place when a dump fails, so the next read handed a step the labels of the screen before.
1 parent 5026352 commit 69b7fcd

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ All notable changes to CallShield will be documented in this file.
55
## Unreleased
66

77
- The data pipeline's test runner now uses the first Python on PATH that has the pipeline's packages installed. With an older Python ahead of it on PATH, three suites used to fail on a missing cryptography or numpy.
8+
- `scripts/device_smoke.py` deletes its last screen dump before taking a new one. A dump that failed used to leave the old file in place, so a step could act on labels from the screen before.
89

910
## v1.13.0 (2026-10-30)
1011

‎scripts/device_smoke.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ def shell(self, *args: str) -> str:
8686
return out.stdout.decode("utf-8", "replace")
8787

8888
def nodes(self) -> list[Node]:
89+
# A dump that fails leaves the old file behind, and its labels would
90+
# read as the current screen.
91+
self.shell("rm", "-f", DUMP)
8992
self.shell("uiautomator", "dump", DUMP)
9093
return parse_nodes(self.shell("cat", DUMP))
9194

‎scripts/test_device_smoke.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ def test_a_tab_is_the_lowest_node_with_its_name(self):
3737
self.assertEqual((539, 2113), (tab.x, tab.y))
3838
self.assertIsNone(device_smoke.bottom_most(device_smoke.parse_nodes(DUMP), "Rules"))
3939

40+
def test_a_dump_deletes_the_last_one_first(self):
41+
# A dump that fails leaves the old file, which would read as the current screen.
42+
calls = []
43+
phone = device_smoke.Phone.__new__(device_smoke.Phone)
44+
phone.shell = lambda *args: calls.append(args) or (DUMP if args[0] == "cat" else "")
45+
46+
self.assertEqual(4, len(phone.nodes()))
47+
self.assertEqual(("rm", "-f", device_smoke.DUMP), calls[0])
48+
self.assertEqual("uiautomator", calls[1][0])
49+
4050
def test_the_expected_version_and_lists_come_from_the_repo(self):
4151
self.assertRegex(device_smoke.app_version(), r"^\d+\.\d+\.\d+$")
4252
self.assertIn("Lista Hũ", device_smoke.catalog_names())

0 commit comments

Comments
 (0)