The builder finds a build module as the indexer's seed does: the build seat whose acting rule `build` has an `on` matching the artifact's language or kind:image, and that seat's holder, read from the seat list's definitions and the claims of the catalog half's manifests. Task.Module, every lane key, the unpublished modules, the toolchain sources, the ends watched, the sayer and builder_stuck (through `<seat>.steps`) derive from it; the floor's sources are the holders of the seats git and mesh-catalog. buildrun.GoBuildModule, NodeBuildModule, LanguageOf, buildstep.BuildModuleOf use, build.ImageBuildModule and StuckBuildModules are gone from the builder (the checker keeps its own names in two small files until its part reads them from the list). Builds: design 47 G §7, §428, §704, §204, A-82 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
61 lines
2.9 KiB
Go
61 lines
2.9 KiB
Go
package buildrun
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/seatdef"
|
|
)
|
|
|
|
// The build module of an artifact is the holder of the build seat whose rule `on` names its language, or kind:image, as the seat
|
|
// list and the catalog half name it (design 47 G A-82): no module name is in the code.
|
|
func TestTheBuildModuleIsTheHolderOfTheBuildSeat(t *testing.T) {
|
|
rule := func(step, on string) seatdef.Definition {
|
|
return seatdef.Definition{Acts: []seatdef.ActingRule{{Step: step, On: on}}}
|
|
}
|
|
defs := map[string]seatdef.Definition{
|
|
"node-build-go": rule(seatdef.StepBuild, "go"), "node-build-node": rule(seatdef.StepBuild, "typescript"),
|
|
"node-build-image": rule(seatdef.StepBuild, seatdef.OnKindImage), "node-build-rust": rule(seatdef.StepBuild, "go"),
|
|
"mesh-checks": rule(seatdef.StepCheck, "go"), "node-builder-every": rule(seatdef.StepBuild, "every"),
|
|
}
|
|
holders := map[string]string{"node-build-go": "acme-go", "node-build-node": "acme-ts", "node-build-image": "acme-img"}
|
|
seats := NewBuildSeats(func() map[string]seatdef.Definition { return defs }, func(s string) (string, bool) { h, ok := holders[s]; return h, ok })
|
|
for _, c := range []struct{ language, kind, module, fail string }{
|
|
{"typescript", "bundle", "acme-ts", ""},
|
|
{"", "image", "acme-img", ""},
|
|
{"python", "bundle", "", "no seat builds"},
|
|
{"go", "bundle", "", "each build"}, // node-build-go and node-build-rust both build go
|
|
} {
|
|
got, err := seats.For(c.language, c.kind)
|
|
switch {
|
|
case c.fail != "" && (err == nil || !strings.Contains(err.Error(), c.fail)):
|
|
t.Errorf("For(%q, %q) = %+v, %v; want the error %q", c.language, c.kind, got, err, c.fail)
|
|
case c.fail == "" && (err != nil || got.Module != c.module):
|
|
t.Errorf("For(%q, %q) = %+v, %v; want %s", c.language, c.kind, got, err, c.module)
|
|
}
|
|
}
|
|
delete(defs, "node-build-rust")
|
|
if m, err := seats.For("go", "bundle"); err != nil || m.Module != "acme-go" || m.Toolchain != "go" || m.AskLanguage() != "go" {
|
|
t.Errorf("For(go) = %+v, %v", m, err)
|
|
}
|
|
if l, ok := seats.LanguageOf("acme-ts"); !ok || l != "typescript" {
|
|
t.Errorf("LanguageOf(acme-ts) = %q, %v", l, ok)
|
|
}
|
|
if _, ok := seats.LanguageOf("acme-img"); ok {
|
|
t.Error("an image build module has a toolchain language")
|
|
}
|
|
if got := strings.Join(seats.Modules(), ","); got != "acme-go,acme-img,acme-ts" {
|
|
t.Errorf("Modules = %s", got)
|
|
}
|
|
delete(holders, "node-build-go") // no catalog entry claims the seat: no build module, said by name
|
|
if _, err := seats.For("go", "bundle"); err == nil || !strings.Contains(err.Error(), "no module claims node-build-go") {
|
|
t.Errorf("a seat with no holder: %v", err)
|
|
}
|
|
if m, err := seats.OfAskLanguage("image"); err != nil || m.Module != "acme-img" {
|
|
t.Errorf("OfAskLanguage(image) = %+v, %v", m, err)
|
|
}
|
|
if got := NewBuildSeats(func() map[string]seatdef.Definition { return nil }, nil).Modules(); len(got) != 0 {
|
|
t.Errorf("before the seat list is read: %v", got)
|
|
}
|
|
}
|