You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a bug that was originally reported as onsi/ginkgo#305 but can also be reproduced by go test -i.
The reproducible test case is at https://github.com/nikhilm/ginkgo-broken. It features a package main program (in project/) that exports a function that is then tested via tests/project_test.go. While not idiomatic, this is legal go code.
To see the bug:
$ go get github.com/nikhilm/ginkgo-broken
$ cd $GOPATH/src/github.com/nikhilm/ginkgo-broken/tests
# This passes
$ go test -v .
=== RUN TestYo
YOYOYO
--- PASS: TestYo (0.00s)
PASS
ok github.com/nikhilm/ginkgo-broken/tests 0.006s
# This breaks the setup
$ go test -i .
$ go test -v .
# github.com/nikhilm/ginkgo-broken/tests_test
./project_test.go:6: can't find import: "github.com/nikhilm/ginkgo-broken/project"
FAIL github.com/nikhilm/ginkgo-broken/tests [build failed]
# update original
$ touch ../project/main.go
$ go test -v .
=== RUN TestYo
YOYOYO
--- PASS: TestYo (0.00s)
PASS
ok github.com/nikhilm/ginkgo-broken/tests 0.009s
What did you expect to see?
go test -v . should always pass.
What did you see instead?
go test -v . immediately after go test -i . fails.
The text was updated successfully, but these errors were encountered:
quentinmit
changed the title
go test -i breaks go test until package being tested is update.
cmd/go: go test -i corrupts imported "main" package
Oct 17, 2016
This was #4210.
The fix did not catch imports of "main" packages in tests.
We do want to allow importing main from its own test,
but not from other tests.
Similarly, the prohibition on local imports from non-local-imported packages
is meant to apply to tests but was dropped.
rsc
changed the title
cmd/go: reject import of "main" package
cmd/go: apply "main" and "./" import restrictions to test code
Oct 24, 2016
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?1.7.1
What operating system and processor architecture are you using (
go env
)?What did you do?
This is a bug that was originally reported as onsi/ginkgo#305 but can also be reproduced by
go test -i
.The reproducible test case is at https://github.com/nikhilm/ginkgo-broken. It features a
package main
program (inproject/
) that exports a function that is then tested viatests/project_test.go
. While not idiomatic, this is legal go code.To see the bug:
What did you expect to see?
go test -v .
should always pass.What did you see instead?
go test -v .
immediately aftergo test -i .
fails.The text was updated successfully, but these errors were encountered: