Repository navigation
test: warm the droidsock instance in a setup file, outside the timed hooks - #48
Merged
Merged
Conversation
…t's mirror views The device leaf mirrors its session onto the mounted leaf with a wrap-on-set write (self.devices[key].connection = connection, src/api/device.mjs:177-178). Since @cldmv/slothlet 3.15.3 (bumped on next in #40), wrap-on-set hands back a live Proxy view of each object instead of the object itself (slothlet changelog v3.15.3, "live Proxy delegation instead of eager materialization"). With 3.15.1 installed the same tests pass; with 3.15.3 and 3.21.0 they fail. That broke two assumptions in the tests, not the library: - device.connection.socket / device.streamManager are views, never the same references the leaf passes on. Every method in src/api/device.mjs (e.g. push at :212, install at :279) passes session.connection.socket and session.streamManager, the objects connection.create() and stream.create() returned. The 9 delegation tests compared the spied call args against the views and failed on equality. They now capture the real session from spies on connection.create/stream.create and assert against that, which is what the leaf is meant to pass. - Assigning device.connection.deviceFeatures = [...] no longer reaches the session's connection object: an object assigned through the view stays on the view. The leaf reads session.connection.deviceFeatures (device.mjs:198, :281), so shell() saw [] and install() never took the streaming path. The only place the library sets deviceFeatures is the handshake (src/api/connection.mjs:117-125, parsed from the device's CNXN banner), so the fake ADB servers now answer the AUTH with a CNXN banner advertising the requested features, as a real device does, instead of the tests writing through the mirror. The documented external use of the mirror, passing device.connection.socket and device.streamManager to a protocol module (docs/API.md), still works: an openStream() through the views reaches the device. The "falls back to classic silently" install test also passed for the wrong reason: without "cmd" reaching the session, install() went straight to classic and never exercised the fallback. It now asserts that both streaming and classic ran. The connection test's hook timeout came from the failed assertion skipping device.disconnect(). The connection stayed open and the afterEach server.close() waited on it. The install tests now disconnect in finally.
…hooks
@cldmv/vitest-runner runs each test file in its own process, so the first
createDroidSock() in a file pays a one-time cold cost. Vitest transforms
slothlet's inlined runtime (server.deps.inline) and loads every src/api
module for the first time. Measured in a probe test on this machine at a
load average of about 60-70 on 8 cores: 6.9-11.0 s for the first instance
versus 1.2-2.7 s for the second in the same process.
That cold cost landed in each file's first beforeEach/beforeAll, which
races the 10 s hook timeout. Under load, whichever test ran first in a file
failed with "Hook timed out in 10000ms", and its afterEach then threw on
the undefined instance ("Cannot read properties of undefined (reading
'shutdown')", or rmSync on an undefined key dir in auth.test). In 3 runs on
next with the deterministic failures already fixed, 5-7 extra tests failed
this way per run, always the first test of a file (auth, files, forward,
install, log, pairing, reboot, reverse, shell, stream). This is where the
varying failure count in #47 came from.
A setup file (tests/setup/warm-droidsock.mjs, registered as setupFiles)
now composes and shuts down one instance before each file is collected.
Setup files run before collection and have no timeout, so each hook is left
with only its own per-test work. No timeout was raised and no test was
skipped.
Fixes #47
Shinrai
approved these changes
Sep 28, 2026
cldmv-bot Bot
added a commit
that referenced
this pull request
Oct 2, 2026
## 🚀 What's Changed ### 💥 Breaking Changes _No breaking changes_ ### ✨ Features _No new features_ ### 🐛 Bug Fixes _No bug fixes_ ### 📦 Dependencies - #44 - deps: bump the minor group across 1 directory with 3 updates (ef91a23) - #43 - deps: bump the patch group across 1 directory with 7 updates (ef8e07c) - #42 - deps: bump @eslint/css from 1.4.0 to 2.0.0 (0beb53a) - #41 - deps: bump @types/node from 26.4.1 to 26.5.1 in the minor group (44c81b4) - #40 - deps: bump @cldmv/slothlet from 3.15.1 to 3.15.3 in the patch group (0b1db2c) - #38 - ci: bump default max_node_major from 22 to 26 (d1a9261) - #36 - deps: bump @vitest/coverage-v8 to 5.0.0 alongside vitest (3fa0950) - deps: bump vitest from 4.1.11 to 5.0.0 (0459a5e) - #33 - deps: bump the minor group with 3 updates (cd94e97) - #32 - deps: bump the patch group with 3 updates (f8c8339) ### 🔧 Other Changes - #50 - ci: stop the skipped PR-run mirror from satisfying Required PR Check (95b9651) - #48 - test: warm the droidsock instance in a setup file, outside the timed hooks (64a07c4) - test(device,connection): assert against the real session, not slothlet's mirror views (569531e) - #46 - ci: stop bundle-size double-counting files (5a45c8e) - ci: bring the v4 workflow sync up to CLDMV/.github v4.29.2 (f608eb7) - ci: sync v4 workflows with CLDMV/.github v4.29.0 templates (a053183) - #45 - chore: restore the verbatim Apache-2.0 license text (f03687c) - #39 - docs(dependabot): group eslint + prettier families into one bump each (f3b5d82) - docs(dependabot): group vitest + @vitest/* into one bump (217d06b) - #38 - chore: bump engines.node floor to >=22.12.0 (4e48647) - ci: bump default min_node_version to 22.12.0 (vitest 5 floor) (a33dbba) <details> <summary>👥 Contributors</summary> - @Shinrai </details> --- <!-- coverage-start -->  | Metric | Coverage | |--------|----------| | Statements | 93.0% | | Branches | 85.3% | | Functions | 94.4% | | Lines | 94.5% | *Avg: **91.8%** · `fece746` · Node lts/** <!-- coverage-end --> <!-- co-authors --> Co-authored-by: Shinrai <[email protected]>
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.
🚀 What's Changed
💥 Breaking Changes
No breaking changes
✨ Features
No new features
🐛 Bug Fixes
No bug fixes
📦 Dependencies
No dependency updates
🔧 Other Changes
👥 Contributors