mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
doctor's policy warnings (netpolicy.NotRules) listed the VMs with state.VMNames, which fails whole for one state it can't read, so one broken vm.json made doctor skip every VM's policy warnings. So did devvm network's warnings about every VM (allowlists for -g, and OtherBinaries). They now use state.ReadableVMs, the VMs whose state reads, which leaves the broken one out and the rest in; VMNames stays strict for what must count every VM, such as ports. A VM folder doctor can't read got two warnings, vms_unreadable from state.VMFolderProblems and vm_state_broken from vm.StateProblems; VMFolderProblems now leaves it to the latter, which names the VM and why. cursorChanges, the verbs refused in Cursor's DashboardService, AutomationsService and BackgroundComposerService, gains merge, fork, write, pin, unpin, rerun, confirm, request, release, acquire, activate, deactivate, notify, make, open, ensure, park, copy, bulk, advance, abort, wake, snapshot, seed, reply, opt, hand, fail, use, skip, decide, unshare, undelete, unpublish, unprepare, unresolve, enroll, unenroll, upgrade, suspend, switch, duplicate, dismiss, deregister, deliver, decline, convert, close, append, execute, provision, mutate, inject, finish, finalize, reassign, reinstall, reject, renew, reorder, reparent, replace, resend, rmdir, report and record. Each was checked against all 1,463 methods of those services in 2026.11.17-f532c45, read and not run: every one of the 102 methods they match changes something, none only reads, and the CLI calls none (Submit, Resolve, Check, Batch and the like stay off, as their methods read or the CLI calls them). fixture_v010_logs' capped.sh loop and network.txtar's sleeps around the squatting proxy now wait with wait_until. Tests: TestNotRules and TestOtherBinaries (beside a state that can't be read), TestVMFolderProblems, doctor.txtar (an unreadable VM folder, one warning), TestCursorChangingVerbs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
179 lines
7.1 KiB
Plaintext
179 lines
7.1 KiB
Plaintext
# doctor: what Lima needs on this machine and how to get what's missing,
|
|
# the features Lima gives VMs, and whether Docker is there. --json prints
|
|
# what it found as JSON, for scripts, and nothing else.
|
|
env ALL=$PATH
|
|
# A Linux host that can pin .git in QEMU's namespace, until the section
|
|
# that tests one that can't.
|
|
env DEVVM_PINS=on
|
|
chmod 0755 brew/brew
|
|
chmod 0755 broken/limactl
|
|
chmod 0755 qemu/qemu-system-aarch64
|
|
chmod 0755 qemu/qemu-system-x86_64
|
|
chmod 0755 qemu/qemu-img
|
|
|
|
# Everything there: only limactl --version runs.
|
|
exec devvm doctor
|
|
stdout '^FEATURE +SUPPORT\n'
|
|
stdout '^build-image +native\n'
|
|
stdout '^egress-proxy +native\n'
|
|
stdout '^ports +emulated\n'
|
|
stdout '^ports-all +emulated\n'
|
|
stdout '^agent-toggle +native\n'
|
|
stdout '^disk +native\n'
|
|
stdout '^docker-layer +native\n'
|
|
stdout '^docker_found\n'
|
|
stdout '^doctor_ok backend=lima version=\S+\n\z'
|
|
! stderr .
|
|
stub_calls
|
|
stdout '^limactl --version\n\z'
|
|
|
|
# git that takes any folder shaped like a git folder for a bare repo gets
|
|
# a tip, which isn't a warning, and --json lists it apart; the sandbox's
|
|
# own git takes one only when it's named.
|
|
exec git config --global --unset safe.bareRepository
|
|
exec devvm doctor
|
|
stdout '^doctor_git_bare$'
|
|
! stderr .
|
|
exec devvm doctor --json
|
|
stdout '^ "tips": \[\n "doctor_git_bare"\n \],$'
|
|
exec git config --global safe.bareRepository explicit
|
|
|
|
exec devvm doctor --json
|
|
stdout '^{\n "version": 1,\n "backend": "lima",\n "problems": \[\],\n "warnings": \[\],\n "tips": \[\],\n "docker": true,\n'
|
|
stdout '^ "ports": "emulated",$'
|
|
! stderr .
|
|
|
|
# What in the VMs' folder isn't a VM's, warned about and left as it is:
|
|
# a file, a folder that isn't named by a hash, and a VM's folder without
|
|
# vm.json, as a devvm that stopped part way leaves.
|
|
mkdir $VMS/devvm-old $VMS/0123456789abcd
|
|
cp default.yaml $VMS/notes.txt
|
|
cp default.yaml $VMS/0123456789abcd/lock
|
|
exec devvm doctor
|
|
stderr '^devvm: vm_folder_stateless path=\S+/vms/0123456789abcd$'
|
|
stderr '^devvm: vms_stray path=\S+/vms/devvm-old vms=\S+/vms$'
|
|
stderr '^devvm: vms_stray path=\S+/vms/notes.txt vms=\S+/vms$'
|
|
stdout '^doctor_ok '
|
|
exec devvm doctor --json
|
|
stdout '^ "warnings": \[\n "vm_folder_stateless path=\S+/vms/0123456789abcd",\n "vms_stray path=\S+/vms/devvm-old vms=\S+/vms",\n "vms_stray path=\S+/vms/notes.txt vms=\S+/vms"\n \],$'
|
|
exists $VMS/devvm-old $VMS/notes.txt $VMS/0123456789abcd/lock
|
|
rm $VMS
|
|
|
|
# A VM whose state devvm can't read, warned about, naming it and why,
|
|
# which names its file, and left as it is: a vm.json that isn't JSON, named by
|
|
# its folder, and one whose section its package can't read, named by the
|
|
# VM. A VM whose state reads gets no warning.
|
|
mkdir $VMS/0123456789abcd $VMS/0123456789abce $VMS/0123456789abcf
|
|
cp broken.json $VMS/0123456789abcd/vm.json
|
|
cp badsection.json $VMS/0123456789abce/vm.json
|
|
cp good.json $VMS/0123456789abcf/vm.json
|
|
exec devvm doctor
|
|
stderr '^devvm: vm_state_broken name=0123456789abcd why=.*/vms/0123456789abcd/vm.json.*$'
|
|
stderr '^devvm: vm_state_broken name=devvm-bad-0123456789abce why=.*/vms/0123456789abce/vm.json.*size.*$'
|
|
! stderr '0123456789abcf'
|
|
stdout '^doctor_ok '
|
|
exec devvm doctor --json
|
|
stdout '"vm_state_broken name=0123456789abcd why=.*/vms/0123456789abcd/vm.json.*",'
|
|
cmp $VMS/0123456789abcd/vm.json broken.json
|
|
cmp $VMS/0123456789abce/vm.json badsection.json
|
|
# A VM's folder devvm can't read: one warning, naming it and why, not two.
|
|
mkdir $VMS/0123456789abd0
|
|
cp good.json $VMS/0123456789abd0/vm.json
|
|
chmod 0000 $VMS/0123456789abd0
|
|
exec devvm doctor
|
|
stderr -count=1 '^devvm: .*0123456789abd0'
|
|
stderr '^devvm: vm_state_broken name=0123456789abd0 why=.*/vms/0123456789abd0/vm.json.*$'
|
|
chmod 0700 $VMS/0123456789abd0
|
|
rm $VMS
|
|
|
|
# A Linux host that can't pin .git: read-only-paths is none, a warning
|
|
# says why, and doctor doesn't fail for it. macOS locks on the host, so it
|
|
# has no such feature and no warning.
|
|
exec devvm doctor
|
|
[linux] stdout '^read-only-paths +native\n'
|
|
[darwin] stdout '^read-only-paths +none\n'
|
|
env DEVVM_PINS='refused by this kernel'
|
|
exec devvm doctor
|
|
stdout '^read-only-paths +none\n'
|
|
[linux] stderr '^devvm: doctor_pins_'
|
|
[darwin] ! stderr .
|
|
stdout '^doctor_ok '
|
|
exec devvm doctor --json
|
|
stdout '^ "read-only-paths": "none",$'
|
|
[darwin] stdout '^ "warnings": \[\],$'
|
|
[linux] stdout '^ "warnings": \[\n "doctor_pins_'
|
|
env DEVVM_PINS=on
|
|
|
|
# No flag or file chooses the backend.
|
|
! exec devvm doctor --backend lima
|
|
stderr '^devvm: flag_unknown command=devvm doctor flag=--backend$'
|
|
! stdout .
|
|
|
|
# No Lima, no Homebrew, no Docker: what to install, and it fails.
|
|
# QEMU's there, which only Linux checks.
|
|
env PATH=$WORK/qemu${:}$DEVVM_BIN
|
|
! exec devvm doctor
|
|
stdout '^FEATURE +SUPPORT\n'
|
|
stdout '^docker_missing\n'
|
|
! stdout doctor_ok
|
|
stderr '^devvm: program_missing name=Lima program=limactl$'
|
|
exec devvm doctor --json
|
|
stdout '^ "key": "lima",\n "fix": null,\n "message": "program_missing name=Lima program=limactl"\n'
|
|
stdout '^ "docker": false,$'
|
|
! stderr .
|
|
|
|
# Every command that needs the backend stops at the first problem.
|
|
! exec devvm build base
|
|
stderr '^devvm: program_missing name=Lima program=limactl$'
|
|
mkdir p
|
|
cd p
|
|
! exec devvm --network open
|
|
stderr '^devvm: program_missing name=Lima program=limactl$'
|
|
cd ..
|
|
|
|
# With Homebrew, its command.
|
|
env PATH=$WORK/brew${:}$WORK/qemu${:}$DEVVM_BIN
|
|
exec devvm doctor --json
|
|
stdout '^ "key": "lima",\n "fix": "brew install lima",\n "message": "program_missing_fix fix=brew install lima name=Lima program=limactl"\n'
|
|
|
|
# A limactl that doesn't run, as one built for another processor.
|
|
env PATH=$WORK/broken${:}$WORK/brew${:}$WORK/qemu${:}$DEVVM_BIN
|
|
exec devvm doctor --json
|
|
stdout '^ "key": "lima",\n "fix": "brew reinstall lima",\n "message": "program_broken_fix command=limactl --version fix=brew reinstall lima name=Lima"\n'
|
|
! exec devvm doctor
|
|
stderr '^devvm: program_broken_fix command=limactl --version fix=brew reinstall lima name=Lima$'
|
|
|
|
# One of Lima's global configs in devvm's Lima home, listed after the
|
|
# rest.
|
|
mkdir $DEVVM_LIMA_HOME/_config
|
|
cp default.yaml $DEVVM_LIMA_HOME/_config/default.yaml
|
|
! exec devvm doctor
|
|
stderr '^devvm: program_broken_fix command=limactl --version fix=brew reinstall lima name=Lima\ndevvm: lima_global_config files=\S+/_config/default.yaml\n\z'
|
|
env PATH=$ALL
|
|
! exec devvm doctor
|
|
stderr '^devvm: lima_global_config files=\S+/_config/default.yaml$'
|
|
exec devvm doctor --json
|
|
stdout '^ "problems": \[\n {\n "key": "lima-config",\n "fix": null,\n "message": "lima_global_config files=\S+/_config/default.yaml"\n }\n \],$'
|
|
|
|
-- brew/brew --
|
|
#!/bin/sh
|
|
-- broken/limactl --
|
|
#!/bin/sh
|
|
exit 126
|
|
-- qemu/qemu-system-aarch64 --
|
|
#!/bin/sh
|
|
-- qemu/qemu-system-x86_64 --
|
|
#!/bin/sh
|
|
-- qemu/qemu-img --
|
|
#!/bin/sh
|
|
-- default.yaml --
|
|
networks: [{vzNAT: true}]
|
|
-- broken.json --
|
|
{"version": 1, "name": "devvm-x-0123456789abcd",
|
|
-- badsection.json --
|
|
{"version": 1, "id": "aa", "name": "devvm-bad-0123456789abce", "image": "base", "dir": "/nowhere/bad",
|
|
"backend": "lima", "created": "2026-11-08T15:54:56Z", "made_by": "0.1.0", "size": {"cpus": 4}}
|
|
-- good.json --
|
|
{"version": 1, "id": "bb", "name": "devvm-good-0123456789abcf", "image": "base", "dir": "/nowhere/good",
|
|
"backend": "lima", "created": "2026-11-08T15:54:56Z", "made_by": "0.1.0", "size": {"cpus": "4"}}
|