Files
devvm/testdata/script/features.txtar
T
w3cjandClaude Opus 5.5 ffbc139969 test(lima): a contract test of the limactl stub against real Lima
TestLimactlStubContract runs scenario on dummy instances twice, through
the real limactl and through testdata/stubs/limactl, and after each step
compares every instance as devvm reads it from limactl list --json: their
order, status, size, mounts, agent forwarding, ssh port and networks, and
the edits each kind of start would make (startSets).

The stub had drifted from Lima, and now matches it:
- create ignored --cpus= and --memory=: every image was 4 CPUs and 8 GiB.
- clone started from an empty config: Lima's keeps its source's config,
  size and lima.yaml (env), then --mount-none, then each --set.
- Only --set .portForwards, .ssh.localPort and .env were kept: the
  mounts, .ssh.forwardAgent, .propagateProxyEnv, .hostResolver and .dns
  were dropped, so each start edited them again. The stub keeps any
  --set (and del()) in $STUB_DIR/config-<name>/, on create too.
- delete left the VM's size and $LIMA_HOME/<name> (its lima.yaml).
- list gave instances in the order they were made: Lima sorts them.

devvm relied on the clone drift: a project VM keeps its image's
propagateProxyEnv: false (from the build's start), so its first start
without network policy edited it, where the CLI tests said it edits
nothing. CreateVM now sets .propagateProxyEnv=true at the clone. And
rebuild.txtar relied on the list order: it compares the deletes sorted,
as Lima lists images by name. On Linux a layer's or the tools build's
VM, cloned from a built image, keeps the config its image's build made,
so Start edits nothing (no ssh port there) and the build's step count
was one too many: cloneEdits counts the configure step only when Start
edits (TestCloneEdits).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 14:11:57 -07:00

89 lines
3.2 KiB
Plaintext

# Base image features: chosen the first time anything is built (without a
# terminal, every one: devvm's own, then the user's), saved in
# settings.json unless config.toml chooses them, and run in base after
# base.sh, in the order chosen.
env CHOSEN=$DATA/settings.json
rm $CHOSEN
mkdir $XDG_CONFIG_HOME/devvm/features
cp mine.sh $XDG_CONFIG_HOME/devvm/features/mine.sh
cp fzf.sh $XDG_CONFIG_HOME/devvm/features/fzf.sh
mkdir $XDG_CONFIG_HOME/devvm/layers
cp foo.sh $XDG_CONFIG_HOME/devvm/layers/foo.sh
# A user feature named like a built-in one is ignored, with a warning.
exec devvm build base
stderr '^devvm: feature_shadowed feature=fzf file=.*/config/devvm/features/fzf\.sh$'
! stdout features_help
stdout '^==> base_features features=cli-tools fzf omb mine$'
grep '^ "features": \[\n "cli-tools",\n "fzf",\n "omb",\n "mine"\n \]$' $CHOSEN
cmp $STUB_DIR/scripts ran-all
catg $DATA/logs/runs/*.log
stdout '^# \[4/9\] running_script script=base\.sh vm=devvm-img-'
stdout '^# \[5/9\] running_script script=cli-tools\.sh vm=devvm-img-'
stdout '^# \[8/9\] running_script script=mine\.sh vm=devvm-img-'
stdout '^# \[9/9\] stopping vm=devvm-img-'
# Chosen once: the next build keeps the choice, and base.
exec devvm build base
! stderr feature_shadowed
! stdout 'base_features|building_image'
# Editing a chosen feature's script rebuilds base on next use.
exec sh -c 'echo "# edited" >> "$XDG_CONFIG_HOME/devvm/features/mine.sh"'
exec devvm build base
stdout '^==> building_image image=base key='
# A chosen feature without a script is skipped, with a warning; the steps
# count only what runs. A layer runs only its own script. config.toml's
# features win over settings.json's.
cp some.toml $CFG/config.toml
exec sh -c ': > "$STUB_DIR/scripts"'
exec devvm build foo
stderr '^devvm: unknown_feature feature=nope$'
! stdout base_features
cmp $STUB_DIR/scripts ran-some
exec sh -c 'cat "$XDG_DATA_HOME"/devvm/logs/runs/*.log'
stdout '^# \[4/7\] running_script script=base\.sh vm=devvm-img-'
stdout '^# \[5/7\] running_script script=fzf\.sh vm=devvm-img-'
stdout '^# \[6/7\] running_script script=omb\.sh vm=devvm-img-'
stdout '^# \[7/7\] stopping vm=devvm-img-'
[darwin] stdout '^# \[4/5\] running_script script=foo\.sh vm=devvm-img-'
[linux] stdout '^# \[3/4\] running_script script=foo\.sh vm=devvm-img-'
! stdout '\[8/7\]|\[6/5\]|\[5/4\]'
# None chosen: base runs only base.sh.
cp none.toml $CFG/config.toml
exec sh -c ': > "$STUB_DIR/scripts"'
exec devvm build base
! stderr .
cmp $STUB_DIR/scripts ran-none
grep '"mine"' $CHOSEN
-- some.toml --
features = ["fzf", "omb", "nope"]
-- none.toml --
features = []
-- mine.sh --
#!/bin/bash
# my tools
-- fzf.sh --
#!/bin/bash
# my fzf
-- foo.sh --
#!/bin/bash
echo foo
-- ran-all --
# Essentials, and mise for the shared tools (shared-tools/).
# CLI tools: bat, fd, eza, zoxide (z), btop, tree, tldr
# fzf: fuzzy Ctrl-R history and Ctrl-T file search
# oh-my-bash: themed prompt, completions, aliases
# my tools
-- ran-some --
# Essentials, and mise for the shared tools (shared-tools/).
# fzf: fuzzy Ctrl-R history and Ctrl-T file search
# oh-my-bash: themed prompt, completions, aliases
echo foo
-- ran-none --
# Essentials, and mise for the shared tools (shared-tools/).