diff --git a/internal/link/conformance_sources_test.go b/internal/link/conformance_sources_test.go index 53e40484..06a0fcd7 100644 --- a/internal/link/conformance_sources_test.go +++ b/internal/link/conformance_sources_test.go @@ -104,7 +104,7 @@ func TestAMergeCheckFailsACapturedCopyEditedByHand(t *testing.T) { } } -// A pin the clone does not hold, or no clone at all, fails loudly and names what is missing. +// A pin the clone does not hold fails loudly and names it. func TestAMergeCheckFailsWithoutTheSDKAtItsPin(t *testing.T) { b := newSDKBed(t) b.pin(t, "0123456789ab0123456789ab0123456789ab0123") @@ -112,9 +112,18 @@ func TestAMergeCheckFailsWithoutTheSDKAtItsPin(t *testing.T) { !strings.Contains(err.Error(), "0123456789ab") { t.Errorf("a pin the clone lacks was not named: %v", err) } - if _, _, err := sdkFixture(t.TempDir(), b.goMod, b.captured, b.capturedLog, fixtureName); err == nil || - !strings.Contains(err.Error(), "not beside this check") { - t.Errorf("a missing clone was not refused: %v", err) +} + +// Until mesh-controller #220 has rolled out the seat places no mesh-sdk beside a check: the captured copy is +// read, and where it was read from says plainly that the clone did not judge it (novox/hq issue 449). +func TestAMergeCheckWithoutTheCloneSaysItReadTheCapturedCopy(t *testing.T) { + b := newSDKBed(t) + raw, from, err := sdkFixture(t.TempDir(), b.goMod, b.captured, b.capturedLog, fixtureName) + if err != nil || string(raw) != "older\n" { + t.Fatalf("read %q, %v; the captured copy holds the older", raw, err) + } + if !strings.HasPrefix(from, "NOT JUDGED AGAINST THE CLONE") || !strings.Contains(from, b.older) { + t.Errorf("the log does not say the clone was missing and which copy was read: %q", from) } } diff --git a/internal/link/conformance_test.go b/internal/link/conformance_test.go index 66c7471e..048ba4f3 100644 --- a/internal/link/conformance_test.go +++ b/internal/link/conformance_test.go @@ -10,6 +10,7 @@ import ( "path/filepath" "regexp" "strings" + "sync" "testing" "time" @@ -26,8 +27,9 @@ import ( // - in a merge check, the fixture as it stands at that pin in the mesh-sdk clone the build seat places // beside the check — read with `git show`, because the clone is checked out at the *running* // controller's pin, and a pull request moving the SDK must be judged against the SDK it moves to, or it -// passes the check and fails everywhere after it rolls out. A missing clone or a pin the clone lacks -// fails the test; +// passes the check and fails everywhere after it rolls out. A pin the clone lacks fails the test; a +// missing clone reads the captured copy and says so loudly, until mesh-controller #220 has rolled out +// and the build seat clones mesh-sdk (then its follow-up makes a missing clone fail again); // - elsewhere, the copy captured in testdata/beside at the commit testdata/beside/CAPTURED names, held to // go.mod by TestTheCapturedSDKIsTheOneGoModPins. // @@ -67,6 +69,10 @@ func loadFixture(t *testing.T, name string) fixture { t.Fatal(err) } t.Logf("%s: %s", name, from) + if strings.HasPrefix(from, notJudged) { + // Said on the check's own output too, where `go test` without -v prints no log of a passing test. + saidNotJudged.Do(func() { fmt.Fprintln(os.Stderr, "internal/link conformance: "+from) }) + } var f fixture if err := json.Unmarshal(raw, &f); err != nil { t.Fatalf("%s: %v", name, err) @@ -74,22 +80,41 @@ func loadFixture(t *testing.T, name string) fixture { return f } +// notJudged opens what a merge check without the SDK's clone says; saidNotJudged says it once on stderr. +const notJudged = "NOT JUDGED AGAINST THE CLONE" + +var saidNotJudged sync.Once + // sdkFixture is one conformance fixture and where it was read: from the mesh-sdk clone in root (a merge // check's MESH_CHECK_BESIDE) at the pin of goMod, or, with no root, from the captured copy. func sdkFixture(root, goMod, captured, capturedLog, name string) ([]byte, string, error) { file := path.Join("conformance", name) - if root == "" { + readCaptured := func() ([]byte, error) { raw, err := os.ReadFile(filepath.Join(captured, filepath.FromSlash(file))) if err != nil { - return nil, "", fmt.Errorf("the captured SDK's %s: %w", file, err) + return nil, fmt.Errorf("the captured SDK's %s: %w", file, err) } + return raw, nil + } + if root == "" { + raw, err := readCaptured() return raw, "the copy captured in testdata/beside (see CAPTURED); a merge check reads the SDK's clone " + - "at this tree's pin", nil + "at this tree's pin", err } clone := filepath.Join(root, "mesh-sdk") if _, err := os.Stat(clone); err != nil { - return nil, "", fmt.Errorf("mesh-sdk is not beside this check in %s=%s, so the SDK this controller "+ - "pins cannot be judged here: %w", beside.Env, root, err) + // A build seat asked by a controller from before mesh-controller #220 places no mesh-sdk beside the + // check, so #220 could never pass its own check if this failed. Until #220 has rolled out, the + // captured copy is read and the log says so loudly; the follow-up of novox/hq issue 449 makes this + // a failure again. + at, cerr := capturedCommit(capturedLog) + if cerr != nil { + return nil, "", cerr + } + raw, rerr := readCaptured() + return raw, fmt.Sprintf(notJudged+": the seat placed no mesh-sdk beside this check in "+ + "%s=%s (it does once mesh-controller #220 has rolled out); read the captured copy at %s", beside.Env, + root, at), rerr } ref, err := sdkRef(goMod) if err != nil {