|
|
|
@@ -389,3 +389,46 @@ func TestARuntimeCompiledToABinaryRunsItself(t *testing.T) {
|
|
|
|
|
t.Errorf("the Go runtime is not told what to serve or whose it is: %v %v", env, process["user"])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// novox/hq ADR 0193: a Go tools bundle is served — its binary is what the runtime starts, delivered
|
|
|
|
|
// like any tools bundle, named to the runtime where a TypeScript bundle names its launcher.
|
|
|
|
|
func TestAGoToolsBundleIsServedByItsBinary(t *testing.T) {
|
|
|
|
|
with := Rendering{ArtifactStore: "anchor.internal:5101",
|
|
|
|
|
Needed: map[string]map[string]string{RuntimeModule: {"broker": "sealed-credential"}}}
|
|
|
|
|
lamp := Manifest{Module: "lamp", Version: "1", Tools: []string{"on"},
|
|
|
|
|
Build: &Build{Artifacts: []Artifact{{Name: "tools", Kind: ArtifactBundle, Language: "go",
|
|
|
|
|
System: "arch", From: "cmd/lamp-tools"}}}}
|
|
|
|
|
if p := lamp.Build.problems("lamp"); len(p) != 0 {
|
|
|
|
|
t.Fatalf("a Go tools bundle was refused: %v", p)
|
|
|
|
|
}
|
|
|
|
|
lamp, err := lamp.Resolve([]Built{{Name: "tools", Kind: ArtifactBundle,
|
|
|
|
|
Reference: ArtifactStoreScheme + "lamp/tools/blobs/" + bundleDigest, Digest: bundleDigest}})
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
if fmt.Sprint(lamp.Bundles[0].Loads) != "[lamp-tools]" {
|
|
|
|
|
t.Fatalf("the runtime loads %v from a Go bundle, want its binary", lamp.Bundles[0].Loads)
|
|
|
|
|
}
|
|
|
|
|
out, err := Resolution{Node: "anchor", Account: "ops", Modules: []Manifest{lamp, theRuntime(t)}}.Declaration(with)
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
if fileNamed(out, "lamp."+BundleID("tools")) == nil {
|
|
|
|
|
t.Errorf("the Go bundle is not delivered: %v", ids(out))
|
|
|
|
|
}
|
|
|
|
|
env := fileNamed(out, RuntimeModule+"."+RuntimeProcessID())["env"].(map[string]string)
|
|
|
|
|
if env[RuntimeToolModules] != "lamp="+BundlePath("lamp", "tools")+"/lamp-tools" {
|
|
|
|
|
t.Errorf("the runtime is told %q, want the binary", env[RuntimeToolModules])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// An artifact may say it explicitly; naming anything but the binary is refused.
|
|
|
|
|
said := Manifest{Module: "lamp", Version: "1", Build: &Build{Artifacts: []Artifact{{Name: "tools",
|
|
|
|
|
Kind: ArtifactBundle, Language: "go", System: "arch", Binary: "lamp", Loads: []string{"lamp"}}}}}
|
|
|
|
|
if p := said.Build.problems("lamp"); len(p) != 0 {
|
|
|
|
|
t.Errorf("loads naming the binary was refused: %v", p)
|
|
|
|
|
}
|
|
|
|
|
said.Build.Artifacts[0].Loads = []string{"tools/index.js"}
|
|
|
|
|
if p := said.Build.problems("lamp"); len(p) == 0 {
|
|
|
|
|
t.Error("a Go bundle loading a file it does not contain was admitted")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|