Why: The sandbox hides the host home directory and has no network, so pip install --user cannot supply python-docx, and the service PATH resolved python3 to a linuxbrew path that does not exist inside the sandbox. Evidence: SELF go test of execenv, tools, store, app, server, runmgr, config, and cmd/agent-system on this worktree. CI has not run. Impact: Sessions inherit a read-only base layer. Extra packages are requested through python_env, auto-approved only from the allowlist, and mounted per conversation. Schema 35 adds the request and binding tables. Refs: .task/feature-layered-python-env.md Co-authored-by: Cursor <cursoragent@cursor.com>
49 lines
1.6 KiB
Go
49 lines
1.6 KiB
Go
package execenv
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestResolveMemConflictAllowlistAndSDist(t *testing.T) {
|
|
index := []Wheel{
|
|
{Name: "Foo", Version: "1.0.0", Filename: "foo-1.whl", SHA256: "aaa", Kind: "wheel"},
|
|
{Name: "Foo", Version: "2.0.0", Filename: "foo-2.whl", SHA256: "bbb", Kind: "wheel"},
|
|
{Name: "OnlySrc", Version: "1", Filename: "onlysrc-1.tar.gz", Kind: "sdist"},
|
|
}
|
|
got := ResolveMem(index, []string{"foo==1.0.0"}, []LockedPkg{{Name: "foo", Version: "2.0.0"}})
|
|
if len(got.Override) != 1 || len(got.Packages) != 0 {
|
|
t.Fatalf("conflict should keep the pin and record an override: %+v", got)
|
|
}
|
|
fresh := ResolveMem(index, []string{"foo"}, nil)
|
|
if len(fresh.Packages) != 1 || fresh.Packages[0].Version != "2.0.0" {
|
|
t.Fatalf("unpinned foo should pick the newest wheel: %+v", fresh.Packages)
|
|
}
|
|
sdist := ResolveMem(index, []string{"onlysrc"}, nil)
|
|
if len(sdist.SDist) != 1 || len(sdist.Packages) != 0 {
|
|
t.Fatalf("sdist-only must be refused: %+v", sdist)
|
|
}
|
|
missing := ResolveMem(index, []string{"nope"}, nil)
|
|
if len(missing.Missing) != 1 {
|
|
t.Fatalf("missing: %+v", missing)
|
|
}
|
|
}
|
|
|
|
func TestBuildLayerRejectsHashMismatch(t *testing.T) {
|
|
root, err := Open(t.TempDir())
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
wheel := root.Wheelhouse() + "/foo.whl"
|
|
if err := osWriteWheel(wheel, "foo.py"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
_, err = root.BuildLayer(Lock{
|
|
Schema: 1, Kind: "base", PythonTag: "cp314", Platform: "any",
|
|
Packages: []LockedPkg{{Name: "foo", Version: "1", Filename: "foo.whl", SHA256: "deadbeef"}},
|
|
})
|
|
if err == nil || !strings.Contains(err.Error(), "hash mismatch") {
|
|
t.Fatalf("err = %v", err)
|
|
}
|
|
}
|