package sdk import ( "encoding/json" "os" "strings" "testing" ) // The module's one package artifact is the module's whole directory, which it says by leaving `paths` out: the manifest // validator refuses the word "." as a path (a package artifact naming one directory). func TestThePackageArtifactNamesNoPathForTheWholeDirectory(t *testing.T) { raw, err := os.ReadFile("module.json") if err != nil { t.Fatal(err) } var m struct { Build struct { Artifacts []struct { Name string `json:"name"` Paths []string `json:"paths"` } `json:"artifacts"` } `json:"build"` } if err := json.Unmarshal(raw, &m); err != nil { t.Fatal(err) } if len(m.Build.Artifacts) != 1 { t.Fatalf("artifacts are %+v: one", m.Build.Artifacts) } for _, a := range m.Build.Artifacts { for _, p := range a.Paths { if p == "." || p == "" { t.Errorf("artifact %s names %q as a path: leave `paths` out for the module's whole directory", a.Name, p) } } } } // The build modules' shared code is this SDK's (design 47 G §464, §680): the step runner `steprun` with its per-node CPU // share and its conformance kit, the seat generator `seatgen` and the commands `seatgen` and `mesh-pack`; and the SDK // requires nothing of mesh-catalog, whose build modules import it. func TestTheSDKHoldsTheBuildModulesSharedCodeAndRequiresNoCatalogModule(t *testing.T) { for _, dir := range []string{"steprun", "steprun/buildcpu", "steprun/conformance", "seatgen", "cmd/seatgen", "cmd/mesh-pack"} { if fi, err := os.Stat(dir); err != nil || !fi.IsDir() { t.Errorf("%s is not a package of the delivery SDK: %v", dir, err) } } raw, err := os.ReadFile("go.mod") if err != nil { t.Fatal(err) } for _, line := range strings.Split(string(raw), "\n") { if strings.Contains(line, "git.novox.be/novox/mesh-catalog/") { t.Errorf("go.mod names a mesh-catalog module: %s", strings.TrimSpace(line)) } } }