All of mesh-build-go's buildstep Go module leaves mesh-catalog for modules/mesh-delivery-sdk: the step run, fetch and release and the regenerate-and-compare step as the package steprun, the CPU share as steprun/buildcpu, the conformance kit as steprun/conformance, the seat generator as seatgen with cmd/seatgen, and cmd/mesh-pack. The three build modules and the builder's and checker's tests import the SDK and keep no copy; the SDK requires nothing of mesh-catalog. Code the build modules share is the delivery domain's SDK, not one module's package. It carries the build-module round's two new files of that package (dropdetected.go 247c422f, storedbuilds.go 904b8aed). Builds: design 47 G §464, §680, §327, §420, §495 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
53 lines
1.5 KiB
Go
53 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun"
|
|
)
|
|
|
|
func fixture(t *testing.T) string {
|
|
t.Helper()
|
|
d := t.TempDir()
|
|
os.MkdirAll(filepath.Join(d, "sub"), 0o755)
|
|
os.WriteFile(filepath.Join(d, "a.txt"), []byte("alpha"), 0o644)
|
|
os.WriteFile(filepath.Join(d, "sub", "run"), []byte("#!/bin/sh\n"), 0o755)
|
|
return d
|
|
}
|
|
|
|
func TestPackFixtureTwiceGivesBuildstepsDigest(t *testing.T) {
|
|
d := fixture(t)
|
|
_, want, err := steprun.Pack(d)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for i := 0; i < 2; i++ {
|
|
got, err := run([]string{"-pack", d, "-out", filepath.Join(t.TempDir(), "x.tgz")})
|
|
if err != nil || got != want {
|
|
t.Fatalf("run %d: %q, %v; want %q", i, got, err, want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestBuildTwiceGivesOneDigestAndRecipeArgs(t *testing.T) {
|
|
m := t.TempDir()
|
|
os.WriteFile(filepath.Join(m, "go.mod"), []byte("module x\n\ngo 1.21\n"), 0o644)
|
|
os.MkdirAll(filepath.Join(m, "cmd", "p"), 0o755)
|
|
os.WriteFile(filepath.Join(m, "cmd", "p", "main.go"), []byte("package main\n\nvar builtFor string\n\nfunc main() { println(builtFor) }\n"), 0o644)
|
|
args := []string{"-dir", m, "-from", "cmd/p", "-binary", "p", "-system", "arch"}
|
|
a, err := run(args)
|
|
if err != nil {
|
|
t.Skipf("no go toolchain that builds offline: %v", err)
|
|
}
|
|
b, err := run(args)
|
|
if err != nil || a != b {
|
|
t.Fatalf("two builds: %q, %q, %v", a, b, err)
|
|
}
|
|
got := Args("/d", "./cmd/p/", "/o", "p", "arch")
|
|
if got[len(got)-1] != "./cmd/p" || got[4] != "-s -w -X main.builtFor=arch" {
|
|
t.Fatalf("args %v", got)
|
|
}
|
|
}
|