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 · 5 comments
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@davecheney
Copy link
Contributor

davecheney 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
Copy link
Member

mvdan commented Apr 5, 2019

/cc @bcmills @jayconrod

@DylanMeeus
Copy link

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
Copy link

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
Copy link
Contributor

bcmills commented Apr 9, 2019

CC @jayconrod

@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 9, 2019
@bcmills bcmills added this to the Go1.14 milestone Apr 9, 2019
@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
@dmitshur dmitshur added the GoCommand cmd/go label Jun 6, 2023
@gopherbot
Copy link

Change https://go.dev/cl/505635 mentions this issue: cmd/go: modify go {test,vet} to scale down to 0 packages gracefully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

8 participants