Files
devvm/testdata/script/stop.txtar
T
w3cjandClaude Opus 5.5 ad99868604 test(stop): keep the proxy's hostagent alive until devvm stop
The limactl stub's start wrote devvm's own pid as the VM's hostagent, so
a proxy that saw it before devvm returned (devvm still running at the
proxy's first 3 s lifeline check, under load) exited at its next check,
and stop.txtar's kill -0 found it gone. The stub now takes a lasting pid
from $STUB_DIR/hostagent; stop.txtar gives it the test's runner.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 23:44:45 -06:00

55 lines
1.7 KiB
Plaintext

# devvm stop: stops the folder's VM and its proxy, then checks .git as a
# launch that finds it stopped does (locking it again on macOS), and drops
# the VM from devvm's ssh config.
env DEVVM_MESSAGES=names
env VMS=$XDG_DATA_HOME/devvm/vms
env RUN=$XDG_DATA_HOME/devvm/run
env CFG=$XDG_CONFIG_HOME/devvm
# No VM.
mkdir $WORK/web
cd $WORK/web
! exec devvm stop
stderr '^devvm: no_vm dir=\S*/web$'
! exec devvm stop now
stderr '^devvm: usage_error '
# A running VM with network policy: it stops, then its proxy. (Its
# hostagent here: the test's runner, which runs on, so the proxy runs until
# stopped; the stub's would be gone after devvm.)
exec git init -q
exec sh -c 'echo $PPID > "$STUB_DIR/hostagent"'
exec devvm --network-policy base
exec sh -c 'cat "$CFG/ssh_config"'
stdout '^Host devvm-web devvm-web-[0-9a-f]{14}$'
exec sh -c 'cat "$RUN"/devvm-web-*.proxy.pid > "$WORK/pid" && kill -0 "$(cat "$WORK/pid")"'
exec sh -c ': > "$STUB_LOG"'
exec devvm stop
stdout '^==> stopped vm=devvm-web-[0-9a-f]{14}$'
stub_calls
stdout '^limactl stop devvm-web-[0-9a-f]{14}$'
[darwin] stdout '^limactl stop devvm-web-[0-9a-f]{14}\n(.*\n)*chflags -R -P uchg /\S*/web/\.git/hooks$'
! stdout 'limactl (start|edit)'
! exec sh -c 'kill -0 "$(cat "$WORK/pid")"'
exec sh -c 'cat "$CFG/ssh_config"'
! stdout devvm-web
# Already stopped: said; .git is checked all the same.
exec sh -c ': > "$STUB_LOG"'
exec devvm stop
stdout '^==> already_stopped vm=devvm-web-[0-9a-f]{14}$'
! stdout '==> stopped'
stub_calls
! stdout 'limactl stop'
# A VM made for an earlier folder at this path isn't stopped.
cd $WORK
rm web
mkdir web
cd web
exec sh -c ': > "$STUB_LOG"'
! exec devvm stop
stderr '^devvm: vm_other_folder vm=devvm-web-[0-9a-f]{14} was=/\S*/web$'
stub_calls
! stdout 'limactl stop'