Files
w3cjandClaude Opus 5.5 851e39ef86 build: embed devvm's files in its binary
devvm is one file: assets/ (base.yaml, layers/, features/,
shared-tools/, guest/, oci/, smolvm/) is embedded as assets.FS, which
cli passes to every constructor; backends, the builder, the shared
tools, the proxy and Ubuntu's key check read it as an fs.FS. Scripts
reach VMs on stdin (backend.Script carries their contents). What needs
a path (limactl create's base.yaml, oci/ mounted into the conversion
VM, the proxies' policy files) is written out to
~/.local/share/devvm/assets/<hash>, atomically, files 600 and folders
700; devvm gc deletes older copies no VM's proxy was started with
(gc_assets, deleted_assets). Release archives hold the binary with
README.md, CHANGELOG.md and LICENSE, and the formula installs the
binary alone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 18:12:37 -06:00

46 lines
992 B
Go

package paths
import (
"os"
"path/filepath"
"testing"
)
func TestResolveFollowsLinks(t *testing.T) {
tmp, err := filepath.EvalSymlinks(t.TempDir())
if err != nil {
t.Fatal(err)
}
install := filepath.Join(tmp, "share", "devvm")
bin := filepath.Join(tmp, "bin")
for _, d := range []string{install, bin} {
if err := os.MkdirAll(d, 0o750); err != nil {
t.Fatal(err)
}
}
exe := filepath.Join(install, "devvm")
if err := os.WriteFile(exe, nil, 0o600); err != nil {
t.Fatal(err)
}
link := filepath.Join(bin, "devvm")
if err := os.Symlink(exe, link); err != nil {
t.Fatal(err)
}
for _, path := range []string{exe, link} {
got, err := resolve(path)
if err != nil {
t.Fatalf("resolve(%s): %v", path, err)
}
if got != exe {
t.Errorf("resolve(%s) = %s, want %s", path, got, exe)
}
}
}
func TestResolveMissing(t *testing.T) {
if _, err := resolve(filepath.Join(t.TempDir(), "gone")); err == nil {
t.Error("resolve a missing file: want an error")
}
}