From 746eb885a3f1fb5cef3f44b61592ec5db7a63819 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 23 Oct 2026 22:14:28 +0200 Subject: [PATCH] Test 1901/AC3: an older pair of build module and checker still agree (issue 1901) --- .../cmd/mesh-build-go/failure_words_test.go | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/modules/mesh-build-go/cmd/mesh-build-go/failure_words_test.go b/modules/mesh-build-go/cmd/mesh-build-go/failure_words_test.go index fede32e4..7a061993 100644 --- a/modules/mesh-build-go/cmd/mesh-build-go/failure_words_test.go +++ b/modules/mesh-build-go/cmd/mesh-build-go/failure_words_test.go @@ -1,6 +1,7 @@ package main import ( + "encoding/json" "os" "strings" "testing" @@ -27,7 +28,7 @@ func TestAFailedTestKeepsItsFatalMessageAfterItsLogLines(t *testing.T) { } } if want := "3 subscription(s) derive to a subject no emitter owns:"; f.Cause != want && !strings.HasSuffix(f.Cause, want) { - t.Errorf("1901/AC2: cause = %q, want the t.Fatalf line, not the t.Logf line", f.Cause) + t.Errorf("1901/AC1: cause = %q, want the t.Fatalf line, not the t.Logf line", f.Cause) } } @@ -46,3 +47,32 @@ func TestAFailureLongerThanTheBoundKeepsItsLastLines(t *testing.T) { t.Errorf("1901/AC1: out = %q...%q", out[:40], out[len(out)-60:]) } } + +// An older checker, which knows no "cause" field, still reads the new build module's answer, and the output it gets +// holds at least what the older build module kept (its first lines, for an output shorter than the bound). +func TestAnOlderCheckerReadsTheNewFailureAndGetsAtLeastWhatItKept(t *testing.T) { // 1901/AC3 + raw, err := os.ReadFile("testdata/captured/go-test-json-log-then-fatal.jsonl") + if err != nil { + t.Fatal(err) + } + res := &TestResult{} + rd := newReader(res, ".") + rd.read(string(raw)) + rd.finish() + b, err := json.Marshal(res.Failed) + if err != nil { + t.Fatal(err) + } + var old []struct { + Package string `json:"package"` + Test string `json:"test,omitempty"` + Output string `json:"output,omitempty"` + } + if err := json.Unmarshal(b, &old); err != nil || len(old) != 1 { + t.Fatalf("1901/AC3: an older checker refused the answer: %v, %d failures", err, len(old)) + } + first := strings.SplitN(old[0].Output, "\n", 2)[0] + if first == "" || !strings.Contains(old[0].Output, "judged against") || !strings.Contains(old[0].Output, "3 subscription(s)") { + t.Errorf("1901/AC3: older checker's output = %q", old[0].Output) + } +}