Files
w3cjandClaude Opus 5.5 ecd266c7d3 test(cli): one wait for the scripts; the docs release job installs only what it builds with
The scripts waited with copies of the same loop: desktop.txtar's and
nix_cache.txtar's waitfor files, and sh -c loops in link_life,
fixture_v010_links, fixture_v010_small, ports and ports_stopped, each
with its own interval and limit. They now use one testscript command,
wait_until SCRIPT, which runs sh -c SCRIPT every 100 ms until it
succeeds, for up to 90 s, and fails at once when every background
command has ended, as wait_file does, or when SCRIPT exits 100
(waitGiveUp, a status no tool the scripts run gives), as the links
check does when its session has ended. Contributing's tests page names
it beside wait_file, whose limit it now says is 60 s.

The docs workflow's release job installed every tool in the tag's
mise.toml. It now installs only Go, Hugo by the name the tag gives it
(hugo-extended before Hugo 0.170) and Node when the tag draws its
diagrams, with --locked as mise-action did, picking them with mise's
own reading of the tag's mise.toml (mise ls --current --json, the tag's
file alone), and fails when the tag names no Hugo. MISE_AUTO_INSTALL is
off for the job, so mise run docs:diagrams and the shims install
nothing more, and a tool the pick missed fails the build. This job runs
only at a release, so it hasn't run yet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 23:07:04 -07:00

172 lines
6.2 KiB
Plaintext

# devvm ports: which ports a folder's VM forwards, changed at once: a
# stopped VM's from its next start, a running one's forwarder started
# again with them; with -g, what new VMs forward (the ports file).
# No VM yet.
project web
! exec devvm ports
stderr '^devvm: no_vm_ports dir=\S*/web$'
# A bad LIST is refused before devvm looks for the VM.
! exec devvm ports banana
stderr '^devvm: port_invalid value="banana"$'
! stderr no_vm_ports
! exec devvm ports add all
stderr '^devvm: ports_list_needed value="all"$'
! stderr no_vm_ports
# -g: what new VMs forward, all until it's set; add and rm change it.
# No VM is looked at.
stub_reset
exec devvm ports -g
stdout '\Aall # devvm: default\n\z'
exec devvm ports -g 3000-3999
stdout '^==> ports_default ports=3000-3999$'
exec devvm ports add -g 5173
grep '^ "ports": "3000-3999,5173",?$' $DATA/settings.json
exec devvm ports -g
stdout '\A3000-3999,5173 # devvm: settings\.json\n\z'
exec devvm ports -g --json
stdout '\A{\n "version": 1,\n "ports": "3000-3999,5173",\n "source": "settings.json"\n}\n\z'
# config.toml's ports win; -g shows where they came from, and refuses to
# change them, naming the file and the key.
cp $WORK/ports.toml $CFG/config.toml
exec devvm ports -g
stdout '\A8000-8010 # \S*/config/devvm/config\.toml\n\z'
exec devvm ports -g --json
stdout '"source": "config.toml"'
! exec devvm ports add -g 9000
stderr '^devvm: set_in_config file=\S*/config/devvm/config\.toml key=ports$'
rm $CFG/config.toml
! exec devvm ports -g --json all
stderr '^devvm: json_shows_only command=devvm ports$'
! exec devvm ports -g add all
stderr '^devvm: ports_list_needed value="all"$'
! exec devvm ports -g rm none
stderr '^devvm: ports_list_needed value="none"$'
exec devvm ports -g rm 3000-3999,5173
stdout '^==> ports_default ports=none$'
exec devvm ports -g all
! stub_calls
# A new VM gets the default. Running: devvm ports shows what it forwards,
# and a change starts its forwarder again with the new ports, the VM
# running on: no stop, start or edit of Lima's. (Its hostagent here: the
# test's runner, so the forwarder runs on. Its ports are free here, as
# a fixed one may be a program's, which a running VM's change leaves out.)
exec sh -c 'echo $PPID > "$STUB_DIR/hostagent"'
free_port P Q
exec devvm --network open --no-git-protect
vm_name WEB web
vm_state $WEB_dir/vm.json
! stdout '^ports\.forward'
exec devvm ports
stdout '\Aall\n\z'
! stderr .
stub_reset
exec devvm ports $P
stdout '^==> ports_forwarding ports='$P' vm=devvm-web-[0-9a-f]{14}$'
! stderr .
stub_calls
! stdout 'limactl (edit|stop|start)'
exec sh -c 'ps -axww -o command= | grep -- "[_]ports -vm $WEB "'
stdout ' -only '$P'$'
exec devvm ports
stdout '\A'$P'\n\z'
! stderr .
exec devvm ports all
stdout '^==> ports_forwarding ports=all vm=devvm-web-[0-9a-f]{14}$'
exec sh -c 'ps -axww -o command= | grep -- "[_]ports -vm $WEB "'
! stdout ' -only '
# None: its forwarder stops.
exec devvm ports none
stdout '^==> ports_forwarding ports=none vm=devvm-web-[0-9a-f]{14}$'
wait_until '! ps -axww -o command= | grep -q -- "[_]ports -vm $WEB "'
exec devvm ports $P
# Stopped: changed at once, in the VM's state, which its next start
# gives devvm's forwarder; Lima's config is left alone (its own forwards
# are off).
exec limactl stop $WEB
stub_reset
exec devvm ports add 8000-8010
stdout '^==> ports_now ports='$P',8000-8010 vm=devvm-web-[0-9a-f]{14}$'
stub_calls
! stdout 'limactl edit'
! exists $WEB_dir/backend
exec devvm ports
stdout '\A'$P',8000-8010\n\z'
! stderr .
stub_reset
exec devvm ports rm $P
stdout '^==> ports_now ports=8000-8010 vm=devvm-web-[0-9a-f]{14}$'
exec devvm ports rm 8000-8010
stdout '^==> ports_now ports=none vm=devvm-web-[0-9a-f]{14}$'
vm_state $WEB_dir/vm.json
stdout '^ports\.forward=none$'
! exec devvm ports rm 5173
stderr '^devvm: port_not_listed port=5173 ports=none$'
! exec devvm ports 0
stderr '^devvm: port_invalid value="0"$'
exec devvm ports all
stdout '^==> ports_now ports=all vm=devvm-web-[0-9a-f]{14}$'
exec devvm ports add 5173
stderr '^devvm: ports_all_already$'
! exec devvm ports rm 5173
stderr '^devvm: ports_rm_all$'
stub_calls
! stdout 'limactl edit'
exec devvm ports
stdout '\Aall\n\z'
# --ports on it is ignored, with a warning naming devvm ports.
exec devvm --ports none
stderr '^devvm: new_vm_flags_ignored_run command=devvm ports LIST flags=--ports vm=devvm-web-[0-9a-f]{14}$'
# A listed port a program on this machine has, on any address, isn't
# forwarded, warned, by a start or a running VM's change that finds it so:
# the forwarder forwards the rest. Lima's config is left alone.
listen_any TAKEN
exec limactl stop $WEB
exec devvm ports $P,$TAKEN
! stderr ports_taken
stub_reset
exec devvm
stderr '^devvm: ports_taken count=1 ports='$TAKEN' vm=devvm-web-[0-9a-f]{14}$'
stub_calls
! stdout portForwards
exec sh -c 'ps -axww -o command= | grep -- "[_]ports -vm $WEB "'
stdout ' -only '$P'$'
exec devvm ports
stdout '\A'$P','$TAKEN'\n\z'
exec devvm ports add $Q
stdout '^==> ports_forwarding ports='$P','$TAKEN','$Q' vm=devvm-web-[0-9a-f]{14}$'
stderr '^devvm: ports_taken count=1 ports='$TAKEN' vm=devvm-web-[0-9a-f]{14}$'
exec sh -c 'ps -axww -o command= | grep -- "[_]ports -vm $WEB "'
stdout ' -only '$P','$Q'$'
# devvm ports says why the forwarder couldn't take each listed port, as
# its record says: in use, past its limit of forwards, or refused by this
# machine, such as a port below 1024 on Linux. An older devvm's record,
# which doesn't say why, warns of none.
exec sh -c 'printf "%s\n\n%s\n%s\n%s\n" "$(head -n1 "$WEB_dir/run/ports.pid")" '$TAKEN' '$Q' '$P' > "$WEB_dir/run/ports.forwarded"'
exec devvm ports
stderr '^devvm: ports_taken count=1 ports='$TAKEN' vm=devvm-web-[0-9a-f]{14}$'
stderr '^devvm: ports_limit count=1 limit=256 ports='$Q' vm=devvm-web-[0-9a-f]{14}$'
stderr '^devvm: ports_refused count=1 ports='$P' vm=devvm-web-[0-9a-f]{14}$'
exec sh -c 'printf "%s\n\n%s\n" "$(head -n1 "$WEB_dir/run/ports.pid")" '$P','$Q' > "$WEB_dir/run/ports.forwarded"'
exec devvm ports
! stderr 'ports_(taken|limit|refused)'
# Stopped, its forwarder stops too.
exec devvm stop
wait_until '! ps -axww -o command= | grep -q -- "[_]ports -vm $WEB "'
# Completion: the keywords and add and rm.
exec devvm __complete ports ''
stdout '^all$'
stdout '^none$'
stdout '^add\t'
stdout '^rm\t'
-- ports.toml --
ports = "8000-8010"