goconvey icon indicating copy to clipboard operation
goconvey copied to clipboard

Panic when running goconvey tests with go 1.9

Open vincentdaniel opened this issue 8 years ago • 16 comments
trafficstars

I get a panic error when I try to use goconvey with go 1.9 on linux. The same code works for version 1.8.3.

I'm using the simple example from the documentation:

package controller

import (
	"testing"

	. "github.com/smartystreets/goconvey/convey"
)

func TestSpec(t *testing.T) {

	// Only pass t into top-level Convey calls
	Convey("Given some integer with a starting value", t, func() {
		x := 1

		Convey("When the integer is incremented", func() {
			x++

			Convey("The value should be greater by one", func() {
				So(x, ShouldEqual, 2)
			})
		})
	})
}

With go 1.9, I get the following error:

> go version
go version go1.9 linux/amd64
> go test -v ./...
[?   	my-app	[no test files]
?   	my-app/node_modules/gulp-go/sample	[no test files]
?   	my-app/server	[no test files]
?   	my-app/server/common	[no test files]]
=== RUN   TestSpec

  Given some integer with a starting value 


0 total assertions

--- FAIL: TestSpec (0.00s)
panic: Top-level calls to Convey(...) need a reference to the *testing.T.
		Hint: Convey("description here", t, func() { /* notice that the second argument was the *testing.T (t)! */ })  [recovered]
	panic: Top-level calls to Convey(...) need a reference to the *testing.T.
		Hint: Convey("description here", t, func() { /* notice that the second argument was the *testing.T (t)! */ })  [recovered]
	panic: Top-level calls to Convey(...) need a reference to the *testing.T.
		Hint: Convey("description here", t, func() { /* notice that the second argument was the *testing.T (t)! */ }) 

goroutine 5 [running]:
testing.tRunner.func1(0xc4200a43c0)
	/usr/local/go/src/testing/testing.go:711 +0x2d2
panic(0x799f20, 0xc420196b40)
	/usr/local/go/src/runtime/panic.go:491 +0x283
github.com/smartystreets/goconvey/convey.(*context).conveyInner.func2(0xc420066f60)
	/home/vdaniel/dev/go/src/github.com/smartystreets/goconvey/convey/context.go:232 +0x1c8
panic(0x799f20, 0xc420196b40)
	/usr/local/go/src/runtime/panic.go:491 +0x283
github.com/smartystreets/goconvey/convey.conveyPanic(0x8246ea, 0xb3, 0x0, 0x0, 0x0)
	/home/vdaniel/dev/go/src/github.com/smartystreets/goconvey/convey/context.go:20 +0xca
github.com/smartystreets/goconvey/convey.rootConvey(0xc420047b30, 0x2, 0x2)
	/home/vdaniel/dev/go/src/github.com/smartystreets/goconvey/convey/context.go:91 +0x416
github.com/smartystreets/goconvey/convey.Convey(0xc420047b30, 0x2, 0x2)
	/home/vdaniel/dev/go/src/github.com/smartystreets/goconvey/convey/doc.go:75 +0x7a
my-app/server/controller.TestSpec.func1()
	/home/vdaniel/dev/go/src/my-app/server/controller/progressController_test.go:15 +0xeb
github.com/smartystreets/goconvey/convey.parseAction.func1(0x9f8600, 0xc420066f60)
	/home/vdaniel/dev/go/src/github.com/smartystreets/goconvey/convey/discovery.go:80 +0x24
github.com/smartystreets/goconvey/convey.(*context).conveyInner(0xc420066f60, 0x81dcbc, 0x28, 0xc4201c61c0)
	/home/vdaniel/dev/go/src/github.com/smartystreets/goconvey/convey/context.go:261 +0x162
github.com/smartystreets/goconvey/convey.rootConvey.func1()
	/home/vdaniel/dev/go/src/github.com/smartystreets/goconvey/convey/context.go:110 +0xec
github.com/jtolds/gls.(*ContextManager).SetValues.func1(0x0)
	/home/vdaniel/dev/go/src/github.com/jtolds/gls/context.go:97 +0x463
github.com/jtolds/gls.EnsureGoroutineId.func1()
	/home/vdaniel/dev/go/src/github.com/jtolds/gls/gid.go:24 +0x31
github.com/jtolds/gls._m(0x0, 0xc4200f7a20)
	/home/vdaniel/dev/go/src/github.com/jtolds/gls/stack_tags.go:74 +0x31
github.com/jtolds/gls.github_com_jtolds_gls_markS(0x0, 0xc4200f7a20)
	/home/vdaniel/dev/go/src/github.com/jtolds/gls/stack_tags.go:54 +0x35
github.com/jtolds/gls.addStackTag(0x0, 0xc4200f7a20)
	/home/vdaniel/dev/go/src/github.com/jtolds/gls/stack_tags.go:49 +0x3a
github.com/jtolds/gls.EnsureGoroutineId(0xc420196ab0)
	/home/vdaniel/dev/go/src/github.com/jtolds/gls/gid.go:24 +0xc9
github.com/jtolds/gls.(*ContextManager).SetValues(0xc4201c6170, 0xc420196a50, 0xc4200f79e0)
	/home/vdaniel/dev/go/src/github.com/jtolds/gls/context.go:63 +0x177
