From 4771ee53d93881b1b4f32e517ed05c6cc31f5c7d Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 21 Oct 2026 15:21:10 +0200 Subject: [PATCH] Name the failing line in a failed check's summary, not the warning count printed last (issue 1310) --- internal/builder/check.go | 15 +++++++++++++++ internal/builder/check_test.go | 26 ++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/internal/builder/check.go b/internal/builder/check.go index 3d333a8c..075c55cb 100644 --- a/internal/builder/check.go +++ b/internal/builder/check.go @@ -1773,9 +1773,24 @@ func whatFailed(s string) string { } } } + // The controller's module check refuses with a count line and one line per problem, then prints its + // warning counts: the refusal is what failed, not the count printed last (novox/hq issue 1310). + for i, line := range lines { + if line = strings.TrimSpace(line); problemsLine.MatchString(line) { + if i+1 < len(lines) { + if first := strings.TrimSpace(lines[i+1]); first != "" { + return line + ": " + first + } + } + return line + } + } return lastLine(s) } +// problemsLine is the module check's refusal: "mesh-controller: 3 problem(s) in 139 manifest(s)". +var problemsLine = regexp.MustCompile(`^\S+: [1-9]\d* problem\(s\) in \d+ manifest\(s\)$`) + func lastLine(s string) string { lines := strings.Split(strings.TrimSpace(s), "\n") return strings.TrimSpace(lines[len(lines)-1]) diff --git a/internal/builder/check_test.go b/internal/builder/check_test.go index 63aea2a4..7618a3b1 100644 --- a/internal/builder/check_test.go +++ b/internal/builder/check_test.go @@ -199,3 +199,29 @@ func TestOnlyATrysSelectionReachesTheScript(t *testing.T) { t.Fatalf("a try's selection: %v", env) } } + +// **Issue 1310**: the controller's module check prints its warning counts after its refusal; a failed check +// is said by the refusal, never by the count printed last. +func TestAFailedModuleCheckIsSaidByItsRefusalNotItsWarningCount(t *testing.T) { + log := "mesh-controller: 3 problem(s) in 139 manifest(s)\n" + + "mesh-files claims node-files and says it serves upload, download, which that seat's protocol does not promise\n" + + "minio claims the seat \"object-store\", which no module declares and the mesh does not define\n" + + "only-office claims the seat \"document-converter\", which no module declares and the mesh does not define\n" + + "adwaita: ok, 4 tool(s)\nlong-running resources without health: 59\n" + + "files asking for a setting without saying whether it is trusted: 36\n" + // 1310/AC1 + want := "mesh-controller: 3 problem(s) in 139 manifest(s): mesh-files claims node-files and says it serves upload, " + + "download, which that seat's protocol does not promise" + if got := whatFailed(log); got != want { + t.Errorf("1310/AC1: the captured log is said as %q, not %q", got, want) + } + // 1310/AC2 + if got, want := whatFailed("ok \tx/a\t1s\n--- FAIL: TestX (0.01s)\n x_test.go:12: got 1\nFAIL\nlong-running resources without health: 59\n"), + "--- FAIL: TestX (0.01s)"; got != want { + t.Errorf("1310/AC2: a failing test is said as %q, not %q", got, want) + } + // 1310/AC3 + if got, want := whatFailed("starting\nsomething odd happened\n"), "something odd happened"; got != want { + t.Errorf("1310/AC3: a log with no failure line is said as %q, not %q", got, want) + } +} -- 2.54.0