Repository navigation
Honour ANDROID_ADB_SERVER_PORT and test the daemon failure paths against a fake adb - #49
Merged
Merged
Conversation
…ainst a fake adb AdbClient now defaults its port to ANDROID_ADB_SERVER_PORT when it is a valid port (adb's own variable), else 5037, and starts the server with -P on the port it uses. Process-level tests run the real daemon against the fake adb server with an isolated config and cover an invalid scrcpyPath during auto-launch, the p and u keys, and adb that cannot be restarted.
4 tasks
5 tasks
This was referenced Oct 26, 2026
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #46
What
AdbClienthonoursANDROID_ADB_SERVER_PORT, and new process-level tests run the real daemon against the fake adb server to check the #14 failure paths that were only verified by reading code.Why
The daemon always used port 5037, the same port as the developer's real adb server, so testing it end to end meant stopping or replacing that server. Four #14 paths had no automated check: an invalid
scrcpyPathduring auto-launch, thepkey, theukey, and adb that cannot be restarted.How
AdbClient({int? port})defaults toAdbClient.defaultPort:ANDROID_ADB_SERVER_PORTif it is a valid port (1 to 65535), else 5037. An explicitport:still wins.parsePortis a static function so the rule is unit-testable. With the variable unset nothing changes.ensureServerRunning()now runsadb -P <port> start-server, so a client pointed at another port can never start a server on 5037. For port 5037 this is the same as before.test/support/daemon_harness.dartstartsbin/daemon.dartas a child process withANDROID_ADB_SERVER_PORTset to the fake server,APPDATAandHOMEset to a temp folder (so the real config and known-devices file are neither read nor written), and a free IPC port written to that temp config. It captures the log, can type keys on stdin, and asks forlistDevicesover IPC to prove the daemon is alive and serving.daemon_process_test.dart: five scenarios. Each waits for the guard's specific log line and then checks IPC still answers. The two adb-restart scenarios wait for "could not start the adb server" twice, so they prove the retry loop keeps running rather than that the process merely survived (the last-resort zone inmainwould keep IPC up even if the loop died).Verified by
dart analyzeclean in core, ipc, daemon. Tests: core 27 (21 + 6), ipc 26, daemon 76 (71 + 5) pass locally on Windows; the five process tests take about 25 s together. CI results are in the checks below, including the first run of these on Ubuntu.parsePortfor valid, missing, malformed, zero, negative, too large and decimal values; explicit port wins; and a stand-inadbscript recording its arguments showsensureServerRunningruns-P <port> start-serverwhen nothing is listening, and runs nothing when a server answers.try/catcharoundensureServerRunning()removed from the daemon's retry loop, the two adb-restart scenarios fail; with it they pass. The code was restored afterwards.chmod-based stand-in script is only exercised there.Risk / follow-ups
packages/daemon(asproject.jsonand the README do).failedevents for these paths.