Skip to content

fix(go): keep the final fuzz stats in the go test summary - #1444

Merged
KuSh merged 3 commits into
rtk-ai:developfrom
matheus-meneses:fix/go-bench-fuzz-filter
Oct 3, 2026
Merged

KuSh merged 3 commits into
rtk-ai:developfrom
matheus-meneses:fix/go-bench-fuzz-filter

Conversation

@matheus-meneses

@matheus-meneses matheus-meneses commented Apr 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Part of #1445

  • Keep the final fuzz: elapsed: line of a package in the green go test summary instead of dropping all fuzz output; the intermediate progress lines are still filtered, and a run with a failure still reports the failure.
  • Benchmark runs already pass through raw since fix: don't inject -json for go test -bench runs #1610, so nothing changes there.

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test
  • rtk go test -fuzz=FuzzRev -fuzztime=4s ./pkg prints the final fuzz stats line
  • a failing fuzz run, and a package-level failure after a green fuzz run, still report the failure

@CLAassistant

CLAassistant commented May 7, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@matheus-meneses

Copy link
Copy Markdown
Contributor Author

The code is ready for review. Thanks for the attention.

@matheus-meneses

Copy link
Copy Markdown
Contributor Author

Anything, Guys?

1 similar comment
@matheus-meneses

Copy link
Copy Markdown
Contributor Author

Anything, Guys?

@KuSh

KuSh commented Sep 27, 2026

Copy link
Copy Markdown
Collaborator

#1610 (merged 2026-05-08) changed run_test so that any -bench run skips -json and passes output through raw, which covers the benchmark part of this PR and makes the BENCH_RESULT_RE path and its tests dead code. What develop still lacks is the fuzz handling (keeping the last fuzz: elapsed: line per package instead of a bare 'N passed') and surfacing non-JSON stdout lines instead of 'Go test: No tests found', both in filter_go_test_json in src/cmds/go/go_cmd.rs, plus the fuzz and non-JSON tests. Could you rebase onto current develop and narrow the PR to that part? It conflicts with develop, and the rebase also needs the lazy_static! block turned into LazyLock, since lazy_static is no longer a dependency. Thanks for this, the fuzz output is a real gap.

@matheus-meneses

Copy link
Copy Markdown
Contributor Author

I'll do it today

… filter

Successful fuzz runs collapsed to a bare "N passed", dropping the final "fuzz: elapsed:" line. Non-JSON stdout (e.g. setup errors) was discarded, so users saw "Go test: No tests found" instead of the real error.
@matheus-meneses

matheus-meneses commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor Author

@KuSh thanks for the feedback, the PR is ready for review.

@KuSh KuSh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 1 of 3 — CHANGES REQUESTED

Claim: keep the final fuzz: elapsed: line in the green go test summary, and show non-JSON stdout lines instead of "No tests found". The benchmark part of the title and description landed in #1610 and is no longer in the diff.
Scope (round 1, frozen): accept if narrowed to "keep the last fuzz: elapsed: line per package in the green go test summary". The non-JSON surfacing is the part to cut.
Ran: rtk go test and rtk pipe -f go-test, develop merge-base against this head, on real Go 1.24.6 and 1.22.12 (docker). Green units, green fuzz (-fuzztime=4s, 100x, with -timeout), failing fuzz, missing go, -list/-n/-x/-work/-c, 9 error scenarios, plain-text and chatter-merged pipe inputs; stdout and stderr captured separately; the hook form is rtk go test …. Savings 95% on the green fuzz run vs the 20% floor. fmt, clippy and cargo test --all pass on this head (4075 tests) and on this head merged onto current develop (4106).
Pins: 4 mutations of the new logic run against the 107 go_cmd tests; 3 caught, 1 survived (blocker 2).
CI @1de69e6: 11/11 green (the run was waiting for approval; I approved it).

Blocks merge (2, frozen at round 1)

  1. src/cmds/go/go_cmd.rs:416 — the non-JSON arm is unreachable on the real producer, and wrong on the only input that reaches it.
    • rtk go test runs the filter on stdout only. Go 1.24.6 and 1.22.12 write no non-JSON line to stdout in any of the 9 scenarios above (compile failure, missing package, no go.mod, -list, -n, -x, -work, -c, bad vet flag); those errors go to stderr, which rtk already forwards. The three new tests use error: cannot find package, which no producer emits on stdout.
    • rtk pipe -f go-test is the only caller that can feed it. A green no-test stream plus one go: downloading … line (stderr merged by 2>&1) prints Go test: No tests found on develop and Go test: error + that line on this head, at exit 0. Plain-text output of 25 ok packages and one FAIL prints Go test: error, 20 ok lines and ... +10 more lines; the FAIL is in the hidden part.
    • To merge: cut the arm and its three tests (the narrowed claim above). The plain-text pipe input is tracked in #4418.
  2. src/cmds/go/go_cmd.rs:423 — unpinned behaviour: no test pins that a failing fuzz run reports the failure instead of the fuzz summary.
    • Mutation: if !has_failures && total_fuzz > 0 { → if total_fuzz > 0 { passes 107/107 go_cmd tests. With it, a crashing fuzz target prints Go test: N passed, 1 fuzz in 1 packages plus the last progress line, and the failure is gone. This precedence is the new decision in the PR; nothing exercises it.
    • To merge, a test must: feed a failing-fuzz stream (real shape: fuzz: elapsed: output events with a Test, then --- FAIL, a fail event for the test and a package-level fail), and assert the output starts with Go test: … failed, contains the failure text, and contains no fuzz in. The mutation above must turn it red.
    • The behaviour itself is correct: on a real failing fuzz run (-fuzz=FuzzRev -fuzztime=4s) develop and this head print byte-identical failure reports. This would be a fixup on its own; it is listed here because blocker 1 sends the PR back anyway.

Optional — will not hold merge

  • test_filter_go_test_fuzz_multi_package_sorted models a stream Go cannot produce: -fuzz over several packages stops with cannot use -fuzz flag with multiple packages on stderr and an empty stdout.
  • The header N fuzz in M packages counts packages, and 2 passed, 1 fuzz counts the same target in both numbers. Wording only.
  • The description still lists the benchmark change and its manual test (#1610 has it). After the narrowing, Fixes #1445 would close that issue with its third item unaddressed; Part of #1445 may fit better. That is the author's and the maintainer's call.

Filed as follow-ups

  • #4418 rtk pipe -f go-test reports plain-text go test output as "No tests found" — pre-existing; the only input that reaches the cut arm.
  • #4419 rtk go test -list prints "No tests found" while the stream lists the tests — pre-existing, outside this PR's hunks.

Checked and correct — no need to re-verify

  • The fuzz half works: -fuzz=FuzzRev -fuzztime=4s prints Go test: 2 passed in 1 packages on develop and, on this head, the same line plus fuzz: elapsed: 5s, execs: …. The kept line is Go's own last progress line, so its (0/sec) is Go's.
  • Failing fuzz runs, green unit runs and a missing go binary print the same output as develop. -fuzz -timeout 2s is a green run.
  • Mutations that were caught: keeping the first progress line instead of the last (2 tests), applying the non-JSON branch when tests passed (1 test).

Your questions

None.

Next

Delete the non-JSON arm and its three tests, and add the failing-fuzz test described in blocker 2. Then this merges once CI is green on the final head.
Rounds: 1/3. Threads: 0 open.

Comment thread src/cmds/go/go_cmd.rs Resolved
Comment thread src/cmds/go/go_cmd.rs Resolved
Non-JSON stdout never reaches the filter from rtk go test (Go writes errors to stderr), and via rtk pipe it hid real failures, so the arm and its tests are removed. Add a test asserting a failing fuzz run reports the failure instead of the green fuzz summary.
@matheus-meneses

Copy link
Copy Markdown
Contributor Author

Real run on Go 1.27.1 with the latest head.

Green fuzz run (rtk go test -run=xxx -fuzz=FuzzAdd -fuzztime=4s .), exit 0:

Go test: 1 passed, 1 fuzz in 1 packages
rev
  fuzz: elapsed: 4s, execs: 2267573 (569395/sec), new interesting: 0 (total: 1)

Failing fuzz run (rtk go test -run=xxx -fuzz=FuzzRev -fuzztime=10s .), exit 1:

Go test: 0 passed, 1 failed in 1 packages

rev (0 passed, 1 failed)
  [FAIL] FuzzRev
     rev_test.go:27: Reverse produced invalid UTF-8 string "\x82\xd5"

@matheus-meneses

matheus-meneses commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor Author

@KuSh all blockers are fixed, let me know if you have any further considerations.

A fuzz run whose package fails without a test-level fail (TestMain
exiting non-zero after a green run) must report the failure, not the
fuzz summary. Also move the comment back above the output push and
restore the blank line the previous commit removed.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

@KuSh KuSh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 2 of 3 — APPROVED, follow-ups filed

Claim: keep the final fuzz: elapsed: line of a package in the green go test summary.
Scope (round 1, frozen): accept if narrowed to that claim. The PR is now exactly that.
Ran: rtk go test and rtk pipe -f go-test, develop merge-base against this head and against the fixup below, on Go 1.26.1. Green and failing fuzz (-fuzztime=4s, 100x, with -timeout), units, -list, no tests, setup failure, missing go, a TestMain that exits non-zero after a green fuzz run, the hook form (rtk go test …); stdout and stderr captured separately. Everything except the fuzz line is byte-identical to develop, and both round-1 pipe repros now match develop. Savings on green fuzz runs 95–96% vs the 20% floor.
Pins: 10 mutations of the new logic on 4daca6a; the capture, keep-last, count, header and failure-over-fuzz guard mutations are caught. Four pass the suite (sort, swapped header counts, the fuzz: prefix, trim_end) and none changes the output of a stream Go can emit: -fuzz over several packages is refused by Go, and a green fuzz run only prints fuzz: elapsed: lines. On the fixup, narrowing the guard to total_fail == 0, dropping total_pkg_fail and dropping the guard each turn a test red.
CI @77b6861: 11/11 green. fmt, clippy and cargo test --all also pass locally on the fixup (4073 tests), and the fixup applies cleanly on current develop.

Blocks merge (0; the 2 from round 1 are fixed in 4daca6a)

  1. The non-JSON arm is removed; the pipe outputs are identical to develop.
  2. Failing-fuzz precedence is pinned by test_filter_go_test_failing_fuzz_reports_failure_not_fuzz_summary; the if total_fuzz > 0 mutation turns it red.

Filed as follow-ups

  • #4434 A failing fuzz run drops the failing-input path and the re-run command — pre-existing, outside this PR's hunks.
  • #4418 and #4419 from round 1 are unchanged.

Checked and correct — no need to re-verify

  • The summary with the fuzz line appears only on green runs. Failing fuzz, unit failures and package-level failures print the same as develop.
  • Missing go, the hook form and the setup-failure row are unchanged from develop.

Your questions

None.

Next

Fixup 77b6861 pushed, code-reviewed and run before/after by a fresh agent (six rows identical) — approving. It adds test_filter_go_test_fuzz_package_failure_reports_failure_not_fuzz_summary (a package-level failure after a green fuzz run, the real TestMain exit-3 shape, must report the failure), restores the blank line the PR deleted, and puts a comment back above the code it describes. No production behaviour changes.
Rounds: 2/3. Threads: 0 open, 1 resolved this round (the other was already resolved).

@KuSh KuSh changed the title fix(go): preserve benchmark and fuzz output in go test filter fix(go): keep the final fuzz stats in the go test summary Oct 3, 2026
@KuSh
KuSh merged commit c356374 into rtk-ai:develop Oct 3, 2026
12 checks passed
@rtk-release-bot rtk-release-bot Bot mentioned this pull request Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants