Files
devvm/testdata/script/subfolder.txtar
T
w3cjandClaude Opus 5.5 16b4ad8771 feat(cli): --no-input, a flag or command for every question, and --force only skips a confirmation
A global --no-input (persistent on the root, with --help and -v): no
question is asked or read. The ui's prompts (Ask, Confirm, Answer,
Secret, Pick/PickOne in a terminal) show the question, then fail with
no_input naming what answers it (msg.AnswerFor, by the question's ID),
or no_input_terminal for a question only a terminal answers. ui.Flags
and SetFlags carry -v and --no-input.

Answers: --network-policy/--no-network-policy, --here, devvm size -g,
devvm setup --features/--backend, devvm network -g, devvm ssh-agent add,
devvm restart, --ssh-config (new, on devvm, host and code: the Include
line without asking; sshconfig.Config.AddInclude, vm.Env.AddInclude),
--stdin, and --force.

--force (-f) only skips a confirmation, and destructive commands need it
without a terminal (force_needed, a failure, not a usage error): rm (new
rm_confirm), gc (it went ahead without a terminal), gc --caches (now
allowed without a terminal with --force), images rm (images_rm_confirm),
secret rm (secret_rm_confirm), adopt (adopt_vm), rebuild when images
are built on the one rebuilt (build.Env.Force). rm --no-export skips the
export; rm's parent-folder, earlier-folder and --clone confirmations are
terminal-only and --force never answers them (vm.RmOptions). gc --tools
--force splits: --recent (only with --tools, gc_recent_needs_tools)
drops the hour's hold and keeps the refusal while a VM is being made
(gc_recent_making); gc_tools_recent names devvm gc --tools --recent.
gc_caches_need_terminal goes.

Tests: TestNoInput, TestAnswers, TestConfirmed, TestRmConfirms, TestAdopt
(--force), TestRebuild (force_needed, then Force); secret, rebuild,
images, gc*, clone, subfolder, existing scripts. e2e: rm/gc/images
rm/secret rm/rebuild with --force (and --no-export where rm -f skipped
the export), and the clone section's rm with its checks. Docs:
commands.md (Questions devvm asks, rm, flags), first-vm, clone, images
(cleaning up, --recent), space, coding-agents, internals overview and
images; CLI reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 03:51:27 -08:00

120 lines
4.2 KiB
Plaintext

# devvm in a subfolder of a folder with a VM: without a terminal it opens
# that VM in the subfolder, saying so; --here and --clone make the
# subfolder its own; stop acts on the parent's VM, naming it first; rm
# refuses it without a terminal. adopt doesn't look upward, and nothing
# does from a repo of its own below the parent's folder. Commands that
# give the parent's VM more access are refused without a terminal.
env DEVVM_MESSAGES=names
env VMS=$XDG_DATA_HOME/devvm/vms
mkdir $WORK/app/src/lib
cd $WORK/app
exec git init -q
exec devvm --no-network-policy base
# The parent's VM, its shell in the subfolder.
cd $WORK/app/src/lib
exec sh -c ': > "$STUB_LOG"'
exec devvm
stdout '^==> using_parent_vm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
! stdout creating
stub_calls
! stdout 'limactl (clone|create)'
stdout '^limactl shell --workdir /\S*/app/src/lib devvm-app-[0-9a-f]{14}\n\z'
exec sh -c 'ls "$VMS" | wc -l'
stdout '^ *1$'
# adopt is for this path's VM only.
! exec devvm adopt
stderr '^devvm: no_vm dir=/\S*/app/src/lib$'
# stop: the parent's, named first.
exec sh -c ': > "$STUB_LOG"'
exec devvm stop
stdout '^==> using_parent_vm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}\n==> stopped vm=devvm-app-[0-9a-f]{14}$'
stub_calls
stdout '^limactl stop devvm-app-[0-9a-f]{14}$'
# --here: a new VM for the subfolder, nothing asked; then it's the
# subfolder's own.
cd $WORK/app/src
exec devvm --here --no-network-policy base
stdout '^==> creating_from image=base vm=devvm-src-[0-9a-f]{14}$'
! stdout using_parent_vm
exec sh -c ': > "$STUB_LOG"'
exec devvm
! stdout using_parent_vm
stub_calls
stdout '^limactl shell --workdir /\S*/app/src devvm-src-[0-9a-f]{14}\n\z'
# The nearest folder with a VM wins.
cd $WORK/app/src/lib
exec devvm stop
stdout '^==> using_parent_vm dir=/\S*/app/src vm=devvm-src-[0-9a-f]{14}$'
# A repo of its own below the parent's folder: other commands find no VM,
# and without a terminal devvm makes the subfolder's own.
mkdir $WORK/app/tool/bin
cd $WORK/app/tool
exec git init -q
cd $WORK/app/tool/bin
! exec devvm stop
stderr '^devvm: no_vm dir=/\S*/app/tool/bin$'
! stdout using_parent_vm
exec devvm --no-network-policy base
stdout '^==> creating_from image=base vm=devvm-bin-[0-9a-f]{14}$'
! stdout using_parent_vm
exec devvm rm --force --no-export
# --clone: a new VM for the subfolder's own repo, as --here, nothing
# asked.
mkdir $WORK/app/repo
cd $WORK/app/repo
env GIT_AUTHOR_NAME=t GIT_AUTHOR_EMAIL=t@t GIT_COMMITTER_NAME=t GIT_COMMITTER_EMAIL=t@t
exec git init -q -b main
exec git commit -q --allow-empty -m one
exec devvm --clone --no-network-policy base
stdout '^==> creating_from image=base vm=devvm-repo-[0-9a-f]{14}$'
! stdout using_parent_vm
exec devvm rm --force --no-export
# rm: never a parent's without asking. Without a terminal it's refused,
# --force or not, and nothing is deleted; in the parent's folder it goes.
cd $WORK/app/src
exec devvm rm --force
cd $WORK/app/src/lib
# Commands that give a parent's VM more access are refused without a
# terminal, naming the VM and its folder, and change nothing.
! exec devvm secret use github
stderr '^devvm: widen_parent_vm_refused cmd=devvm secret use dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
! exec devvm ssh-agent on
stderr '^devvm: widen_parent_vm_refused cmd=devvm ssh-agent on dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
exec devvm ssh-agent
stdout '^off$'
! exec devvm network allow example.com
stderr '^devvm: widen_parent_vm_refused cmd=devvm network allow dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
exec devvm network deny bad.example.com
stdout 'rule_added'
! exec devvm network rm '!bad.example.com'
stderr '^devvm: widen_parent_vm_refused cmd=devvm network rm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
exec devvm network
stdout '!bad.example.com'
! stdout '^example.com'
exec sh -c ': > "$STUB_LOG"'
! exec devvm rm --force --no-export
stdout '^==> using_parent_vm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
stderr '^devvm: rm_parent_vm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
stub_calls
! stdout 'limactl delete'
exec sh -c 'ls "$VMS" | grep -v "\.policy$" | wc -l'
stdout '^ *1$'
cd $WORK/app
exec devvm rm --force
stdout '^==> deleted vm=devvm-app-[0-9a-f]{14}$'
exec ls $VMS
! stdout .
cd $WORK/app/src/lib
! exec devvm rm --force
stderr '^devvm: no_vm dir=/\S*/app/src/lib$'