Files
devvm/testdata/script/setup.txtar
T
w3cjandClaude Opus 5.5 d94929523d feat(vm): a new VM shows a summary, then asks whether to customize it
Before devvm makes a new VM it shows a summary of what the VM gets:
each toolchain, coding agent and layer with why (the file that calls for
it, devvm setup, config.toml or the flag that gave it), its size, network
tier and ports, and the devcontainer.json it's made as. Where the picker
shows (CanPick) and something is left to choose, it asks
"Customize it? [y/N]": Enter makes the VM as shown; y opens the picker
(a part a flag gave greyed out), then the network tier question when no
tier is given or saved, then the VM's CPUs and memory (for this VM
alone). Without a terminal or with --no-input the summary ends with the
flags that choose others. The summary replaces new_vm_gets and
devcontainer_using. devvm's first run asks its size and agents first,
as before, then shows the summary.

A test build's DEVVM_PICK_ON_PIPE shows the picker with a terminal on
stdin alone, so testscript's ttyin reaches it (up_customize.txtar).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 16:48:53 -07:00

201 lines
7.6 KiB
Plaintext

# setup: base's features, and new VMs' size, network policy, agents and
# layers (all asked in a terminal, which Go tests cover; without one, the
# size and network policy aren't asked and the features are kept, or
# every one until they're chosen; --features, --agents and --layers
# without asking), each saved in settings.json. A new choice of features says base rebuilds, and once
# images are built that devvm gc deletes the old ones.
env SAVED=$DATA/settings.json
# Kept: none chosen; no size asked.
exec devvm setup
stdout '^==> base_features_none$'
! stdout base_will_rebuild
! stdout 'size_question|size_defaults'
! grep '"backend"|"size"|"agents"' $SAVED
grep '^ "features": \[\]$' $SAVED
! stdout default_agents
! stderr .
! stub_calls
# Unchosen: every feature.
rm $SAVED
exec devvm setup
stdout '^==> base_features features=cli-tools fzf omb$'
! stdout base_will_rebuild
# --features, in the order features run; nothing built yet.
exec devvm setup --features omb,fzf
stdout '^==> base_features features=fzf omb$'
stdout '^==> base_will_rebuild$'
! stdout gc_old_hint
grep '^ "features": \[\n "fzf",\n "omb"\n \]$' $SAVED
exec devvm setup --features fzf,omb
! stdout base_will_rebuild
# Built: a new choice rebuilds base, and gc deletes the old one.
exec devvm build base
exec devvm setup --features none
stdout '^==> base_features_none$'
stdout '^==> base_will_rebuild$'
stdout '^gc_old_hint$'
exec devvm build base
stdout '^==> building_image image=base key='
exec devvm gc --force
stdout '^gc_image image=base key='
# A name that isn't a feature changes nothing: desktop is a layer.
! exec devvm setup --features fzf,nope
stderr '^devvm: no_feature feature=nope features=cli-tools fzf omb$'
! stdout base_features
! exec devvm setup --features desktop
stderr '^devvm: no_feature feature=desktop features=cli-tools fzf omb$'
! stdout base_features
exec devvm setup
stdout '^==> base_features_none$'
# New VMs' size is devvm size -g's, and without a terminal nothing asks
# for it or for new VMs' network policy. Flags for a new VM are devvm's
# alone, so setup doesn't take them, and no command chooses a backend.
! exec devvm setup --backend lima
stderr '^devvm: flag_unknown command=devvm setup flag=--backend$'
! exec devvm setup --cpus 2
stderr '^devvm: flag_unknown command=devvm setup flag=--cpus$'
! exec devvm setup --memory 8
stderr '^devvm: flag_unknown command=devvm setup flag=--memory$'
! grep '"size"|"network"' $SAVED
# --features none chooses none; --features '' is refused, and changes
# nothing.
exec devvm setup --features fzf
! exec devvm setup --features ''
stderr '^devvm: flag_blank flag=features$'
grep '^ "features": \[\n "fzf"\n \]$' $SAVED
exec devvm setup --features none
stdout '^==> base_features_none$'
grep '^ "features": \[\]$' $SAVED
# The network tier saved for new VMs: open makes an open one.
exec devvm network -g open
project off git
exec devvm --no-git-protect
vm_name OFF off
vm_state $OFF_dir/vm.json
stdout '^net.tier=open$'
cd $WORK
# --agents: the coding agents new VMs get, without asking; none for none.
# An agent that isn't one is a usage error, with a did-you-mean.
exec devvm setup --agents claude,codex
stdout '^==> default_agents agents=claude codex$'
grep '^ "agents": \[\n "claude",\n "codex"\n \]$' $SAVED
exec devvm setup --agents none
stdout '^==> default_agents_none$'
grep '^ "agents": \[\]$' $SAVED
! exec devvm setup --agents cladue
stderr '^devvm: unknown_part_like flag=--agents given=cladue like=claude$'
stderr '^usage_help command=devvm setup$'
! exec devvm setup --agents node
stderr '^devvm: part_other_flag flag=--agents given=node other=--tools$'
grep '^ "agents": \[\]$' $SAVED
# A new VM made without a terminal gets setup's agents, and says so.
exec devvm setup --agents codex
project agents git
exec devvm --network open --no-git-protect
stdout '^new_vm_toolchains_none\nnew_vm_agent_from agent=codex from=devvm setup\nnew_vm_layers_none\n'
vm_name AGENTS agents
vm_state $AGENTS_dir/vm.json
stdout '^tools.names=codex$'
cd $WORK
# --layers: the layers new VMs get, bottom first as given, without
# asking; none for none. A name that isn't a layer is a usage error, with
# a did-you-mean, and changes nothing.
exec devvm setup --layers nix,docker
stdout '^==> default_layers layers=nix docker$'
grep '^ "layers": \[\n "nix",\n "docker"\n \]$' $SAVED
! exec devvm setup --layers dokcer
stderr '^devvm: unknown_part_like flag=--layers given=dokcer like=docker$'
stderr '^usage_help command=devvm setup$'
! exec devvm setup --layers node
stderr '^devvm: part_other_flag flag=--layers given=node other=--tools$'
grep '^ "layers": \[\n "nix",\n "docker"\n \]$' $SAVED
exec devvm setup --layers none
stdout '^==> default_layers_none$'
grep '^ "layers": \[\]$' $SAVED
# A new VM made without a terminal gets setup's layers, and says so;
# --layers replaces them, and --layers none gives it none.
exec devvm setup --layers desktop
project layers git
exec devvm --network open --no-git-protect
stdout '^new_vm_agent_from agent=codex from=devvm setup\nnew_vm_layer_from from=devvm setup layer=desktop\n'
vm_name LAYERS layers
vm_state $LAYERS_dir/vm.json
stdout '^image=desktop$'
project layersflag git
exec devvm --network open --no-git-protect --layers docker
stdout '^new_vm_agent_from agent=codex from=devvm setup\nnew_vm_layer_from from=--layers layer=docker\n'
project layersnone git
exec devvm --network open --no-git-protect --layers none
stdout '^new_vm_agent_from agent=codex from=devvm setup\nnew_vm_layers_none\n'
cd $WORK
# A default layer of yours whose script is gone: warned, naming it, and
# the VM is made without it.
mkdir $CFG/layers
cp mailpit.sh $CFG/layers/mailpit.sh
exec devvm setup --layers mailpit
stdout '^==> default_layers layers=mailpit$'
rm $CFG/layers/mailpit.sh
project gone git
exec devvm --network open --no-git-protect
stderr '^devvm: default_layer_gone dir=\S*/config/devvm/layers layer=mailpit vm=devvm-gone-[0-9a-f]{14}$'
stdout '^new_vm_agent_from agent=codex from=devvm setup\nnew_vm_layers_none\n'
cd $WORK
exec devvm setup --layers none
# What config.toml sets wins over settings.json, and devvm setup's flags
# can't change it: refused, naming the file and the key, with nothing
# saved.
cp config.toml $CFG/config.toml
! exec devvm setup --features omb
stderr '^devvm: set_in_config file=\S*/config/devvm/config\.toml key=features$'
! exec devvm setup --agents claude
stderr '^devvm: set_in_config file=\S*/config/devvm/config\.toml key=agents$'
grep '^ "agents": \[\n "codex"\n \],$' $SAVED
! exec devvm setup --layers docker
stderr '^devvm: set_in_config file=\S*/config/devvm/config\.toml key=layers$'
grep '^ "layers": \[\]$' $SAVED
# Without a terminal, setup keeps config.toml's features, saying so.
exec devvm setup
stdout '^==> setup_in_config file=\S*/config/devvm/config\.toml key=features$'
! stdout base_features
# A new VM gets config.toml's layers.
project configlayers git
exec devvm --network open --no-git-protect
stdout '^new_vm_agent_from agent=opencode from=config\.toml\nnew_vm_layer_from from=config\.toml layer=nix\n'
cd $WORK
rm $CFG/config.toml
# config.toml has no backend key: a file that sets one is refused.
cp backend.toml $CFG/config.toml
! exec devvm setup
stderr '^devvm: setup_failed reason=\S*/config/devvm/config\.toml:1: unknown key "backend"$'
rm $CFG/config.toml
# An unreadable choice stays for you to fix.
cp bad.json $SAVED
! exec devvm setup
stderr '^devvm: setup_failed reason=\S*/data/devvm/settings\.json: features: not a feature''s name: "Not_A_Feature"$'
cmp $SAVED bad.json
-- config.toml --
features = ["fzf"]
agents = ["opencode"]
layers = ["nix"]
-- mailpit.sh --
#!/bin/bash
# mailpit: a layer of the user's
-- backend.toml --
backend = "lima"
-- bad.json --
{"features": ["Not_A_Feature"]}