It's a little weird right now that go test in a directory of non-context-matching *.go files (like golang.org/x/sys/windows/registry on Linux) results in an error, but go test in a directory without tests is fine (exit 0), and go test ./... is also fine, as long as one directory somewhere has a context-matching file.
dev:~ $ mkdir /tmp/foo
dev:~ $ cd /tmp/foo
dev:foo $ go mod init foo
go: creating new go.mod: module foo
dev:foo $ go test
no Go files in /tmp/foo
dev:foo $ echo $?
1
dev:foo $ cat > x_windows.go
package main
dev:foo $ go test
package foo: build constraints exclude all Go files in /tmp/foo
dev:foo $ echo $?
1
dev:foo $ cat > x.go
package main
dev:foo $ go test
? foo [no test files]
dev:foo $ echo $?
0
dev:foo $ go test ./...
go: warning: "./..." matched no packages
no packages to test
dev:foo $ mkdir bar
dev:foo $ cat > bar/bar.go
package bar
dev:foo $ go test ./...
? foo/bar [no test files]
dev:foo $ echo $?
0
dev:foo $ go test golang.org/x/sys/windows/registry
go: finding module for package golang.org/x/sys/windows/registry
go: downloading golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980
go: found golang.org/x/sys/windows/registry in golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980
package golang.org/x/sys/windows/registry: build constraints exclude all Go files in /home/bradfitz/pkg/mod/golang.org/x/sys@v0.0.0-20200602225109-6fdc65e7d980/windows/registry
Can we instead make go test act more like the package has no tests? I'd like to see:
$ go test golang.org/x/sys/windows/registry
? golang.org/x/sys/windows/registry [no matching files]
$ echo $?
0
This arose due to integration of Go in another build system (that builds non-Go stuff) and that build system was using the heuristic that if a directory contains *_test.go files, it running go test in that directory was reasonable. That's currently not true for directories like x/sys/windows/registry or other such OS-specific packages.
The text was updated successfully, but these errors were encountered:
It's a little weird right now that
go test
in a directory of non-context-matching*.go
files (likegolang.org/x/sys/windows/registry
on Linux) results in an error, butgo test
in a directory without tests is fine (exit 0), andgo test ./...
is also fine, as long as one directory somewhere has a context-matching file.Can we instead make go test act more like the package has no tests? I'd like to see:
This arose due to integration of Go in another build system (that builds non-Go stuff) and that build system was using the heuristic that if a directory contains
*_test.go
files, it runninggo test
in that directory was reasonable. That's currently not true for directories likex/sys/windows/registry
or other such OS-specific packages.The text was updated successfully, but these errors were encountered: