-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Milestone
Description
To reproduce, create the following three files:
testit.go
package testit
extern_test.go:
package testit_test
import (
"code.google.com/p/rog-go/testit"
)
func init() {
testit.Register()
unused
}
intern_test.go:
package testit
import "testing"
var registered bool
func Register() {
registered = true
}
func TestPackage(t *testing.T) {
if !registered {
t.Fatal("registry never called")
}
}
Running the tests gives the error "registry never called",
indicating that the code in extern_test.go is never run.
Moreover, it's not even compiled - there's no error from
the unused variable.
While it may look contrived, the above configuration mirrors the way
that tests are registered with the popular gocheck testing
package - tests that were previously run correctly may now
be silently skipped.
I have verified that this is a regression since Go 1.2.2.
FWIW, there is an easy workaround (define TestPackage in the external
test file) but it might be better to avoid the regression.Reactions are currently unavailable