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: go test ./... gives duplicate reports when no source files availabe #31271

Open
davecheney opened this Issue Apr 5, 2019 · 4 comments

Comments

Projects
None yet
5 participants
@davecheney
Copy link
Contributor

commented Apr 5, 2019

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

% go version
go version devel +964fe4b80f Thu Apr 4 00:26:24 2019 +0000 darwin/amd64

Does this issue reproduce with the latest release?

yes

What did you do?

% mkdir ~/devel/test && cd ~/devel/test
% go mod init github.com/davecheney/test
% go test ./...

What did you expect to see?

no packages to test

or

"./..." matched no packages

or

no output

What did you see instead?

% go test ./...
go: warning: "./..." matched no packages
no packages to test

Note the duplicate warning and error message.

@mvdan

This comment has been minimized.

Copy link
Member

commented Apr 5, 2019

@DylanMeeus

This comment has been minimized.

Copy link

commented Apr 5, 2019

With my quick view of the code, I suspect it is because there is a search functions for packages that warns when nothing is found rather than returning an error. The test module itself, however, also returns an error if no packages are found.

Perhaps the "LoadPackages" function needs to return an error instead of just a slice of length 0?

If this needs fixing, I'd like to give it a shot to come up with a solution :). I can take a look in more detail later and make a proposal for a fix.

@ianthehat

This comment has been minimized.

Copy link

commented Apr 5, 2019

It's not really a duplicate though, because you might have specified multiple patterns, in which case the first message is repeated once per pattern that did not match anything, and the latter only happens if none of the patterns matched any tests

% go test a/... b/...
go: warning: "a/..." matched no packages
go: warning: "b/..." matched no packages
no packages to test

and if there were tests but also a broken pattern

% go test ./valid_test a/...
go: warning: "a/..." matched no packages
ok      valid_test    0.024s

@thepudds thepudds changed the title go test ./... gives duplicate reports when no source files availabe cmd/go: go test ./... gives duplicate reports when no source files availabe Apr 8, 2019

@bcmills

This comment has been minimized.

Copy link
Member

commented Apr 9, 2019

@bcmills bcmills added this to the Go1.14 milestone Apr 9, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.