Skip to content

@simlock/e2e: a setup function runs once on every leased device #1991

Done

Description

@V3RON

Part of #1634.

Scope

simlockDevices takes a setup function that runs once on every device it leases, with an exec for simctl or adb commands, and the CI page says how to put a device into a known state.

If this goes wrong, a run starts its tests on a device that is not set up, or fails before its tests.

Technical spec

Commit 096519b.

Rows

  • Behaviours: B1, B2, B3, B4, B5, B6, B7
  • Interfaces: I1, I2
  • Existing code: X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13

Facts

# Fact Source
F1 On a booted simulator (iOS 27.0, iPhone 17), simctl spawn <udid> defaults write of ReduceMotionEnabled and AppleLanguages takes effect for a program started after it: UIAccessibility.isReduceMotionEnabled and Locale.preferredLanguages change with no reboot, and a clone of the simulator keeps both a Swift program spawned before and after the writes, and in a clone: reduceMotion=false langs=["en-PL", "pl-PL"], then reduceMotion=true langs=["de-DE"] twice (2026-11-30)
F2 A clone keeps a permission grant, and simctl keychain <udid> reset works on it sqlite3 TCC.db in the clone printed kTCCServiceMicrophone|com.apple.mobilesafari|2; the reset exited 0 (2026-11-30)
F3 The runner's app.permissions is applied on every fresh launch, and device.clearKeychain() resets the iOS simulator's whole keychain, unsupported on Android node_modules/@e2e-dev/mobile/README.md:64 and node_modules/@e2e-dev/mobile/dist/device.d.ts:164 at 0.12.9
F4 The runner passes AppleLanguages and AppleLocale as launch arguments of one app on iOS node_modules/@e2e-dev/mobile/dist/launch-arguments.js:3 at 0.12.9

Modules touched

Searches: those of the parent's Existing code.

  • packages/e2e/src/: the option, its check, the run of setup, exec in a file of its own, the exported types and class, the type-checked sample
  • e2e/slow-e2e-provider.test.ts: B7
  • website/src/content/docs/docs/using-devices/ci.mdx: the docs section, the option's row, the failure table

Rules in play

  • ADR 0077 §3: the package imports nothing from src/; it calls the HTTP route
  • testing.md 6: tests drive simlockDevices and createProvider; exec has no test of its own file
  • testing.md 7: B7 extends the existing slow test, and starts no device of its own
  • documentation.md 2: the CI page cites no ADR

Tests

Seams: simlockDevices in packages/e2e/src/index.test.ts and createProvider in packages/e2e/src/provider.test.ts, the latter with a node:http server on 127.0.0.1 as the farm's exec route; model on the install cases already there.

  • B1: A config gives setup: it is checked at config load: absent; undefined; async function; plain function; an arrow that returns exec(...) itself type-checks; a list, null and a string are refused with I1's message
  • B2: The runner acquires a device: setup runs once, after the app and every extra app are installed and before acquire ends, with I1's context, and simlock: setup done in <n> ms is logged; with no setup, nothing is run and nothing is logged: iOS; Android; app named and not named; plain function; async function; no setup; the lease is renewed while a long setup runs
  • B3: setup throws: the device is given back, I1's line is logged, one other device is leased, installed and set up; a second failure fails the acquire with the existing could not set up a device after 2 tries message: throws an Error; rejects; throws a string; first fails and second ends; both fail (two releases); install fails first and setup fails second; plain function throws
  • B4: The run is aborted while setup runs: acquire rejects with the abort's reason without waiting for setup, the device is given back, no other is leased: setup never ends; setup rejects because of the abort; an exec in flight is cut; setup is not started when the run aborted during the install
  • B5: setup calls exec: the command runs on this lease's device, and exec ends with its stdout and stderr: iOS sends tool simctl; Android sends adb; stdin sent and left out; stdout and stderr mixed; a message cut across two chunks; a multi-byte character cut across two chunks; comment lines ignored; the request carries the token and this lease's id
  • B6: exec fails: it rejects with I2's error for the case: exit 1 with stderr; exit 1 with stdout only; exit 1 with no output; last line over 300 characters; stream error; JSON error before the start; non-JSON answer; stream ends with neither exit nor error; connection refused; a url with a username and password reaches the farm with the bearer token, and with the farm unreachable no error, cause or log line holds either (maintainer, 2026-11-30); [] sends no request; the farm's real EXEC_TIMEOUT text (X11) and other-device refusal (X12), each quoting all the arguments: neither the error's message and causes, nor the log lines, nor the final error and its causes hold a later argument, and farmMessage holds the text
  • B7: On a real simulator a setup writes a setting through exec and reads it back: write then read com.apple.Accessibility ReduceMotionEnabled is 1 when acquire ends

Done when

  • pnpm exec vitest run --project unit packages/e2e/src/provider.test.ts and the same for packages/e2e/src/index.test.ts pass.
  • packages/e2e/src/config.sample.ts sets setup, and pnpm typecheck passes.
  • ci.mdx has a section "Prepare each device" that covers: setup with an iOS example (language, reduce motion) and an Android one (animations off), I1's context and I2's failures; that setup runs once per device and not between tests; permissions through the runner's app.permissions; keychain between tests through device.clearKeychain(); one app's language through launch arguments; and when to use a baseline instead (the same state for every run, saved by an operator on each worker). Its options table has a setup row, its "When it fails" table the new lines, and it says that other runners use exec over the HTTP API.
  • pnpm --dir website install && pnpm --dir website build && node website/scripts/check-openapi.mjs passes.
  • ci.mdx warns that the last line a failed command prints reaches the CI log.
  • B7 needs a real iOS simulator: scripts/slow-e2e.sh e2e/slow-e2e-provider.test.ts passes.

Out of scope

The parent's Non-goals. Moving budgie or mobile-ci to setup.

Depends on

None.

Written by an agent.

Activity

  1. added
    task:draft
    on Nov 30, 2026
  2. added
    task:ready
    and removed
    task:draft
    on Nov 30, 2026
  3. self-assigned this
    on Nov 30, 2026
  4. 4 remaining items

  5. V3RON commented on Nov 30, 2026

    @V3RON
    ContributorAuthor

    Handoff

    Done: PR #1993 at 1f83fca: B1 to B6 and the CI page. R1, R2, R4 to R7, R11, R12, R14 to R16 fixed.

    Not done: R17 to R19 (texts in the PR's Status). B7's slow test is written, never run: the review did not pass, so the lane and gate did not start.

    Findings: R3, R11, R14, R15 and R17 are one class: a password in url reaches the CI log through fetch's error. Each fix hid more spellings, the next check found another. R16 came from the same code.

    Blocked on: the maintainer picks how to fix R17:

    • Send fetch a url with the userinfo removed, so it never quotes it, and delete secretsIn and hideCredentials (proposed, unproven).
    • Refuse a url with credentials in checkUrl, whose message must not print it. Changes what a config accepts.
    • Keep redacting, as R17 says.

    Written by an agent.

  6. added
    task:blocked
    and removed
    task:ready
    on Nov 30, 2026
  7. removed their assignment
    on Nov 30, 2026
  8. added
    task:ready
    and removed
    task:blocked
    on Nov 30, 2026
  9. self-assigned this
    on Nov 30, 2026
  10. added a commit that references this issue on Nov 30, 2026
    c02e8b2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

task:ready

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions