Repository navigation
report test2json: report packages that fail to build - #44
Open
DzmitryHumianiuk wants to merge 2 commits into
Open
DzmitryHumianiuk wants to merge 2 commits into
DzmitryHumianiuk wants to merge 2 commits into
Conversation
Since Go 1.24 'go test -json' puts the build events of the go command into the stream: build-output and build-fail, with an ImportPath and without Time or Package, and the package's fail event names the failed build in FailedBuild. The reporter treated them as test events: the first one started the launch at the zero time, and the failed package was not reported at all, since it has no test. Build output is now kept per ImportPath. A package that fails with FailedBuild is reported as a FAILED suite with the output of that build as one ERROR log. Build events neither start the launch nor move its end time. The fixtures are unedited 'go test -json' output of go1.27.4. Part of #26. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part of #26 (slice C4). Stacked on C3 (
feat/test2json-launch-uuid) → C2 → #29. The change itself only needs #29.Since Go 1.24,
go test -jsonwrites the go command's build events into the same stream as the test events.report test2jsondid not know them. Two things went wrong with a real stream of a package that does not compile:Time, and the first event of the stream starts thelaunch. Observed on the demo server with the binary of the base branch:
"startTime":"0001-12-30T00:00:00Z".failevent wasignored. The launch was
FAILEDwith nothing in it that failed, and the compiler output was dropped.Changes
testEventgetsImportPath.build-outputandbuild-failevents are recognised (isBuildEvent); they neverstart the launch and never move the time the launch is finished with.
ImportPath.failevent withFailedBuild:--reportEmptyPkg),FailedBuildas oneERRORlog on the suite, stamped with the timeof the
failevent,FAILED. The launch isFAILED, as before.reported as
FAILEDand a warning is logged.internal/commands/testdata/buildfail/*.jsonl: unedited stdout ofgo test -json, go1.27.4.hierarchyServer(test fake) now records log entries and the launch finish body.FailedBuildnote in AGENTS.md (which said it was a Go 1.27 field and not acted on).Behaviour change
FAILEDsuite with anERRORlog. Before it did not appear.FAIL\t<package> [build failed]line of the test output is still a launch-level log when thesuite does not exist yet at that point (without
--reportEmptyPkg), like any package output without a suite.STEPitems, so the launch's executions (total/passed/failed) do not countit. The launch status is
FAILED.Verification
go build ./... && go vet ./... && go test -race ./...: ok. Lint (run ./...,run --build-tags e2e ./e2e/...):0 issues.
TestReportLaunch_BuildFailuresruns the three real streams (andmixed.jsonlwith--reportEmptyPkg):suite type,
FAILEDstatus, the exact log text, number of items, launchFAILED, launch start and end timefrom 2026 (not the zero time).
TestReportLaunch_BuildFailureWithoutBuildOutputcovers a pre-1.24 stream.scratchpad/wave/live-c4.sh, logscratchpad/wave/live/c4.log, same filemixed.jsonl:startTime 0001-12-30T00:00:00Z, items: only…/okandTestOne.startTime 2026-11-27T22:38:27.286697Z; suites…/brokentest,…/usea,…/usebFAILED,…/okPASSED;errorlogs on the three failed suites with the compiler output (undefined: three, …;# example.com/buildfail/depon bothuseaanduseb). Executions: total 1, passed 1.go test -tags e2e -count=1 -v -run BuildFailure ./e2e/...→PASS TestReportTest2JSON_BuildFailure (3.46s).Investigation log
go help buildjson(structBuildEvent{ImportPath, Action, Output}, actionsbuild-output/build-fail, "does not matchTestEvent.Package") and
go doc cmd/test2json("The FailedBuild field is set for Action == "fail" if the testfailure was caused by a build failure … matches … BuildEvent.ImportPath").
scratchpad/wave/mkbuildfail.shbuilds a module withbrokentest(test file does not compile),dep(does not compile) imported byuseaanduseb,ok, andvetfail(failsgo vet), and recordsgo test -jsonfor several package sets intoscratchpad/wave/buildfail/out/. What the streams show:Timeand noPackage;ImportPathof a test build ispkg [pkg.test], of a dependency justpkg;start, oneoutput(FAIL\tpkg [build failed]), andfailwith"Elapsed":0,"FailedBuild":"<ImportPath>"; norunevent;useaandusebboth nameexample.com/buildfail/dep;FailedBuild= the test build).receive()ininternal/commands/reporter.gostarted the launch withev.Timeof the first event of any kind and overwrote the end time on every event. Confirmed live (see above).finishSuitereturned early when no suite exists and--reportEmptyPkgis off.it by line only. The entry gets the
failevent's time because build events have none.Time(checked by runninggo test -json ./ok/twice), so build events arethe only events without one.
Not verified
go help buildjson, but was not captured with an older toolchain.failrefers to (for example warnings of a successful build) is kept in memoryand not reported. No real stream with such output was produced.
🤖 Generated with Claude Code