The builder's published package reached the bus library through buildstep, whose KeptBuildsOf took mesh-sdk's buscalls.ObjectInfo, and buscalls now imports nats.go for its seat chunks. buildstep's layouts, keys and codecs are read by modules that never touch the bus (its own guard), so the kept build of one object is judged from the object's own fields (KeptBuildOf, SortKept) and the build module lists its store itself. The guard now also refuses a bus library reached through an import, the kind that let this in. Builds: design 47 G (join 11 area 4: builds TestThePackageReachesNoBus, buildstep's bus-free guard) Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
46 lines
1.4 KiB
Go
46 lines
1.4 KiB
Go
package buildstep
|
|
|
|
import (
|
|
"go/parser"
|
|
"go/token"
|
|
"os/exec"
|
|
"path/filepath"
|
|
"strconv"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// The layouts, keys and codecs of this package are read by modules that never touch the bus (a composer's tool, the
|
|
// builder's published package): it imports neither the bus library nor mesh-sdk's runtime (the root package), whose
|
|
// part that runs is package buildrun's.
|
|
func TestThePackageIsFreeOfTheBus(t *testing.T) {
|
|
files, _ := filepath.Glob("*.go")
|
|
fset := token.NewFileSet()
|
|
for _, f := range files {
|
|
if strings.HasSuffix(f, "_test.go") {
|
|
continue
|
|
}
|
|
parsed, err := parser.ParseFile(fset, f, nil, parser.ImportsOnly)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, imp := range parsed.Imports {
|
|
path, _ := strconv.Unquote(imp.Path.Value)
|
|
if strings.HasPrefix(path, "github.com/nats-io/") || path == "git.novox.be/novox/mesh-sdk/go" {
|
|
t.Errorf("%s imports %s, which reaches the bus", f, path)
|
|
}
|
|
}
|
|
}
|
|
// Nor through a package it imports: a mesh-sdk package that came to import the bus library (buscalls' seat chunks) took
|
|
// the builder's published package onto the bus through this one (join 11).
|
|
out, err := exec.Command("go", "list", "-deps", ".").Output()
|
|
if err != nil {
|
|
t.Fatalf("go list: %v", err)
|
|
}
|
|
for _, p := range strings.Fields(string(out)) {
|
|
if strings.HasPrefix(p, "github.com/nats-io/") {
|
|
t.Errorf("buildstep depends on %s", p)
|
|
}
|
|
}
|
|
}
|