Skip to content

cmd/go/internal/test: compile error for go test on package with no test files does not output package-level "FAIL" error #64286

@joyzheng

Description

@joyzheng

What version of Go are you using (go version)?

$ go version
go version go1.20.6 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/jzheng/Library/Caches/go-build"
GOENV="/Users/jzheng/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/jzheng/Plaid/go/pkg/mod"
GONOPROXY="github.plaid.com"
GONOSUMDB="github.plaid.com"
GOOS="darwin"
GOPATH="/Users/jzheng/Plaid/go"
GOPRIVATE="github.plaid.com"
GOPROXY="https://proxy.golang.org"
GOROOT="/usr/local/Cellar/go/1.20.6/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.20.6/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.20.6"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="cc"
CXX="c++"
CGO_ENABLED="0"
GOMOD="/Users/jzheng/Plaid/go/src/github.plaid.com/plaid/go.git/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/mw/swflvd316dl67xycd2lmfzhcll7jtg/T/go-build3323119429=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Run go test ./pkg ./pkg2 on the following directory:

go.mod
pkg/main.go
pkg2/main.go

go.mod:

module foo

go 1.21.4

pkg/main.go:

package pkg

import "fmt"

func main() {
	fmt.Println("Hello, world")
}

package pkg2/main.go (does not compile)

package pkg2

import "fmt"

func main() {
	fmt.Println("Hello, world")
	foo
}

What did you expect to see?

# foo/pkg2 [foo/pkg2.test]
pkg2/main.go:7:2: undefined: foo
?   	foo/pkg	[no test files]
FAIL	foo/pkg2 [build failed]
FAIL

The above is the output that shows up if I add a pkg2/main_test.go file with a line `package pkg2 line in the file.

What did you see instead?

go test ./pkg ./pkg2
# foo/pkg2
pkg2/main.go:7:2: undefined: foo
?   	foo/pkg	[no test files]
FAIL

The FAIL foo/pkg2 [build failed] line is missing. This is true in both regular and -json output formats, which makes it harder to parse the results of CI runs on many packages to see which packages resulted in failures.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoCommandcmd/goNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions