Files
docs-next/docs/contributing/tests.md
T

48 KiB

Tests

Go test helpers

Go tests are table tests next to the code they test, and they share a few helpers, so each one reads the same way:

  • stubtest.New(t) puts the stubs first on PATH for one test, as the CLI tests have them, with a new folder under /tmp as their STUB_DIR and its calls file as their STUB_LOG. The folder goes when the test ends. stubtest.New(t, "ssh") puts only the stubs it names on PATH, so the host's other commands, such as git, stay. Its Calls returns the calls the stubs logged, Reset forgets them, and Touch, Write and Read work on the files the stubs read, such as a switch, a file whose presence makes a stub fail. VM, Size and VMs set and read Lima's instances in the stubs' state, and Keychain and SetKeychain the Keychain's items. stubtest.Command(t, "mise") returns the path of one stub, for a test that runs it by its path, as DEVVM_HOST_MISE does.
  • stubtest.ExecRunner is a backend's runner that runs each command as it is, with no run log, so a backend under test runs the stubs.
  • msg.IDOf(err) returns the ID of the message an error carries, or "" when it carries none, and msg.NamesOf(err) returns the message's names, as names mode prints them, or the error's own text when it isn't a message. A test compares either with what it expects.
  • A msg.Fake is the msg.Reporter a package under test prints and asks through. Its zero value is quiet: it prints nothing, has no terminal, so it refuses every question as the UI does where it can't ask, and runs a logged command as it is. Its fields change that: OnInfo, OnWarn and the other On funcs are given each message or question of their kind, with a question's context going to OnNote first, OnAny every message, and Terminal, Picks, Interrupt and the writers stand for the terminal, the picker, an interrupt and the output.
  • A msg.Recorder keeps the messages it's given. Set a msg.Fake's OnInfo or OnWarn to the recorder's Add, then compare its Names or its IDs.
  • backendtest.Stored is the fake backend with its disks on the host, for the free-space checks.

CLI tests

CLI tests are testscript scripts in testdata/script/*.txtar, run by internal/cli/script_test.go against a freshly built devvm. Call it with exec devvm …:

# An unknown flag fails.
! exec devvm --nope
stderr '^devvm: flag_unknown command=devvm flag=--nope$'

Scripts see messages by their names, so the example checks which message devvm printed, not its wording. A script that checks a message's text sets env DEVVM_MESSAGES= first.

Run one script with mise exec -- go test ./internal/cli -run TestScript/<name>.

Each script runs in a sandbox under /tmp, never the real folders:

Variable Points to
HOME home/
XDG_DATA_HOME data/
XDG_CONFIG_HOME config/
DEVVM_LIMA_HOME, LIMA_HOME lima/ (short, for Lima's socket paths)
DATA, VMS, RUN devvm's data folder, data/devvm/, and its vms/ and run/ folders
CFG devvm's config folder, config/devvm/
DEVVM_MESSAGES names, so messages print as their names
STUB_DIR stub/, for stubs' state
STUB_LOG stub/calls, the stubs' call log
DEVVM_SECRET_SERVICE devvm-test, the Keychain service name
DEVVM_UBUNTU_URL ubuntu/, with a dated release as Ubuntu signed it
DEVVM_KVM stub/kvm, a file standing in for Linux's /dev/kvm
DEVVM_TEST_CPUS, DEVVM_TEST_MEMORY_GIB, DEVVM_TEST_FREE_GIB 8, 16 and 500: a large host, whatever runs the tests (details)
DEVVM_HOST_MISE the mise stub, which resolves the shared tools in place of devvm's own mise
MISE_STUB_LOCK testdata/mise.lock, the lock the mise stub writes
TOOLCHAINS, AGENTS the toolchains' and the coding agents' names, in the registries' order and joined with spaces, as devvm's messages list them, so a script that checks a list names no toolchain or agent itself (stderr 'names='$TOOLCHAINS'$')
DEVVM_BIN the folder of the built devvm, alone
DEVVM_REPO the checkout, for the scripts in scripts/, which tests copy into a throwaway repo before running, and the scripts in assets/, which tests source to check their pieces

The built devvm is a test build, so it reads the stand-ins above that a release ignores, such as DEVVM_KVM and DEVVM_HOST_MISE. A script answers a question in one of two ways: ttyin -stdin FILE gives the next exec a terminal whose input is the file, so devvm asks as it does in yours, and env DEVVM_PIPED_ANSWERS=1 with stdin FILE has each question read its answer as a line of the file instead, without its prompt. Without either, devvm has no terminal, so it refuses every question, as a script's devvm does. It has the checkout's assets/ embedded, as a release has, and no test build reads them from elsewhere: a script that needs other files for devvm (layers, features, policies) puts them in the user's folders in the sandbox, as a user would.

$WORK, the script's own folder, is the current folder. project NAME makes the folder $WORK/NAME and goes to it, as a project's folder, and project NAME git makes it a git repo too. Once devvm has made the folder's VM, vm_name VAR NAME finds it among the states in $VMS and sets $VAR to the VM's name, which ends in an ID the test can't know, so a script can pass it to a stub (exec limactl stop $WEB). It also sets $VAR_dir to the VM's folder, $VMS/<hash>, so a script reads the VM's state as $WEB_dir/vm.json and its network log as $WEB_dir/logs/network.jsonl. catg GLOB prints the one file a glob matches, and fails when the glob matches none or more than one, so a check never reads two files by mistake. vm_state GLOB prints the one VM state a glob matches as sorted KEY=VALUE lines for stdout to match: a section's fields are dotted (net.on=true, ports.host.ssh=23456), a list of strings is joined with spaces (tools.names=node claude), a list of objects is indexed (links.links.0.name=db), and anything but a string is JSON. Negated, ! catg GLOB and ! vm_name VAR NAME pass when there isn't exactly one. json_set GLOB KEY=VALUE… sets string fields in each JSON file the glob matches and keeps the rest, or makes the file when a glob without wildcards matches none. KEY:=JSON sets any JSON value, and a dotted key sets a field of an object, which it makes when it's missing. Scripts write devvm's JSON records with it, such as a tool image's record (json_set $SHARE/node-*.json built=2020-01-01T00:00:00Z), because a record's times are in the file, where touch can't change them. fixture VERSION puts a release's state into the sandbox, and json_superset [-shape] [-changes PATH] WANT GOT checks that one JSON file has everything another has, as Released state says. A VM state a script writes as a fixture needs version, id, name, image, dir and backend, created for a VM whose creation finished, and a hash of its own for its folder (json_set $VMS/12345612345601/vm.json version:=1 id=x name=devvm-live-12345612345601 image=base dir=/p/live backend=lima created=2020-01-01T00:00:00Z net.on:=false).

Tests never touch the network. Downloads are served from a test server (net/http/httptest) or read from a file:// folder. DEVVM_UBUNTU_URL replaces https://cloud-images.ubuntu.com/releases/resolute, where devvm finds Ubuntu's dated releases: point it at a folder of release-YYYYMMDD/ folders, each with its SHA256SUMS and SHA256SUMS.gpg, as file:///path/to/folder. The CLI tests serve internal/ubuntu/testdata/resolute, a release as Ubuntu published and signed it, and Go tests sign their own releases with a key they make (internal/ubuntu/pgp_test.go). devvm's own releases, which devvm upgrade installs, come from internal/upgrade/upgradetest: a TLS test server laid out as GitHub's releases, with a minisign key of the test's own that signs each release's SHA256SUMS as minisign does. A script starts one with release_server [-badsig] LATEST [VERSION...], which serves a release of each version, the first the newest, each devvm in it a script that prints its version, and with -badsig signs them with another key. It points a test build at the server with DEVVM_REPO_URL, at its key with DEVVM_RELEASE_KEY and at its certificate with DEVVM_RELEASE_CA, and DEVVM_TEST_VERSION gives the test build a release's version. Container registries (--from) are a TLS test server in Go tests; scripts use pinned digests, which need no lookup, or set HTTPS_PROXY to a closed port, so lookups fail as offline ones do.

A command left running in the background (exec devvm … &name&) can be interrupted with kill -INT name. wait_file FILE waits up to 10 seconds for a file to appear, such as one a stub writes when it gets somewhere. A script that runs a copy of devvm makes it with cp_exe SRC DST, not cp: on Linux, a command another script starts while the copy is being written keeps the file open for writing until it runs, so running the copy then fails with "text file busy", and cp_exe writes the file while no command can start.

Stubs

The stubs stand in for every host command devvm runs, so tests never run the real tools: limactl, docker, security, ssh, ssh-add, ssh-agent, ssh-keygen, qemu-img, qemu-system-aarch64, qemu-system-x86_64, chflags, tmutil, sw_vers, uname, open, code and mise. They are one Go program, internal/stubtest/stub, which does what the command it's run as would do: the binary is named stub, each command's name is a link to it, and it reads its name from its argv[0]. internal/stubtest builds it once, into $TMPDIR/devvm-stubs-<hash> with its links, where the hash covers the stub's sources and Go's version. Every test process, and every later run until the sources change, finds that folder and uses it, so the binary builds only once, and a folder of an older build is removed once it's a day old. TestScript puts that folder on PATH right after devvm's, ahead of the real commands.

Each stub logs its call to $STUB_LOG as one line, its name and its arguments joined by spaces. The stub writes the line itself, in one write to the log opened for appending, so lines from stubs running at once never mix, and its arguments never go to another process's command line. That matters because endpoint security tools such as CrowdStrike Falcon kill a process whose arguments look like an ssh option next to a proxy URL with a password, which is what a start's limactl edit passes. stub_calls prints the log for stdout or cmp to check, ! stub_calls fails if anything was logged, and stub_reset empties the log, so the next check sees only the calls after it:

exec devvm …
stub_calls
cmp stdout calls

-- calls --
limactl list

uname and sw_vers pretend to be another host when these are set, and run the real command otherwise:

Variable Printed by
STUB_UNAME_S uname -s
STUB_UNAME_M uname -m
STUB_SW_VERS sw_vers -productVersion

What the stubs keep between their calls is their state, $STUB_DIR/state.json, which internal/stubtest/stubstate reads and writes as typed JSON under a file lock, so stubs running at once never lose each other's changes. It holds Lima's instances, each with its status, size and config, the Keychain's items, the SSH agent and its keys, and Time Machine's exclusions. Scripts read and change it with the stub command, and Go tests with the stubtest.Stubs methods VM, Size, VMs, Keychain and SetKeychain:

Command What it does
stub vm NAME STATUS Lima lists the instance NAME in STATUS, such as Stopped, Running or Broken, with Lima's default size when it's new
stub vms prints Lima's instances, one NAME STATUS line each, sorted
stub size NAME CPUS MEMORY DISK gives an instance its size, with the memory and disk in bytes
stub keychain ACCOUNT prints the Keychain's item for ACCOUNT, and fails when there's none
stub keychain-set ACCOUNT saves the item for ACCOUNT from its input, so the value is in no process's arguments
stub agent prints the SSH agent's keys as ssh-add -l lists them, and fails when no agent runs
stub agent-stop stops the SSH agent
stub names prints every stub's name

A switch is a file a test makes in $STUB_DIR to change what a stub does, such as start-fails, which makes limactl start fail. The comment above each stub's function lists its switches, and every switch is named for the command and what happens to it: -fails, -hangs, -fails-on and -waits-on, where an -on switch holds the text that a call's arguments must contain. A stub that hangs touches $STUB_DIR/hanging first, so wait_file can wait for it. The files a stub writes in $STUB_DIR are what a test checks, such as $STUB_DIR/sync.tar, what a VM's setup was sent.

limactl keeps its instances in the state and fails or hangs on request. It keeps each instance's size and config as create, clone and edit set them, and a contract test checks that it does so as real Lima does. Its shell reaches the guest, the VM the stubs make believe in, which ssh reaches too. One module, guest.go, answers whatever devvm runs in a VM, with one set of switches whichever way devvm gets there. limactl shell is also the shell devvm opens in a VM, which then ends, so a script sees it as devvm's last call. In the shared tools' build VM, its shell writes the images build.sh is asked for into the build's folder (or, on request, a symlink instead), and it keeps what a VM's setup is sent as $STUB_DIR/sync.tar. A base build's packages go in as $STUB_DIR/packages-in.tar, and what the build gives back is $STUB_DIR/packages-out.tar, or no packages. In the --from build VM, its shell writes what oci/build.sh would (or, on request, a hostile disk, command line, C library or symlink), and a call naming $STUB_DIR/interrupt-on's text interrupts devvm, as Ctrl+C would. The VM's ssh host keys are one made-up key for each VM, unless $STUB_DIR/hostkeys-fails exists.

docker stands in only for what --from asks of it. It has an image only when $STUB_DIR/docker-image holds its ID, its save writes a tarball naming that image (or $STUB_DIR/docker-saved's, a tag that moved), and it isn't running when $STUB_DIR/docker-down exists. ssh answers a port forwarder's master with $STUB_DIR/guest-ports, and a link session's master listens on its control socket. Either master outlives the process that started it, as ssh's does, until the sandbox's cleanup stops it or 5 minutes pass. A direct connection from a VM (the self-check's) fails, as a confined VM's does, unless $STUB_DIR/net-direct exists. A --clone VM's git runs on the host, on $STUB_DIR/vmfs/<folder>, and ssh pushes to and fetches from there (it fails with $STUB_DIR/ssh-fails). security stands in for the Keychain and tmutil for Time Machine, both keeping their items in the state, never in the real ones. mise writes $MISE_STUB_LOCK as the lock ($MISE_STUB_OLDER_LOCK for a list of versions), lists $MISE_STUB_VERSIONS, and fails like mise offline with MISE_STUB_FAIL set. chflags sets no flags, so .git protection leaves test folders deletable. qemu-img and QEMU are there so Linux hosts pass devvm's checks.

To add a stub, write its function in internal/stubtest/stub, with a comment that says what it does and lists its switches, and add it to stubs() under the command's name. It logs its call with c.log() first, keeps what it must remember in the state through c.update, and reads its switches with c.on and c.text. A new command the state needs goes in control. To add a switch, read it in the stub's function, name it for what it does as above, and add it to that function's comment. Each stub has unit tests in stub_test.go, which run it in the test's own process. Where a stub prints what devvm parses, such as limactl list --json, the golden fixtures check that it prints what the real tool prints.

devvm runs in $WORK or a folder made in it (mkdir, then cd), never in HOME or devvm's own folders, which it refuses as project folders.

Coverage

mise run test measures each package's test coverage, then fails when a package's coverage is more than a point below its line in the baseline, so coverage only goes up. That point of room is there because the same tests can cover a little less from one run to the next, with timing or the tools a machine has installed. A package inside it passes and keeps its line. Each system has a baseline of its own, testdata/coverage/darwin.txt and testdata/coverage/linux.txt, because macOS and Linux run different code and skip different tests. On a system without one, mise run test says so and checks nothing. A package's coverage counts its own Go tests and the CLI tests together. scripts/test.sh sets CLI_GOCOVERDIR, so TestScript builds devvm with -cover for every package of devvm's, and each devvm a script runs writes its counters to that script's own folder inside it. Scripts run in parallel, and devvm runs that started at the same moment in one folder would race to write the same meta-data file, so one of them would print coverage meta-data emit failed on stderr and fail any script that checks it. go tool covdata then merges every script's folder with the Go tests' own counters. That way internal/cli, and code that only the CLI tests reach, such as a backend's real runner, count as tested. The end-to-end tests don't count.

When a change raises a package's coverage, raise its baseline in the same commit. Run mise run coverage, which runs the tests as mise run test does, then writes each package's coverage to this system's baseline where it went up, and commit the file. A change that raises coverage on both systems raises both baselines, so run it on a Linux host too. It never lowers a line: a package within a point below its baseline keeps the line it has, and when a package is more than a point below, it fails and writes nothing. A new package gets its line from mise run coverage too, and a package that's gone loses its line there, because mise run test fails on both until then. coverage.txtar checks scripts/coverage.sh, which compares the coverage with the baseline.

There's no target percentage: a package is judged by what's untested in it, not by its number.

End-to-end tests

mise run e2e runs devvm against real VMs, so it needs Lima and takes minutes: run it in the background. It runs TestE2E in tests/e2e, with the run's flags after --. First it checks that this machine has every command the chosen sections use, and it names each one that's missing with what installs it (the list). Then it builds devvm from the checkout into its sandbox, its files embedded, and runs every check through that binary:

Lima home ~/.lt-e2e-go (or $DEVVM_E2E_LIMA_HOME); it refuses ~/.lima and devvm's own
State /tmp/devvm-go-e2e (XDG_DATA_HOME, XDG_CONFIG_HOME)
Keychain service devvm-go-e2e (DEVVM_SECRET_SERVICE), fake tokens only, deleted at the end
Lock /tmp/devvm-go-e2e.lock, a symlink to the pid of the run that holds it, so only one run uses the sandbox at a time
mise run e2e                        # every section but desktop and from
mise run e2e -- --from              # every section, from too, and base with every feature: the longest
mise run e2e -- --only images,gc    # just these sections
mise run e2e -- --clean             # delete the sandbox's cached images and tool images first
mise run e2e -- --every-feature     # base with every feature, as a run with from builds it
mise run e2e -- --slots 3           # the sections spread over 3 sandboxes that run at once
mise run e2e -- --slot 1            # run in slot 1's sandbox, its images as it has them
mise run e2e -- --newest-base       # base from Ubuntu's newest image and packages, in a sandbox of its own
mise run e2e -- --golden            # also capture the stubs' golden fixtures from the real tools

End-to-end tests in Go says how to run go test yourself, write a check and add a section.

--newest-base builds base as a user's first build does, in place of the pinned release that the other runs use, and Maintaining says when to run it and what to do when it fails. --golden writes the golden fixtures of this system into the checkout, for you to commit.

The sections so far:

  • images: building base and fixture layers, rebuilds, a failed script and Ctrl+C during a build, then base's recorded packages, each in the cache under its SHA-256, and base built again under the same key with ubuntu-mirror set to an address nothing answers on, whose apt reads only the build's own folder of packages.

  • project: devvm in a new project folder (under /tmp/devvm-go-e2e/p) makes a VM from base and opens a shell there, which reads its commands from devvm's input. The folder and the shared tools are mounted and nothing else is, there's no SSH agent, no Docker (no docker layer) and the hostname is the folder's. The ssh config lists it as devvm-web with its host keys pinned; through an ~/.ssh/config of the run's own that includes it under a Host * forwarding the agent, ssh devvm-web works, forwards no agent (a throwaway one), and refuses a changed host key. .git is locked (macOS) and git in the VM can still commit. devvm stop stops it and drops its entry, and on macOS reports and locks a submodule git folder the VM added. TestE2EExecQuoting in internal/backend/registry, which runs only there (DEVVM_E2E_VM names the VM), checks that arguments with spaces, quotes, $, newlines and globs, a folder and input reach the guest as given, through the Exec of the backend the VM's state records, so one test covers every backend. Then a VM from a devcontainer.json, with no ports by default: its forwardPorts said and not forwarded, none reaching this machine, its containerEnv in the shell and its commands, its postCreateCommand run once in the folder, its postStartCommand at each start (again after devvm restart), nothing written to the folder, and a changed file warned about without changing the VM. Then a claude VM with a fake agent config, history, git identity and token in a home of its own: devvm agent import copies the agent's settings into the sandbox's agent store without the history or the links out of its folder, the store's folder is mounted read-only and linked into the VM's home, and the home folder's isn't mounted, its settings are copied and its history isn't, the VM gets the git identity, the timezone and its hostname, and, open as it is, the token's placeholder and never the token. devvm agent save without a terminal shows the VM's changed settings.json as a diff and its new commands folder's file, then refuses and saves nothing, and after a yes it saves both into the store, but neither the VM's fake login beside them nor the folder's link out of it. Then SSH agents, with a home of their own and throwaway keys: a --ssh-agent VM uses a throwaway agent standing for yours; after devvm ssh-agent add and devvm ssh-agent devvm it keeps yours, in its shell and by name, until a restart, then uses only devvm's own agent's key, in its shells and by name; after devvm ssh-agent off, none.

  • gc: a VM from a folder named img-keep, which is named like an image, and a fixture layer edited after its build: devvm gc deletes the stale image and its record and an old tool image no VM lists (once there's a tools lock), and keeps base and the VM.

  • tools: first, the shared tools resolve to upstream's newest versions, with devvm's pinned mise (downloaded once), each download with its checksum. This section is the only one that uses the newest versions, and no other step checks for them (DEVVM_NO_TOOL_CHECK). At the section's end, e2e puts the pinned lock back. Then a node project's VM: node, npm, pnpm, bun and yarn at the locked versions, each a read-only EROFS image, the share read-only even for root, npm i -g into the VM's home, a non-login shell over SSH, an .nvmrc's own version, the tools mounted at boot without devvm, and a second node VM that builds nothing. Last, a .NET project's VM on the allowlist tier, chosen by its solution file: the shared SDK at the locked version from the share, a console project that restores a package from NuGet, builds and runs, dotnet tool install -g into ~/.dotnet/tools with the tool run from a non-login shell, every toolchain's environment and PATH folders in a login shell and a non-login one, a workload installed into ~/.dotnet, nothing of it blocked, and a global.json's own SDK installed into the VM.

  • network: a VM with Claude Code, Codex, opencode and pi and --network allowlist, a fake token in devvm's environment and a fake ~/.claude.json and Codex login in a home of its own, which devvm agent import copies into the sandbox's agent store, only yours to read. Its proxy runs and the self-check passed; its password was in no host process's arguments while devvm launched it (ps, sampled), and the guest has it; ssh devvm-net reaches it; direct connections fail, even as root, to an address and to other ports; an allowed host works and others, or other ports, are blocked; a line in the VM's policy file that reads as a deny but isn't a rule makes the running proxy refuse an allowed host, with no allow command in devvm network log --blocked, devvm network rm warns of it, and the host works again once it's gone; DNS fails at once; the host's loopback services are out of reach, directly or through the proxy; the proxy refuses requests without the VM's password; the token is nowhere in the VM, which has its own CA and the next one, its own placeholder and logins' copies with placeholders only; the proxy puts the token in for its host (for the VM's own placeholder only), an MCP server's header and Codex's key for theirs, over TLS the VM verifies; a second allowlist VM has CAs of its own, each VM trusts only its own and has no key, each proxy serves and presents only its own VM's CAs, and devvm rm deletes one VM's CAs and leaves the other's; the home folder's and the store's login files are unchanged. devvm agent save saves the VM's changed ~/.claude.json with the store's MCP header in place of its placeholder, and once the VM changes that server's URL it leaves the file out, so the store keeps the server as it was. devvm secret set github --stdin saves a fake token (in the Keychain on macOS, under the run's service, found through a link to ~/Library/Keychains in the VM's home), read from a file so it's in no process's arguments, and devvm secret lists it saved, while asking devvm secret for a get subcommand is refused without printing it; secret use github binds it to the running proxy at once, and on the next launch the VM has its own placeholder in GH_TOKEN, never the token, which the proxy puts in for api.github.com; secret unuse and rm take the binding and the token away. TestE2ESelfCheck in internal/netpolicy runs the self-check on the VM: it passes, then, once the VM is started outside devvm, it fails and stops the VM. devvm stop stops the VM and its proxy at once. devvm network open makes its next start direct, its proxy set in the guest and answering, and the open VM holds no real secret either: the token is nowhere in it, its environment and Codex's login hold only its placeholders, its proxy puts the token in over TLS the VM verifies with its own CA, and a request that goes around the proxy carries only the placeholder and gets a 401 from the token's host. Then devvm network internet and devvm network none change its tier at once, the VM running on. Restarted behind the run's company proxy on this machine's loopback, named in the shell's HTTPS_PROXY with a fake password that the check reads from a file, the guest has the proxy and reaches GitHub through it, while devvm's run logs hold the password only as <password> and Lima's ha.stderr.log only as stars. devvm network allowlist while it runs open shows it unenforced until devvm restart starts it confined; devvm network open while it runs confined keeps it on its proxy until it next starts. Behind a company proxy of the run's own that fakes OpenAI's token endpoint with a certificate from the run's CA, a login made in the VM is captured: the store gets the fake tokens and API key, and the VM gets placeholders. Then devvm agent login codex runs the real Codex's login in the VM, curl on this machine opens its callback with the state Codex's address names, through the forward of localhost:1455, devvm names the account the store saved, the VM's Codex holds only placeholders, and the forward is gone once the login ends, and gone too after an interrupted login. devvm agent login opencode --device-code runs the real opencode 2's Codex device code login in the VM, which the fake endpoint answers too, devvm says the store saved the login, and opencode auth export in the VM shows only placeholders. A second VM with opencode has OPENCODE_DISABLE_AUTOUPDATE=1 in its login shell, makes its database and imports a credential of its own, then devvm agent login opencode --api-key --provider openrouter --stdin saves a fake key from the first VM, and at the second VM's next launch its opencode has devvm's entry with the key's placeholder, never the key, beside its own credential, and once its database is deleted and made again, the next launch gives it the key's placeholder again. With a local server's fake key and a Copilot Enterprise login added to the store's opencode login, its next launch warns that both are withheld, and neither the VM's auth.json nor its opencode holds the key or the tokens. Once config.toml's [pass-keys] lists both providers under opencode, the launch notes the key as passed, the VM's auth.json and its opencode's database have it, and the login's tokens still stay out. pi runs in the network VM with PI_SKIP_VERSION_CHECK=1 and PI_TELEMETRY=0, in a login shell and in a non-login bash -c alike, and an install it can't write to, and its policy reaches its catalog at pi.dev. Its terminal UI, started in a terminal of script's, finds base's fdfind and rg and downloads nothing into ~/.pi/agent/bin, while with a PATH that has no fdfind the same start downloads fd, which shows the start reached that check. The same company proxy fakes Claude's token endpoint and Anthropic's API, which logs the token each request brings, or the x-api-key: devvm agent login pi --api-key --provider anthropic --stdin saves a fake key, the VM's pi holds only its placeholder, and pi's own request reaches the API with the key the proxy put in, which no log holds. The same company proxy fakes Groq's API too, and devvm agent login pi --api-key --provider groq --stdin saves a fake Groq key, the VM's pi holds only its placeholder, and pi's own request reaches Groq's API with the key in its Authorization, which no log holds. It fakes OpenAI's API as well, and after devvm agent login pi --api-key --provider openai --stdin saves a fake OpenAI key, the VM's pi holds only its placeholder, which starts with sk-, and pi's own request reaches OpenAI's API as an API key's, asking for max_output_tokens, with the key in its Authorization, which no log holds. The same company proxy fakes Gemini's API, and after devvm agent login pi --api-key --provider google --stdin saves a fake Gemini key, the VM's pi holds only its placeholder, and pi's own request reaches Gemini's API with the key in its x-goog-api-key and no key in its URL, which no log holds. Then devvm agent login opencode --api-key --provider groq --stdin saves a fake Groq key for opencode, the VM's opencode holds only its placeholder, and the request that opencode run makes reaches Groq's API with the key in its Authorization, which no log holds. Then claude setup-token's request, as curl, makes the fake token the claude secret and gives the VM its placeholder, and the API gets the token for it. Then devvm agent login claude runs the real Claude Code's claude auth login in the VM, its code pasted on devvm's input with the state its address names, the store keeps the fake login and the claude secret is gone, the VM's ~/.claude/.credentials.json holds only placeholders and its environment no token, and once the store's access token is due, the VM's next request makes the host refresh it at Claude's endpoint through the company proxy. This machine's TLS doesn't trust the run's CA, so that refresh fails, the store keeps its login and the proxy's log says so, and TestClaudeOAuthGet checks a refresh that succeeds. Last, a VM made with --network learn runs on the internet tier, shown as internet (learning), and reaches example.com and example.org; devvm network lock --json lists both, each with its port, and its next launch counts what it learned; devvm network lock --all adds exactly the hosts it learned to its own rules and gives it the allowlist tier at once, the VM running on, so example.com still works on 443, while its port 80 and example.net get a 403.

  • nix: the nix layer. A copy of assets/layers/nix.sh as a layer of the run's own, built behind a company proxy of the run's own, reaches Nix's releases through it and leaves no proxy settings for nix-daemon (and not the company proxy's password) anywhere on its image's disk. Then a folder with package.json, flake.nix and .envrc gets a VM with node on the nix layer (--layers nix) on the allowlist tier: Nix and direnv at their pins, a store that's root's, sandbox on with no fallback, trusted-users root alone and an untrusted user's --option substituters ignored, nix-daemon with the VM's own proxy in devvm's drop-in alone, nix run nixpkgs#hello from Nix's cache, a build in Nix's sandbox, sudo nix and nix over ssh, the flake's dev shell (nixpkgs at a pinned revision) loaded by direnv in an interactive shell, its node ahead of the shared node prompt after prompt and gone outside the folder, nix-direnv's cache in the VM's home with no .direnv in the folder, a fixed-output download from a host that isn't allowed refused with 403 and named by devvm-why, and after devvm network open and devvm restart, no drop-in and no proxy for the daemon.

  • from: run with a docker that isn't running, so nothing comes from Docker. Its container images go by their pinned digests, as node:24@sha256:…, so devvm looks them up nowhere, except the company proxy's alpine:3.21, which keeps its tag so that devvm's registry lookup is checked too. A VM from node:24 with node, python and Claude Code on the docker and nix layers (Debian 12, in a home of its own) boots, with its base keyed by the pinned digest, its node, python and claude at the locked versions, GNU tar as its commands find it, its tool images built in a clone of devvm's own Ubuntu base when the run builds them, the docker layer's Docker from Docker's Debian repository, and the nix layer's Nix under systemd running nix run nixpkgs#hello and a build in Nix's sandbox; a VM from alpine:3 with node and dotnet, which its package.json and global.json call for, on the docker, nix and desktop layers runs node and pnpm from musl tool images, and dotnet's musl SDK with ICU, which makes and runs a console project, built in its own base and keyed and recorded by its digest, the docker layer's Docker on OpenRC, the desktop layer's programs from Alpine's packages, with no crashed services, and the nix layer's Nix as an OpenRC service, with nix run nixpkgs#hello and a sandboxed build, then after devvm network allowlist and devvm restart a download only its daemon makes from a host that isn't allowed refused with the proxy's 403, and with GNU tar as its commands find it, devvm history import puts an export into it, while an export with a path outside the agents' history imports nothing there; base builds from ubuntu:26.04; and the build VM and its temporary folders are gone.

  • link: links between VMs, each check the end-to-end proof of a row of the threat check in the design note. It runs devvm with a soft limit of 256 open files, macOS's default, as the link sessions it starts get that limit too, and it makes two small open targets, each forwarding no port and running servers on its own 127.0.0.1 (/var/tmp/e2e-link.pl, in perl, which every base has), and a client that forwards every port. Each of the three reserves the link checks' ports (ip_local_reserved_ports), so Linux never gives one to a connection's own end, where a connection that just ended would hold it for a minute and a later server or ssh -R couldn't bind it. sshd -T in each VM shows remote forwards allowed on 127.77.*:* alone, at the address the host asks for, and the client's own Lima rules ignore every port. A port the target doesn't publish is refused by devvm link add, and once a port is published, devvm link add on the running client reaches it within seconds as NAME:PORT and NAME.devvm.internal:PORT, by curl and by a raw TCP client (bash's /dev/tcp), while with --as NAME the target's folder name doesn't resolve. Two targets on one port are each reached by their own name, port 80 is linked on port 80, devvm link and devvm link publish list what they hold with "version": 1 in their --json, and devvm network allowlist is refused for the client while it links to open targets. A published port that isn't linked has nothing listening for it, devvm link unpublish refuses the link's next connection, logs it and names the client, and devvm link rm takes the listener away within seconds. In the client, sshd listens only on its own port and the links' addresses, and nothing from a link listens on 127.0.0.1, ::1 or every address, so this machine gets no forward of a link, while a server of the client's own on 127.0.0.1 with a link's port is forwarded as usual. Each link's socket is mode 600 in the run folder of mode 700, and the link session and every process it starts listen on no TCP port and connect only to the VMs' ssh ports. ssh -R into the client binds nothing outside 127.77.0.0/16 (rfwd_links). A program in the client that holds a link's address first fails that link alone with link_port_taken, 256 connections at once, past the socket's backlog of 128 on macOS, are all carried, and a 257th is refused and logged as link_limit. Root in the client then loosens its sshd and the link session connects again: with PermitListen any the client binds only the links' addresses, because the host asks for nothing else, and with GatewayPorts yes too, the link session still listens on no TCP port of this machine and connects only to the VMs' sshd. devvm network log shows the links' connections and refusals. A stopped target refuses the connection, logs link_target_stopped and stays stopped, and the client's launch warns of it. Once it's restarted, the link works again. devvm rm of the target removes the client's link, names the client and removes its sockets, and a VM made again in that folder isn't linked. Then the client and one target get the allowlist tier, the target while it runs. Until the target restarts, devvm ls shows it unenforced, the client's next connection is refused and logged as unenforced while the target's server runs, and devvm link add and the client's launch warn of it (link_target_unenforced). Once both have restarted, the client reaches its link by curl through its proxy settings and by a raw TCP client while a direct connection fails. A link added while the client runs is reached at once by curl through its proxy, by GET and CONNECT, with no link name in NO_PROXY and the client's boot and host keys unchanged, and the client's proxy refuses names, ports and addresses that aren't on its own list, while the target's proxy refuses the client's link name. devvm link add refuses an open target, devvm network open is refused for the target, and with the rule broken by hand in the target's state the next connection is refused and the client's launch warns and runs without the link until the rule holds again. In the --from tier, an Alpine client reaches its link to port 80. devvm rm of the client leaves no link session, socket, pid file, log or link state.

Every section but tools uses the shared tools' versions pinned in tests/e2e-mise.lock, for both architectures' glibc and musl VMs, and the --from checks start from container images pinned by digest in tests/e2e/from_test.go (fromNodeDigest, fromAlpineDigest and fromUbuntuDigest). The images built from them stay valid until a pin moves. base starts from the dated release of Ubuntu's cloud image that e2eUbuntuRelease in tests/e2e/sandbox_test.go names, given to devvm as DEVVM_UBUNTU_RELEASE, in place of the newest that a user's devvm pins, so base's key stays the same between runs and on every machine of one architecture. Its packages are those its key recorded at its first build in the sandbox, which stay in the sandbox's package cache through --clean, so base built again under the same key installs the same packages until assets/ or the release changes its key. scripts/bump.sh e2e-tools moves the lock to upstream's newest versions, resolved with devvm's pinned host mise, scripts/bump.sh e2e-from moves the digests to what Docker Hub has for each tag, and scripts/bump.sh e2e-ubuntu moves the release to the newest Ubuntu lists; scripts/bump.sh --check shows them against upstream. The lock's first line is the SHA-256 of the assets/shared-tools/mise.toml it was resolved from, and a run stops at once when that file has changed since, until scripts/bump.sh e2e-tools resolves the lock again.

base, the --from bases and the shared tool images stay cached between runs, except what a rebuild or gc deletes: every stale image in the sandbox (other selections' bases, whose features differ, among them) and every unused tool image (an earlier from run's musl ones, and the tools section's newest versions where they differ from the pins); every other VM a run makes is deleted at its end, and its project folders are unlocked and deleted. Each check prints [n/N], how long it took and the time left as the last complete run of each of its sections measured it, and a heartbeat every minute shows the latest output. e2e keeps each section's times in a file of its own in slot 0's state folder, timings/plain/SECTION, or timings/features/SECTION for a run whose base has every feature, because that run also checks base's features. So a run of any selection, in any slot, estimates from and compares with the sections it runs. A check fails on its first failure, except the few marked Flaky, which flake on timing, such as the network section's check that the proxy's password was in no host process's arguments, and the link section's 256-connection check and its stopped-target check. When one of these fails, e2e shows its output and runs it once more, and a second failure fails it. Its result says retried once, its line in the timings has a third field, retried, and the summary counts the retried checks and names each one. A check a run has nothing for is counted as SKIP: base's features, with base cached. A section that runs fewer checks than its last complete run with the same tests/e2e Go files fails the run, because an error ended it early, and e2e keeps the times it had. After you edit those files, each section's first complete run sets the count the next runs compare with. Checks look for devvm's messages with devvm _msg, never by their wording. The Go tests that need a real VM or desktop, TestE2EExecQuoting, TestE2ESelfCheck and TestE2EDesktop, skip unless their DEVVM_E2E_* variables are set, and e2e runs each of them through s.GoE2E, which sets those variables in the test's environment, so a value such as the desktop's password is in no process's arguments.

Each check's command has a time limit, counted from when it starts: three times the check's longest time in its section's last complete run, at least 2 minutes, or 10 minutes for a check with no time yet. The checks that build base or a --from base, which Builds() marks, get at least an hour, because their last time may have been a cached build. The steps between two checks, such as the launches that build tool images, get an hour too. When a check runs past its limit, the heartbeat stops the processes it started, with TERM as Ctrl+C would and then KILL 30 seconds later, and the check fails with the heartbeat's last line in its output. When the steps before a check run past their limit, the heartbeat stops their processes the same way, and that check fails without running. Either way, the run goes on to the next check and then to its usual cleanup.

Slots

A host with spare cores and memory can run the sections at once, each set in a sandbox of its own called a slot. mise run e2e -- --slots N spreads the chosen sections over N slots, from 1 to 9, and runs each slot as a --slot K run of its own, all at the same time. The default is one slot, which is the run described above. Slot 0 is the sandbox in the table, and slot K adds -K to its Lima home, state folder, Keychain service and lock, as ~/.lt-e2e-go-1, /tmp/devvm-go-e2e-1, devvm-go-e2e-1 and /tmp/devvm-go-e2e-1.lock. Each fixed port the checks use is slot 0's plus 100 times the slot, so slot 1's servers use 47260 where slot 0's use 47160. Slot 0's ports run from 47160 to 47199, from 47240 to 47249, and 47613, 18765 and 18766, so no two slots ever share one.

e2e places the longest sections first, each in the slot with the least time so far, using each section's time from its last complete run. A section that has never run gets a guess, from 2 minutes for gc and clone to 30 minutes for from. link always goes in the same slot as from when both run, because in the --from tier link's Alpine client starts from the image that from builds. Each slot runs its own sections in the usual order, and a slot left without a section isn't started. When go isn't on your PATH, e2e finds mise's Go once and puts its folder first on the slots' PATH, because slots that each ran mise exec at the same time would each install the repo's tools over one another. With --from, e2e passes --every-feature to every slot, so each slot's base has every feature, as a single --from run's has.

Before the slots start, e2e takes every slot's lock and gives each other slot what slot 0 has and it lacks: every image's Lima instance and record, every tool image and its record, and devvm's caches. It clones the large files and never copies them whole: on macOS each one is an APFS clone, which needs both folders on one APFS volume, and on Linux a reflink. The records and the --from digests are small files, so e2e copies them. When a file can't be cloned, as on a Linux host whose /tmp is tmpfs, e2e says so and that slot builds its own. With --clean, nothing is cloned, and each slot deletes its own cached images instead. A --slot K run of your own uses that slot's images as they are.

Each slot's output appears as it comes, each line led by its slot's number, such as [1], and stays in the slot's e2e.log. When every slot has ended, e2e prints each slot's sections, results and time, then the sums: checks passed, failed, skipped and retried, the failed checks by name, and the time the whole run took. The run fails when any slot fails or ends without its results. TERM or Ctrl+C stops every slot with TERM, and each one cleans up as a single run does.

Testing on other hosts says how many slots each kind of host runs. Testing on other hosts also covers Linux hosts, x86_64 and the checks to run by hand.