-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/test2json: test output without trailing newline missing final status #57172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Comments
I think this is a question for the community on how we want to handle this case. Some options I see are:
|
previously #38063 |
@bcmills yeah, it works now:
and I can see the use of |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
When making use of
test2json
orgo test -json
, and during the course of a test something is printed to stdout (like withfmt.Print
) without a trailing\n
, then the test status is not reported in the json event stream.I believe this behavior stems from here where we do exact byte matching at the start of the each line being handled in
test2json
(matching itself is a little lower inhandleInputLine
: https://github.com/golang/go/blob/master/src/cmd/internal/test2json/test2json.go#L170-L175Repro:
TestPrint
that usesfmt.Print
with no trailing newline and another (TestPrintln
) that usesfmt.Println
to expose the difference in behavior withtest2json
go test .
passes finego test . -json
still exits with a0
status, but thePASS
Action of theTestPrint
test is not emitted.What did you expect to see?
I expect to see an additional line noting that the test action was pass for the
TestPrint
test:I would expect that to show up on line 4 down below, before the
run
event for the next test.What did you see instead?
Note that
TestPrintln
(the second test run) has a line for the event withAction: pass
, but the first test,TestPrint
does not (even though it passed, as seen in the lastAction: output
event for that test on Line 3)The text was updated successfully, but these errors were encountered: