Search code examples
goginkgo

Using ginkgo with different go versions


I'm using go with multiple version as stated in this doc https://go.dev/doc/manage-install

go install golang.org/dl/go1.10.7@latest
go1.10.7 download

And I'm also using ginkgo, which I installed like this: (based on https://onsi.github.io/ginkgo/#installing-ginkgo)

go install github.com/onsi/ginkgo/v2/ginkgo@latest

I can run a ginkgo test suite like this:

ginkgo ./...

However, this uses my main go version. I would like to use ginkgo to test with another version of go. Currently, the best I can do is to run the ginkgo tests with go test

go1.10.7 test ./...

Can I make ginkgo use different version of go to test with?


Solution

  • Based on their source code, they just use the command ”go”, so your options are:

    1. Temporarily rename go to go.bak and then rename go.10.7 to go (e.g. using mv)
    2. Open up a pull request to allow support for overriding the path to the Go executable (via an environment variable, for example)
    3. Do what you’re doing now

    Source: https://github.com/onsi/ginkgo/blob/master/ginkgo/internal/compile.go

    Relevant code:

    func CompileSuite(suite TestSuite, goFlagsConfig types.GoFlagsConfig) TestSuite {
    
        ...
    
        cmd := exec.Command("go", args...)