deps skips a forge requirement the go.mod already replaces to a directory (a package of the module's own repository), which it used to look for in a clone beside the check and fail. The new check removedpackages refuses an import of a package mesh-sdk gave up and a use of the build runner through mesh-sdk's buildstep; it is red on mesh-provisioner until the provisioner stops composing (the release's provisioner subtask). controllerdeps also refuses a go.mod requiring the controller's repository. Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
58 lines
2.7 KiB
Go
58 lines
2.7 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// ADR 0593 §1: a source that imports a package mesh-sdk gave up, or names the build runner through mesh-sdk's buildstep, is
|
|
// refused naming where it went; the contract that stays, the runner's own package and a testdata copy are not.
|
|
func TestFindingsRefuseWhatMeshSDKGaveUp(t *testing.T) {
|
|
const head = "package x\n\nimport (\n"
|
|
for _, row := range []struct {
|
|
name, file, src string
|
|
want string // empty: clean
|
|
}{
|
|
{"clean", "modules/a/x.go", head + "\t\"git.novox.be/novox/mesh-sdk/go/delivery\"\n)\n\nvar _ = delivery.StepsState\n", ""},
|
|
{"a removed package", "modules/a/x.go", head + "\t\"git.novox.be/novox/mesh-sdk/go/compose\"\n)\n\nvar _ = compose.Resolve\n", "imports git.novox.be/novox/mesh-sdk/go/compose, which left mesh-sdk; it is the node-engine"},
|
|
{"under a removed package", "modules/a/x_test.go", head + "\t\"git.novox.be/novox/mesh-sdk/go/compose/frombus\"\n)\n", "the node-engine"},
|
|
{"buildcpu", "checks/c/x.go", head + "\t\"git.novox.be/novox/mesh-sdk/go/buildcpu\"\n)\n", "buildstep/buildcpu"},
|
|
{"the runner through mesh-sdk's buildstep", "modules/a/x.go", head + "\t\"git.novox.be/novox/mesh-sdk/go/buildstep\"\n)\n\nvar _ = buildstep.RunAsk\n", "uses buildstep.RunAsk, which is the build runner's"},
|
|
{"the runner through an alias", "modules/a/x.go", head + "\tsdkstep \"git.novox.be/novox/mesh-sdk/go/buildstep\"\n)\n\nvar _ = sdkstep.Puller{}\n", "uses sdkstep.Puller"},
|
|
{"the contract of buildstep", "modules/a/x.go", head + "\t\"git.novox.be/novox/mesh-sdk/go/buildstep\"\n)\n\nvar _ = buildstep.NewID\nvar _ buildstep.Failure\n", ""},
|
|
{"the runner's own package", "modules/a/x.go", head + "\t\"git.novox.be/novox/mesh-catalog/modules/mesh-build-go/buildstep\"\n)\n\nvar _ = buildstep.RunAsk\n", ""},
|
|
{"a copy in testdata", "modules/a/testdata/x.go", head + "\t\"git.novox.be/novox/mesh-sdk/go/compose\"\n)\n", ""},
|
|
} {
|
|
t.Run(row.name, func(t *testing.T) {
|
|
root := t.TempDir()
|
|
p := filepath.Join(root, row.file)
|
|
if err := os.MkdirAll(filepath.Dir(p), 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(p, []byte(row.src), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
got, err := Findings(root)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if all := strings.Join(got, "\n"); (row.want == "") != (all == "") || !strings.Contains(all, row.want) {
|
|
t.Fatalf("findings = %q, want one containing %q", all, row.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
// The script's run of this check over the real tree (novox/hq ADR 0529 clause 2).
|
|
func TestTheCatalogueImportsNothingMeshSDKGaveUp(t *testing.T) {
|
|
got, err := Findings(filepath.Join("..", ".."))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, f := range got {
|
|
t.Error(f)
|
|
}
|
|
}
|