github.com/smartystreets/goconvey/convey.rootConvey(0xc420035f68, 0x3, 0x3)
	/home/vdaniel/dev/go/src/github.com/smartystreets/goconvey/convey/context.go:105 +0x2d6
github.com/smartystreets/goconvey/convey.Convey(0xc420035f68, 0x3, 0x3)
	/home/vdaniel/dev/go/src/github.com/smartystreets/goconvey/convey/doc.go:75 +0x7a
my-app/server/controller.TestSpec(0xc4200a43c0)
	/home/vdaniel/dev/go/src/my-app/server/controller/progressController_test.go:12 +0xa6
testing.tRunner(0xc4200a43c0, 0x828cf0)
	/usr/local/go/src/testing/testing.go:746 +0xd0
created by testing.(*T).Run
	/usr/local/go/src/testing/testing.go:789 +0x2de
FAIL	my-app/server/controller	0.011s
?   	my-app/server/logs	[no test files]
?   	my-app/server/model	[no test files]

With go 1.8.3, it works:

> go version
go version go1.8.3 linux/amd64
> go test -v ./...
?   	my-app	[no test files]
?   	my-app/node_modules/gulp-go/sample	[no test files]
?   	my-app/server	[no test files]
?   	my-app/server/common	[no test files]
=== RUN   TestSpec

  Given some integer with a starting value 
    When the integer is incremented 
      The value should be greater by one ✔


1 total assertion

--- PASS: TestSpec (0.00s)
PASS

...

I'm running it on Ubuntu 16.04.3 LTS (Xenial Xerus).

Feel free to ask any additionnal information you might need to reproduce this issue.

vincentdaniel avatar Sep 14 '17 13:09 vincentdaniel

Same issue, Go 1.9 OSX.

leeola avatar Sep 15 '17 15:09 leeola

I'm having the same issue, Go 1.9 on OS X. I had to do brew install [email protected] and remove other versions to get my tests working again.

dannolan avatar Sep 18 '17 06:09 dannolan

Goconvey relies on https://github.com/jtolds/gls for a go routine local stack to pass its context around. Only the latest version of gls works properly with 1.9. So I guess you might want to update @dannolan, @leeola , @vincentdaniel.

dynamix avatar Sep 20 '17 14:09 dynamix

same here. https://github.com/jtolds/gls at master branch 77f18212c9c7edc9bd6a33d383a7b545ce62f064

image

oliveagle avatar Sep 30 '17 07:09 oliveagle

@oliveagle When dynamix told me to update, I gotbb0351aa7eb6f322f32667d51375f26a2bca6628 and it worked for me without issues.

Not countering your comment, just hoping to help - maybe the above commit will work for you?

leeola avatar Oct 02 '17 16:10 leeola

bb0351aa7eb6f322f32667d51375f26a2bca6628 still crashes...

this is how I crash it.


import (
    "github.com/stretchr/testify/assert"
    "testing"
)

func TestHahah(t *testing.T) {
	a := struct {Name string} {"a"}
	b := struct {Name string} {"b"}
	assert.Equal(t, a, b)
}

oliveagle avatar Oct 09 '17 08:10 oliveagle

I'm having the same issue, Go 1.9 and Linux... Like @oliveagle I use stretchr's assert library

B3rs avatar Oct 09 '17 12:10 B3rs

It works for me after the command below

go get -u github.com/smartystreets/goconvey

go version go1.9 darwin/amd64 / OS X 10.12.6

ahdai0718 avatar Oct 11 '17 06:10 ahdai0718

this solved my issue too thanks @ahdai0718

B3rs avatar Oct 13 '17 10:10 B3rs

Have this issue on windows10 go 1.9 as well

MelleKoning avatar Oct 16 '17 11:10 MelleKoning

If you've updated gls and you're still getting this, delete $GOPATH/pkg/linux_amd64 (or whatever your OS/arch is). I had a vendored version of gls in there in one of my projects.

nkovacs avatar Oct 27 '17 12:10 nkovacs

Just following up as it appears this ticket is still open. This still happens, and with Go 1.10 now as well (which could be assumed as it was introduced with 1.9).

cpjolicoeur avatar Oct 08 '18 15:10 cpjolicoeur

I'm running into the same issue. I tried updating both goconvey and gls but neither helped resolve the issue.

marwan-at-work avatar Jan 10 '19 14:01 marwan-at-work

FYI: I had this issue after updating to go1.12 (out today!); I needed to govendor update github.com/jtolds/gls before it worked again

gedge avatar Feb 26 '19 17:02 gedge

@gedge Hitting the same problem with Golang 1.12 as well. ~Since we're using the new go modules, we can't just update gls (latest 4.20 tag is not semver format so go mod doesn't detect it)~

Edit: I was able to update gls using the branch identifier and it works: go get -u github.com/jtolds/gls@master

sgnn7 avatar Feb 27 '19 22:02 sgnn7

this does it for me using Gopkg.toml (dep)

[[override]]
  name = "github.com/jtolds/gls"
  revision = "b4936e06046bbecbb94cae9c18127ebe510a2cb9"

Dieterbe avatar Apr 02 '19 16:04 Dieterbe