Skip to content

automate_observation: split run() into process_device() and print_sum… - #37

Merged
billy-lau merged 1 commit into
android:mainfrom
billy-lau:uraniborg/refactor-main
Sep 29, 2026
Merged

billy-lau merged 1 commit into
android:mainfrom
billy-lau:uraniborg/refactor-main

Conversation

@billy-lau

Copy link
Copy Markdown
Member

…mary()

The per-device workflow lived inline in run(), with its outcome spread across three shared sets and a continue on every failure. Each recent feature (--serial, --events, prompts) added branches to that one loop, it could only be tested end to end through main(), and the scattered bookkeeping made status bugs easy.

Split it, with no behaviour change:

  • process_device() observes one device and returns a DeviceResult (status, results_dir, error); print_summary() logs the final lines and returns the run_finished summary.
  • RunState carries pre-fetch state across devices; classify_device() holds the status rules and replaces device_status().

Log text, events and exit codes are unchanged. Moved lines now show _observe_device or print_summary instead of run as the function name in the log prefix. One edge case: if two connected devices share a serial, the summary line shows the last one's outcome (the exit code still reflects both).

Test:

  • pytest uraniborg/scripts/python/tests/: 156 passed (11 new, calling the new functions directly; test_device_status replaced by test_classify_device; other existing tests unmodified).
  • Live on an Android 14 emulator, before vs after: identical logs (apart from function names) and events (apart from timestamps).

Change-Id: Ib1d454ea5586cf110ae6cbbcd8ca1cda02907d9b

…mary()

The per-device workflow lived inline in run(), with its outcome spread
across three shared sets and a `continue` on every failure. Each
recent feature (--serial, --events, prompts) added branches to that
one loop, it could only be tested end to end through main(), and the
scattered bookkeeping made status bugs easy.

Split it, with no behaviour change:

- process_device() observes one device and returns a DeviceResult
  (status, results_dir, error); print_summary() logs the final lines
  and returns the run_finished summary.
- RunState carries pre-fetch state across devices; classify_device()
  holds the status rules and replaces device_status().

Log text, events and exit codes are unchanged. Moved lines now show
_observe_device or print_summary instead of run as the function name
in the log prefix. One edge case: if two connected devices share a
serial, the summary line shows the last one's outcome (the exit code
still reflects both).

Test:
- pytest uraniborg/scripts/python/tests/: 156 passed (11 new, calling
  the new functions directly; test_device_status replaced by
  test_classify_device; other existing tests unmodified).
- Live on an Android 14 emulator, before vs after: identical logs
  (apart from function names) and events (apart from timestamps).

Change-Id: Ib1d454ea5586cf110ae6cbbcd8ca1cda02907d9b
@billy-lau
billy-lau merged commit 3b3d386 into android:main Sep 29, 2026
7 checks passed
@billy-lau
billy-lau deleted the uraniborg/refactor-main branch September 29, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant