-
-
Notifications
You must be signed in to change notification settings - Fork 677
Description
Hi guys,
Im currently trying to upgrade to v2 on our cloudfoundry app-autoscaler project and have hit a significant blocker.
The issue will probably in more complex projects with loads of dependencies that use ginkgo from multiple versions i.e. a transient dependency (because go does not have a test dependency tree)
I believe there are at least 4 dependencies transitily including the v1 ginkgo
This means in our project we have 1.16.5 and 2.0.0 included.
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/onsi/ginkgo/v2 v2.0.0
This does not work because of the init(){} functions in both included dependencies are run and they use the
flag.CommandLine at init time and modify it creating duplicate flags that causes panics with
/app-autoscaler-release/src/autoscaler/api/brokerserver/brokerserver.test flag redefined: ginkgo.seed
panic: /Users/kevincross/SAPDevelop/cf/app-autoscaler-release/src/autoscaler/api/brokerserver/brokerserver.test flag redefined: ginkgo.seed
goroutine 1 [running]:
flag.(*FlagSet).Var(0xc000218120, 0x1df5fc8, 0x2351f80, 0xc000357640, 0xb, 0x1cd87a3, 0x2a)
/golang/1.16.8/go/src/flag/flag.go:871 +0x637
flag.(*FlagSet).Int64Var(...)
/golang/1.16.8/go/src/flag/flag.go:682
github.com/onsi/ginkgo/v2/types.bindFlagSet(0xc0003cc000, 0x20, 0x21, 0x1bbd540, 0xc0003b86f0, 0x232f420, 0xd, 0xd, 0x0, 0x0, ...)
/go/pkg/mod/github.com/onsi/ginkgo/v2@v2.0.0/types/flags.go:161 +0x15e5
github.com/onsi/ginkgo/v2/types.NewAttachedGinkgoFlagSet(...)
/go/pkg/mod/github.com/onsi/ginkgo/v2@v2.0.0/types/flags.go:113
github.com/onsi/ginkgo/v2/types.BuildTestSuiteFlagSet(0x2351f80, 0x23519a0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/go/pkg/mod/github.com/onsi/ginkgo/v2@v2.0.0/types/config.go:346 +0x6e8
github.com/onsi/ginkgo/v2.init.0()
/github.com/onsi/ginkgo/v2@v2.0.0/core_dsl.go:47 +0x8f
ginkgo run failed
After finding this I updated the v2 module to make a copy of the command line changing v2 to using a copy... this stops the panic
/v2/ginkgo/types/config.go:346
return NewAttachedGinkgoFlagSet(flag.NewFlagSet(os.Args[0], flag.ExitOnError), flags, bindings, FlagSections, extraGoFlagsSection)
but the v1 reports: flag provided but not defined: -ginkgo.randomize-all
somehow 😕
I tried looking a bit further but it all gets a bit wierd with the 2nd layer of compliation 🤷
Ive also tried using the
exclude (
github.com/onsi/ginkgo v1.16.5
)
in the go mod file but too no avail.
to replicate this error try checkout the autoscaler project https://github.com/cloudfoundry/app-autoscaler-release
checkout the branch ginkgo-v2
and run make test
this should replicate this issue easily (after a bunch of docker ect.)