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: test coverpkg=all ./... with test only packages will fail to build #27333

Open
AlexRouSg opened this Issue Aug 29, 2018 · 3 comments

Comments

Projects
None yet
5 participants
@AlexRouSg
Copy link
Contributor

AlexRouSg commented Aug 29, 2018

Please answer these questions before submitting your issue. Thanks!

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

1.11

Does this issue reproduce with the latest release?

Yes

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

linux amd64

What did you do?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

Ran go test -coverpkg=all ./... with the following folder structure:

├── foo.go
├── foo_test.go
└── tests
    └── tests_test.go

Content of files is irrelevant.
Apparently go test -cover ./... works, so it's specific to -coverpkg
Also deleting foo_test.go works

What did you expect to see?

ok      _/<HOME>/go/src/foo   0.001s  coverage: 0.0% of statements [no tests to run]
ok      _/<HOME>/go/src/foo/tests     0.004s  coverage: 0.0% of statements [no tests to run]

What did you see instead?

go build _/<HOME>/go/src/foo/tests: no non-test Go files in go/src/foo/tests
FAIL    _/<HOME>/go/src/foo [build failed]
ok      _/<HOME>/go/src/foo/tests     0.001s  coverage: 0.0% of statements in all [no tests to run]

@FiloSottile FiloSottile added this to the Go1.12 milestone Aug 30, 2018

@FiloSottile

This comment has been minimized.

Copy link
Member

FiloSottile commented Aug 30, 2018

@bcmills bcmills modified the milestones: Go1.12, Go1.13 Nov 15, 2018

@vvakame

This comment has been minimized.

Copy link

vvakame commented Feb 27, 2019

I met this issue in real world.
This issue is very painful...
because, unrelated packages will be build failed without an error message...
I found go build go.mercari.io/datastore/testbed: no non-test Go files in /go/src/go.mercari.io/datastore/testbed message, but I can't found relation between this message to build faled. and I see it occasionally, but I never had a problem until now.

https://github.com/mercari/datastore/tree/v1.4.0/testbed
https://circleci.com/gh/mercari/datastore/219

$ go test go.mercari.io/datastore go.mercari.io/datastore/aedatastore go.mercari.io/datastore/aeprodtest go.mercari.io/datastore/boom go.mercari.io/datastore/clouddatastore go.mercari.io/datastore/dsmiddleware go.mercari.io/datastore/dsmiddleware/aememcache go.mercari.io/datastore/dsmiddleware/chaosrpc go.mercari.io/datastore/dsmiddleware/dslog go.mercari.io/datastore/dsmiddleware/fishbone go.mercari.io/datastore/dsmiddleware/localcache go.mercari.io/datastore/dsmiddleware/noop go.mercari.io/datastore/dsmiddleware/rediscache go.mercari.io/datastore/dsmiddleware/rpcretry go.mercari.io/datastore/dsmiddleware/storagecache go.mercari.io/datastore/internal go.mercari.io/datastore/internal/shared go.mercari.io/datastore/internal/testutils go.mercari.io/datastore/testbed go.mercari.io/datastore/testsuite go.mercari.io/datastore/testsuite/dsmiddleware/dslog go.mercari.io/datastore/testsuite/dsmiddleware/fishbone go.mercari.io/datastore/testsuite/dsmiddleware/localcache go.mercari.io/datastore/testsuite/dsmiddleware/rpcretry go.mercari.io/datastore/testsuite/favcliptools go.mercari.io/datastore/testsuite/realworld/recursivebatch go.mercari.io/datastore/testsuite/realworld/tbf -count 1 -p 1 -coverpkg=go.mercari.io/datastore/... -covermode=atomic -coverprofile=coverage.txt
go build go.mercari.io/datastore/testbed: no non-test Go files in /go/src/go.mercari.io/datastore/testbed
FAIL	go.mercari.io/datastore [build failed]
FAIL	go.mercari.io/datastore/aedatastore [build failed]
?   	go.mercari.io/datastore/aeprodtest	[no test files]
FAIL	go.mercari.io/datastore/boom [build failed]
FAIL	go.mercari.io/datastore/clouddatastore [build failed]
?   	go.mercari.io/datastore/dsmiddleware	[no test files]
FAIL	go.mercari.io/datastore/dsmiddleware/aememcache [build failed]
FAIL	go.mercari.io/datastore/dsmiddleware/chaosrpc [build failed]
FAIL	go.mercari.io/datastore/dsmiddleware/dslog [build failed]
FAIL	go.mercari.io/datastore/dsmiddleware/fishbone [build failed]
FAIL	go.mercari.io/datastore/dsmiddleware/localcache [build failed]
?   	go.mercari.io/datastore/dsmiddleware/noop	[no test files]
FAIL	go.mercari.io/datastore/dsmiddleware/rediscache [build failed]
FAIL	go.mercari.io/datastore/dsmiddleware/rpcretry [build failed]
FAIL	go.mercari.io/datastore/dsmiddleware/storagecache [build failed]
?   	go.mercari.io/datastore/internal	[no test files]
?   	go.mercari.io/datastore/internal/shared	[no test files]
?   	go.mercari.io/datastore/internal/testutils	[no test files]
ok  	go.mercari.io/datastore/testbed	6.887s	coverage: 0.7% of statements in go.mercari.io/datastore/...
?   	go.mercari.io/datastore/testsuite	[no test files]
?   	go.mercari.io/datastore/testsuite/dsmiddleware/dslog	[no test files]
?   	go.mercari.io/datastore/testsuite/dsmiddleware/fishbone	[no test files]
?   	go.mercari.io/datastore/testsuite/dsmiddleware/localcache	[no test files]
?   	go.mercari.io/datastore/testsuite/dsmiddleware/rpcretry	[no test files]
?   	go.mercari.io/datastore/testsuite/favcliptools	[no test files]
?   	go.mercari.io/datastore/testsuite/realworld/recursivebatch	[no test files]
?   	go.mercari.io/datastore/testsuite/realworld/tbf	[no test files]
@gopherbot

This comment has been minimized.

Copy link

gopherbot commented Feb 28, 2019

Change https://golang.org/cl/164198 mentions this issue: cmd/go: ignore test only packages with -coverpkg

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.