Open idexter opened 5 years ago
Same issue raised in #559, I believe it's caused by gls
, and have raised https://github.com/jtolds/gls/issues/14
Worst case (because it breaks back compatibility), we can use context
package and have that in all Convey
calls as suggested by @mjl- in #559
I am seeing the same failure on my projects. Was thinking about moving away from goconvey. Please fix!
Same here. Just upgraded to Go v1.12 and getting this error.
This should already be fixed. Try to update goconvey to latest version.
That was it! We unknowingly had goconvey vendored so it was pointing to an older version.
On Tue, Mar 12, 2019 at 12:46 PM Tony Wang notifications@github.com wrote:
This should already be fixed. Try to update goconvey to latest version.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/smartystreets/goconvey/issues/561#issuecomment-472108791, or mute the thread https://github.com/notifications/unsubscribe-auth/Ai89gU9kzBtXSNAeIBA5UCNgj0g9IQO4ks5vV-fugaJpZM4bWm4G .
~IGNORE~ The issue was fixed, there was one outdated vendor.
same issue
go version
go version go1.12.4 darwin/amd64
fixed by update goconvey
go get github.com/smartystreets/goconvey
Didn't fix me, here is what did:
Pulled master of convey/assertations
attempted a convey build, failed due to https://github.com/smartystreets/goconvey/issues/570
Performed steps in issue (go get -u golang.org/x/tools/...)
Installed properly, still get the error.
Read more issues, find this one: https://github.com/smartystreets/goconvey/issues/559
pulled jtolds/gls to master
go install .
... works
Seems like this could have been solved with vendoring.
This code could NOT work:
func TestFoo(t *testing.T) {
So(1, ShouldEqual, 1)
}
Actually you should do
func TestFoo(t *testing.T) {
Convey("Foo test", t, func() {
So(1, ShouldEqual, 1)
})
}
May help other noobs like me XD
code contains So(...)
in go func like below will trigger this panic
Convey("test", func() {
var a = 0
go func(){
a = 1
So(a, ShouldEqual, 1)
}
}
should change to
Convey("test", func() {
var a = 0
go func(){
a = 1
}
time.Sleep(time.Millisecond * 10)
So(a, ShouldEqual, 1)
}
hope this may help
goconvey can't keep track of the test suites across goroutines automatically; this is not permitted by the way the go language/runtime work.
Take a close read of the documentation for the Convey function: https://godoc.org/github.com/smartystreets/goconvey/convey#Convey
In particular:
Additionally, you may explicitly obtain access to the Convey context by doing:
Convey(description string, action func(c C))
You may need to do this if you want to pass the context through to a goroutine, or to close over the context in a handler to a library which calls your handler in a goroutine (httptest comes to mind).
So, you can do So assertions inside of a goroutine by explicitly using the context object like:
Convey("test", func(c C) {
var a = 0
go func(){
a = 1
c.So(a, ShouldEqual, 1)
}
}
Note the c C
and c.So
. Normally goconvey passes this context implicitly on the stack using gls
. When you launch a goroutine, it gets a completely empty, fresh stack, and this context is lost. By explicitly asking and using the convey context, you can still make So assertions (and Convey suites) inside the goroutine. Note that you only need to do this once per stack, so you can go back to using the implicit context once inside a Convey on the goroutine. Example:
Convey("test", func(c C) {
var a = 0
go func(){
a = 1
c.Convey("inner", func() {
So(a, ShouldEqual, 1)
})
}
}
Hopefully that helps.
same issue
go version go1.13 darwin/amd64
panic: Convey operation made without context on goroutine stack.
Hint: Perhaps you meant to use `Convey(..., func(c C){...})` ? [recovered]
panic: Convey operation made without context on goroutine stack.
Hint: Perhaps you meant to use `Convey(..., func(c C){...})` ? [recovered]
panic: Convey operation made without context on goroutine stack.
Hint: Perhaps you meant to use `Convey(..., func(c C){...})` ?
i tried to update goconvey and assertions in $GOPATH to the latest version, not work.
I installed go 1.13.3 with gvm, installed goconvey on top of empty pkg and src dirs and my tests work.
I'm using golang 1.13.10. After updating the github.com/jtolds/gls, it works for me. seems like they've fixed it https://github.com/jtolio/gls/issues/14
update jtolio/gls will fix this issue
I'am trying to run test of grafana 6.0.0. it works fine when I use go 1.11.5, but panics on go 1.12 It seems related with #476 and https://golang.org/doc/go1.12#compiler https://github.com/smartystreets/goconvey/blob/master/convey/gotest/utils.go#L18