Judge the SDK conformance fixtures against the SDK the controller pins, never a desktop's checkout (issue 449)

A check clones mesh-sdk beside the controller at the commit go.mod pins; elsewhere
the test reads a copy captured at that commit, held to go.mod. A missing clone fails
instead of skipping.
This commit is contained in:
2026-10-11 04:19:01 +02:00
parent 9d6a12eb53
commit 4632b6a508
6 changed files with 161 additions and 16 deletions
+39 -5
View File
@@ -5,15 +5,21 @@ import (
"os"
"path/filepath"
"regexp"
"strings"
"testing"
"time"
"github.com/novox/mesh-controller/internal/beside"
)
// The Go implementation, held to the shared fixtures (novox/hq ADR 0074, design 19).
//
// **Read from the sdk's conformance directory by sibling path**, the way the lab finds its
// siblings — deliberately not copied here. A fixture copied into each implementation is two
// fixtures, and two fixtures drift, which is the exact failure the suite exists to prevent.
// **Read from the SDK's own conformance directory, never copied by hand**: a fixture written into each
// implementation is two fixtures, and two fixtures drift, which is the failure the suite exists to prevent.
// Which SDK is read is named, never the one a desktop happens to hold beside this checkout (novox/hq issue
// 449): in a merge check the SDK the build seat clones beside it, at the commit this controller's go.mod
// pins, and a missing clone fails the test; elsewhere the copy captured in testdata/beside at that same
// commit (internal/beside, testdata/beside/CAPTURED), held to go.mod by TestTheCapturedSDKIsTheOneGoModPins.
type fixture struct {
Name string `json:"name"`
Given struct {
@@ -32,10 +38,11 @@ type fixture struct {
func loadFixture(t *testing.T, name string) fixture {
t.Helper()
path := filepath.Join("..", "..", "..", "mesh-sdk", "conformance", name)
path := filepath.Join(beside.Dir(t, "mesh-sdk"), "conformance", name)
raw, err := os.ReadFile(path)
if err != nil {
t.Skipf("the sdk's conformance fixtures are not beside this checkout: %v", err)
// Failed, never skipped: a skip here passed the suite with nothing judged.
t.Fatalf("the SDK's conformance fixture %s: %v", name, err)
}
var f fixture
if err := json.Unmarshal(raw, &f); err != nil {
@@ -44,6 +51,33 @@ func loadFixture(t *testing.T, name string) fixture {
return f
}
// The captured SDK is the one this controller is built against: when go.mod moves the SDK, the copy moves
// with it, or the tests away from a merge check judge an SDK the controller no longer uses (novox/hq issue
// 449).
func TestTheCapturedSDKIsTheOneGoModPins(t *testing.T) {
mod, err := os.ReadFile(filepath.Join("..", "..", "go.mod"))
if err != nil {
t.Fatal(err)
}
pinned := regexp.MustCompile(`(?m)^\s*git\.novox\.be/novox/mesh-sdk/go v\S+-([0-9a-f]{12})$`).FindSubmatch(mod)
if pinned == nil {
t.Fatal("go.mod pins no commit of git.novox.be/novox/mesh-sdk/go as a pseudo-version; say here how a " +
"release's tag is matched against testdata/beside/CAPTURED")
}
captured, err := os.ReadFile(filepath.Join(beside.Captured(), "CAPTURED"))
if err != nil {
t.Fatal(err)
}
at := regexp.MustCompile(`(?m)^mesh-sdk\s+([0-9a-f]{40})\s`).FindSubmatch(captured)
if at == nil {
t.Fatal("testdata/beside/CAPTURED names no commit for mesh-sdk")
}
if !strings.HasPrefix(string(at[1]), string(pinned[1])) {
t.Errorf("the SDK is captured at %s but go.mod pins %s: capture it again at the pinned commit, as "+
"testdata/beside/CAPTURED says", at[1], pinned[1])
}
}
// Every header the fixture requires is one this implementation actually sets.
func TestTheGoEmitterSetsEveryRequiredHeader(t *testing.T) {
f := loadFixture(t, "events/module-event.json")