Skip to content
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

cmd/go: FAIL line printed by "go test" corrupted when test output does not end in a newline #49317

Closed
bcmills opened this issue Nov 3, 2021 · 1 comment
Labels
FrozenDueToAge GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@bcmills
Copy link
Member

bcmills commented Nov 3, 2021

When the test for a package fails, go test prints the test's output followed by a FAIL line for the package.

Unfortunately, it does not check whether the test's output ends with a newline; when it doesn't, go test doesn't add one, so tools that (reasonably) look for output lines matching ^FAIL\s+ don't find those failures.

$ gotip version
go version devel go1.18-5b213178e Wed Nov 3 09:08:46 2021 +0000 linux/amd64

$ gotip test .
exitcode=1FAIL  example 0.011s
FAIL

-- go.mod --
module example

go 1.18
-- no_newline_test.go --
package test

import (
	"os"
	"testing"
)

func TestMain(m *testing.M) {
	os.Stderr.WriteString("exitcode=1")
	os.Exit(1)
}
@bcmills bcmills added GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done. labels Nov 3, 2021
@bcmills bcmills self-assigned this Nov 3, 2021
@bcmills bcmills added this to the Go1.18 milestone Nov 3, 2021
@gopherbot
Copy link

Change https://golang.org/cl/361095 mentions this issue: cmd/go: ensure that 'go test' prints the FAIL line for a package on a new line

bcmills added a commit to bcmills/go-misc that referenced this issue Nov 3, 2021
This works around a common failure mode of golang/go#49317,
allowing proper extraction of failures from Android builder logs.
aclements pushed a commit to aclements/go-misc that referenced this issue Nov 3, 2021
This works around a common failure mode of golang/go#49317,
allowing proper extraction of failures from Android builder logs.
@rsc rsc unassigned bcmills Jun 23, 2022
@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

2 participants