Repository navigation
fix(pipe): preserve non-JSON Go test reports - #4455
Conversation
📊 Automated PR Analysis
SummaryThis PR fixes the Review Checklist
Linked issues: #4418 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
28051d2 to
e11a981
Compare
KuSh
left a comment
There was a problem hiding this comment.
Round 1 — CHANGES REQUESTED
Claim: rtk pipe -f go-test (and auto-detected Go JSON) passes input that is not a Go test event stream through unchanged instead of reporting Go test: No tests found.
Scope: accept. The plain-text fix for #4418 works as stated; what holds merge is inside the new recognizer.
Ran: real go test from Go 1.24.6 and Go 1.27.1 on a 31-package module, plain and -json, plus go tool test2json and go build -json. Cases: green, failing after 25 ok, build failure, zero tests, t.Attr, -artifacts, parallel/skip/subtest/panic, cold module cache. 27 streams × develop 5538d72 / head d94b031, 20 of them also through auto-detect (rtk pipe without -f). Invariants: split streams (stdout only and 2>&1), under the hook (the hook leaves … | rtk pipe -f go-test as typed, and go test goes to the unchanged runner), every decision. Savings: valid JSON 99–100% on both builds; plain text 0% by design (lossless fallback).
Pins: 12 decisions, 24 mutations, 7 survived (6 allowlist entries: start, output, skip, pause, cont, bench; the empty-name conjunct)
Matrix: executed this round; pin check: executed this round
CI @d94b031: all green (15/15)
Blocks merge (2, frozen at round 1)
-
src/cmds/go/go_cmd.rs:326— the recognizer rejects streams that develop summarizes correctly (6 producer shapes, one cause: the all-or-nothing accept set is stricter than whatfilter_go_test_jsonalready handles). Evidence, each a real captured stream throughrtk pipe -f go-test, develop → head:- Go ≥1.25, a test calling
t.Attr("issue", "4455"),go test -json ./...(emits{"Action":"attr",…,"Key":"issue","Value":"4455"}):Go test: 51 passed in 27 packages→ the whole 45,295-byte stream raw. - Go ≥1.26,
t.ArtifactDir()undergo test -json -artifacts(emits"Action":"artifacts"):Go test: 3 passed in 2 packages→ raw. go test -c -o s.test ./pkg && go tool test2json -t ./s.test -test.v=test2json(noPackageon any event):Go test: 4 passed, 2 failed, 1 skipped in 1 packages+ the failures → 4,704 bytes raw.- A UTF-8 BOM before the first event (what Windows PowerShell 5.1
Out-File -Encoding utf8writes):51 passed, 1 failed in 27 packages→ 44,616 bytes raw. go test -json ./... 2>&1on a cold module cache, where Go writes twogo: downloading golang.org/x/text v0.21.0lines to stderr:Go test: 51 passed in 26 packages→ 44,503 bytes raw. One line that isn't an event is enough to turn off the filter for the whole report.- A stream cut mid-object (
head -c 20050of a failing run):Go test: 23 passed in 16 packages→ 20,050 bytes raw.
For the last two, the PR's goal of not dropping lines silently and develop's summary are both achievable: the summary plus the non-event lines verbatim keeps every line that isn't an event and still compresses the events.
mixed_json_and_text_keeps_every_linecurrently pins the whole-stream raw output and would change with it.In the other direction, within this PR's claim though not a regression:
go build -json ./broken(onlybuild-output/build-failevents) is accepted and printsGo test: No tests found, droppingbroken/b.go:3:23: undefined: missing. Develop prints the same thing; the PR's G1 says this input should be preserved.
Test must: run each of these captured streams throughpipe -f go-testand assert the summary (for the2>&1stream: the summary and bothgo: downloadinglines; for the build-only stream: the compile error is in the output).attrandartifactsare the 1.25 and 1.26 additions to an action set the test2json docs call fixed, so expect another one: a check that accepts only the actions it knows will need updating with each Go release. - Go ≥1.25, a test calling
-
src/cmds/go/go_cmd.rs:326— unpinned behaviour (action allowlist entries). Evidence: removing"start","output","skip","pause","cont"or"bench"from the match passes the whole suite (pipe_cmd and go_cmd unit tests +go_test_pipe_test). Every real stream begins withstart, hasoutputevents, andskipfor a package with no test files;pause/contcome fromt.Parallel.valid_json_events_still_use_the_existing_filterdoes not catch the missing"output": its fail case falls back to raw, and the raw input also containsTestXandx_test.go:12and notNo tests found. Test must: run a realgo test -json ./...stream from a module with a no-test-files package, at.Parallelpair, and a benchmark that callsb.Log, and assert the exact summary line. Each of the six mutations must turn it red; assertingshown != inputin the existing fail case closes theoutputone.
Optional — will not hold merge
go_cmd.rs:311says "Recognize a complete event stream"; the function checks each line's shape, not completeness (your PR body says so). A stream cut at a line boundary beforeTestX'sfailevent still summarizes as50 passed, same as develop (#4693).go_cmd.rs:332: thename.is_empty()half survives mutation, and no Go producer emits"Package":""(the field isomitempty). Either drop it or pin it.
Filed as follow-ups
- #4692
rtk pipewithout-freads plaingo testoutput as find/grep results — pre-existing, outside this PR's hunks; filed. - #4693 go test JSON filter reports a cut-off stream as all passed — pre-existing, outside this PR's hunks; filed.
Checked and correct — no need to re-verify
- Plain text from both Go versions (green, failure after 25
oklines, build failure on stdout-only and2>&1, zero tests) comes back byte for byte with exit 0; develop printedGo test: No tests foundfor every one. - Valid
-jsonstreams (green, failing, build failure, zero tests on both Go versions; stdout-only cold-cache run; parallel/skip/subtests/panic) give output byte-identical to develop. rtk go test(the runner) is unchanged and unaffected.cargo fmt --check,cargo clippy --all-targets(0 warnings) andcargo test --all(4528 passed) on the head, which already contains the develop tip.
Your questions
None asked.
Next
A recognizer that summarizes the six stream shapes in item 1 (keeping the non-event lines of the last two, and not summarizing away a build-only stream), and a test over real captured streams that kills the six allowlist mutations in item 2.
Rounds: 1. Threads: 2 open (waiting on the author), 0 resolved this round.
|
At synced head 810ab1f, 13/14 CI checks passed. The only failure is the unchanged CTest test Could a maintainer rerun just this failed Windows MSVC job once? My attempt returned HTTP 403: "Must have admin rights to Repository." |
KuSh
left a comment
There was a problem hiding this comment.
Round 2 — CHANGES REQUESTED
Claim: rtk pipe -f go-test (and auto-detected Go JSON) passes input that is not a Go test event stream through unchanged instead of reporting Go test: No tests found.
Scope: accept (round 1, frozen).
Ran: real go test from Go 1.24.6 and Go 1.27.1 on a 33-package module, plain and -json (green, failing, build failure, zero tests, t.Attr, -artifacts, parallel/skip/subtest/panic, benchmarks chatty and -v=false), plus go tool test2json with and without -t, go build -json, and go test -json ./... 2>&1 on a cold module cache. Also derived streams: BOM, CRLF, cut mid-object, cut at a line boundary, two runs concatenated. 33 streams × develop 6c2313a / this head merged onto it, through pipe -f go-test and auto-detect; benchmark rows also on v1.0.1. Invariants: split streams, every decision. Savings on valid JSON 94–100%.
Pins: 20 decisions, 43 mutations, 17 survived the suite; 4 of them change the output on real streams (below), the other 13 change nothing on any of the 33 streams.
Matrix: executed this round @810ab1f7b; pin check: executed this round
CI @810ab1f7b: 1 failing: test (windows-latest), caps_failed_test_entries_with_one_complete_section_tee (left 0, right 1). The test is outside this PR's diff; see your question below.
Both round-1 blockers are fixed: every row of item 1 now summarizes (attr, artifacts, test2json with and without timestamps, BOM, 2>&1 with the go: downloading line kept, mid-object cut with the fragment kept, build-only stream raw), and all nine lifecycle actions are now pinned by the captured-stream tests. Threads resolved.
Blocks merge (2 from round 1, closed; +3 on code added in bd8fc65)
-
src/cmds/system/pipe_cmd.rs:200— auto-detect now routes text that quotes Go events into the reducer, which removes those lines.is_go_test_json(input)scans every line, andpipe_event_linetrims leading spaces, so one event-shaped line anywhere is enough. Evidence,rtk pipewith no-f, develop → this head:git diff --no-indexoftests/fixtures/go_test_pipe/failure.jsonlagainst a copy with oneElapsedchanged: unchanged (1,413 bytes) → 414 bytes,Go test: No tests foundon top and all six context lines gone, so the hunk no longer matches its@@ -2,7 +2,7 @@header.- A markdown note quoting three events (
run, anoutputwithflaky_test.go:12: got 3, want 4,pass) in a fenced block: unchanged (493 bytes) → 173 bytes,Go test: 1 passed in 1 packagesand an empty fence; the quoted diagnostic is gone.
Fix must: return both inputs unchanged under
rtk pipe. Two ways reach that, your call: keep develop's first-line check (drop theis_go_test_json(input) ||disjunct; the auto-detect variants ofcaptured_cold_cache_stderr_survives_next_to_the_summaryandleading_bom_does_not_disable_a_captured_streamthen change with it), or keep the whole-input scan and also keep the cold-cache2>&1stream summarized under auto-detect. -
src/cmds/go/go_cmd.rs:337— unpinned behaviour (the key check on package-less records). Each of these passes the whole suite and changes the output of a realgo tool test2json -t ./x.test -test.v=test2jsonstream: removing"Time"from the allowed keys (thestartandfaillines are appended raw after the summary), removing"Elapsed"(thefailline), and dropping the&& event.output.is_none()conjunct (the{"Action":"output","Output":"FAIL\n","OutputType":"frame"}line). Test must: run the capturedpackage_less.jsonlandpackage_less_no_time.jsonlthroughpipe -f go-testand assert the whole output; each of the three mutations must turn it red. -
src/cmds/go/go_cmd.rs:422— unpinned behaviour (consuming build records that a package-level fail represents). Changingindex < *fail_indextoindex < *fail_index && falsepasses the whole suite, and on a realgo test -jsonbuild failure the summary becomesbroken [build failed]with no error under it while the three build records are appended as raw JSON (105 → 473 bytes). The current assertions hold because the raw JSON also containsundefined: missing. Test must: assert the exact summary of a captured build-failure stream, withbroken/b.go:3:23: undefined: missingunderbroken [build failed]and no JSON after it.
Optional — will not hold merge
- Two
go test -jsonruns concatenated (a CI retry log):repeated_build_failureclearsrepresented_buildsfor every package, so each[build failed]block prints without its errors and all build errors follow as raw JSON (106 → 880 bytes; nothing is lost). Clearing only the repeated package would keep the others readable. - 13 surviving mutations change nothing on any of the 33 real streams (summary package order aside, which is random between runs on develop too): the
ImportPath/Outputrequirements on build records (unmatched ones end up in the residual either way), each single field inpipe_test_evidence, build events counted as evidence, BOM stripping past line 1,is_go_test_jsonaccepting any supported event, counting test-level fails inrepeated_build_failure, passingrawinstead oflineto the reducer, and the old first-line disjunct in auto-detect. Simplifying them is your call.
Filed as follow-ups
- #4862
pipe -f go-testdrops benchmark results:-v=false -benchgivesGo test: No tests found, the chatty run loses itsns/opline. Same on v1.0.1 and develop; #1445 fixed the runner path only.
Checked and correct — no need to re-verify
- Every valid
-jsonstream from both Go versions gives the same summary as develop; streams develop already handled are byte-identical apart from the residual lines this PR adds on purpose. - Plain text from both Go versions (green, failing, build failure, zero tests; stdout only and
2>&1) passes through byte for byte, exit 0. - CRLF, an unterminated final fragment and a BOM come back intact in the residual.
cargo fmt --check,cargo clippy --all-targets(0 warnings) andcargo test --all(4803 passed) on this head merged onto develop 6c2313a.
Your questions
- "Could a maintainer rerun just this failed Windows MSVC job once?" → Flagged for a rerun. The failing test is in
ctest_cmd, which this PR does not touch, and it passed on this head's Windows GNU job and on the MSVC job of d94b031. I could not reproduce it locally.
Next
Items 1–3 above. Both round-1 blockers are closed.
Rounds: 2. Threads: 3 open (waiting on the author), 2 resolved this round.
A cold-cache stream whose first package fails to build opens with a download line and build records, so auto-detection must keep scanning to the first test event. Only download lines are skipped before a stream; other go command output keeps the input verbatim. Both cases use real Go 1.27.1 captures. Co-Authored-By: Claude Opus 5.5 <[email protected]>
KuSh
left a comment
There was a problem hiding this comment.
Round 3 — APPROVED
Claim: rtk pipe -f go-test (and auto-detected Go JSON) passes input that is not a Go test event stream through unchanged instead of reporting Go test: No tests found.
Scope: accept (round 1, frozen); maintainer PRs: none overlap.
Ran: real go test from Go 1.27.1 and Go 1.26.1 on 9- and 4-package modules, plain and -json (green, failing, panic, build failure, zero tests, t.Attr, -artifacts, parallel/skip/subtest, benchmarks chatty and -v=false), go test -json ./... 2>&1 on a cold module cache, with text build output (GODEBUG=gotestjsonbuildtext=1), with a -coverpkg warning and with -mod=mod resolution, go tool test2json with and without -t, go build -json. Derived: BOM, CRLF, leading blank lines, an echoed command line before the stream, cut mid-object, cut at a line boundary, two runs concatenated. Text quoting events: a git diff of a captured stream, a markdown note, a patch. 38 inputs × v1.1.0 / develop 22812af / 810ab1f / this head merged onto develop, through pipe -f go-test and auto-detect. Invariants: split streams, every decision. Savings on valid JSON 86–99%.
Pins: 12 decisions (the new auto-detect loop and its caller, plus the four round-2 items), 13 mutations; 2 survived the author's suite and are killed by the tests in 15cf650.
Matrix: executed this round @139618d80; pin check: executed this round
CI: all green on 139618d (15/15); on 15cf650 (fixup) all green (15/15)
All three round-2 blockers are fixed; threads resolved.
Blocks merge (3 from round 2, closed)
src/cmds/system/pipe_cmd.rs:200— auto-detect on quoted events. Fixed: thegit diffand markdown rows come back byte for byte, as on develop, and the cold-cache2>&1stream and a BOM-prefixed stream are still summarized under auto-detect. Since 810ab1f only three auto-detect rows changed (the two quoted-text rows, and a stream preceded by an echoedgo testcommand line, now raw as on develop); every-jsonstream gives the same output as before.src/cmds/go/go_cmd.rs:337— package-less key check. Fixed: dropping"Time", dropping"Elapsed"and dropping&& event.output.is_none()each turncaptured_package_less_test2json_with_and_without_timestamps_is_summarizedred.src/cmds/go/go_cmd.rs:434— build-record consumption. Fixed:index < *fail_index && falseturnscaptured_build_failure_has_an_exact_summary_without_raw_jsonred.
Fixup 15cf650 (tests and fixtures only)
Two decisions of the new is_go_test_json loop changed real output without failing a test:
- continuing past events without test evidence: returning
falsethere leaves a cold-cachego test -json ./... 2>&1whose first package fails to build completely raw under auto-detect (753 → 18,842 bytes).captured_cold_cache_build_failure_is_summarized_past_its_build_recordspins the summary on a real Go 1.27.1 capture. - skipping only
go: downloadinglines: widening it to anygo:line summarizes a-mod=modstream that opens withgo: finding module, which this head (like develop and v1.1.0) passes through unchanged.captured_stream_after_other_go_command_output_is_not_auto_detectedpins the current behaviour on a real capture, and its-f go-testoutput.
It also documents the two captures in the fixture README (sources, go.mod, flags) and renames its "Round 2 regression captures" heading to "Build-failure and quoted-input captures". No production code changes.
Filed as follow-ups
- #4692 (existing) — auto-detect misses
go test -jsonstreams with go command output before the first event; with text build output in front, the grep heuristic keeps the compile error and drops the test failures. Same on v1.1.0 and develop; comment added. - #4862
pipe -f go-testdrops benchmark results — pre-existing; filed at round 2.
Checked and correct — no need to re-verify
- Every other mutation of the new loop is killed: blank-line skip, the
go: downloadingskip, stop at the first non-event line, stop at the first event with test evidence, finalfalse, BOM on line 1, and the caller inpipe_cmd.rs. - Every valid
-jsonstream from both Go versions gives the same summary as at round 2; plain text passes through byte for byte under-f go-test. cargo fmt --check,cargo clippy --all-targets(0 warnings) andcargo test --all --no-fail-fast(5464 passed, 0 failed) on 15cf650 merged onto develop 22812af.
Next
Fixup 15cf650 pushed, code-reviewed: it adds two tests on real captures and renames a README heading — approving.
Rounds: 3. Threads: 0 open, 3 resolved this round.
Summary
pipe -f go-testJSON filterGoTestEventschema for recognition; leave the Go runner and its JSON result/fuzz/build parsers unchangedCloses #4418. This is the plain-text follow-up to merged #1444 and does not change the list/fuzz routing addressed by #4430 / #4437 / #4438.
Spec-driven re-review
Acceptance was derived from #4418, the repository's lossless fallback principle, and Go's event schema before inspecting this implementation.
plain_failure_after_many_successes_is_preserved_in_full,plain_success_empty_and_non_event_json_are_not_misclassified,mixed_json_and_text_keeps_every_line, and the addedraw_fallback_preserves_line_endings_and_unterminated_text(CRLF, Unicode, whitespace, no trailing newline).output_shaped_json_without_output_is_not_a_test_reportexposed one missed case: an object with Action/Package but no Output lost its diagnostic and becameNo tests found. It failed on the original PR implementation (6 CLI tests passed, 1 failed). A five-line guard now leaves output/build-output records without their required payload unchanged; all 7 CLI tests pass. Matching wrapper unit cases cover the same boundary.valid_json_events_still_use_the_existing_filter, addedpadded_json_and_build_failures_keep_existing_summaries, and existing Go parser tests. The runner, list/fuzz routing, and renderer are unchanged.Package-less
go tool test2jsoninput is conservatively retained raw; Package is optional in that tool's format, so this is a lossless fallback, not a claim that such JSON is malformed. This recognizer checks individual event shapes, not sequence completeness.pipecannot recover the upstream command's status. No plain-text parser or new framework is added.Verification
cargo fmt --all --check,cargo clippy --offline --all-targets, andcargo test --offline --allpassed: 4,122 tests passed; 8 pre-existing ignored tests were not runCI run 37336140553 passed for
fb79b81d570ec3249cc17a66b5a2af0a7baee94f, including Windows/macOS/Linux tests, formatting, clippy, benchmark and security jobs. CLA status passed. The target-branch job is intentionally skipped for the develop base. The optional AI documentation review was skipped because its repository API key is not configured; the job reports success.The spec-driven self-review has no remaining known in-scope finding. Ready for maintainer review.