Skip to content

test(android): isolate emulator port tests from live emulators - #163

Merged
ElbertePlinio merged 3 commits into
mainfrom
fix/160-emulator-test-ports
Sep 10, 2026
Merged

ElbertePlinio merged 3 commits into
mainfrom
fix/160-emulator-test-ports

Conversation

@ElbertePlinio

Copy link
Copy Markdown
Member

The android tests assumed console ports 5554 to 5562 were free, so packages/android/test/emulator.test.ts, session.test.ts and reaper.test.ts failed whenever a real emulator ran on the machine.

startEmulator gains an optional portRange seam (autoMin, max) forwarded to automatic allocation; production callers omit it and keep 5554 and 5556 to 5682, with no new flag or environment read. The emulator tests derive every port from a private base at 5670, the session tests from 5640 and the reaper test from 5648, so each assertion keeps its meaning (skip on bound port lands on base+2, explicit reserved or bound port is refused, emulator-reported collision retries on the next port, bounded retries give up). The explicit 5554 case became "accepts an explicit port below the auto-allocation floor".

Validation: bunx vitest run packages/android (10 files, 154 tests) with ports free and again with loopback listeners bound on 5554 to 5563; bun run lint, bunx tsc --noEmit, bunx complexity-gate check --changed.

Closes #160

The console port reservation and port collision test groups assumed console
ports 5554 to 5562 were free, so they failed on any machine running a real
Android emulator. Add an optional portRange seam to startEmulator and the
internal allocator, defaulting to the existing AUTO_MIN_CONSOLE_PORT and
MAX_CONSOLE_PORT, and derive every port in those groups from a private base
of 5670. Production defaults, CLI flags and environment reads are unchanged.

Closes #160
The android session and reaper tests passed explicit console ports 5554,
5556, 5558 and 5560 to createAndroidSession and startEmulator, so the
pre-flight free-port probe rejected them whenever a real emulator held that
window. Derive their explicit ports from a test-private base per file, 5640
for the session tests and 5648 for the reaper test, and report the matching
serial from each fake adb. The whole packages/android suite now passes with
listeners bound on 5554 to 5563.

Refs #160
@ElbertePlinio
ElbertePlinio merged commit 8f5263c into main Sep 10, 2026
10 checks passed
@ElbertePlinio
ElbertePlinio deleted the fix/160-emulator-test-ports branch September 10, 2026 16:30
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.

test(android): emulator tests assume console ports 5554-5562 are free

1 participant