使用不同的Go版本与ginkgo一起使用

huangapple go评论91阅读模式
英文:

Using ginkgo with different go versions

问题

我正在使用多个版本的Go,如此文档所述:https://go.dev/doc/manage-install

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

我还使用了ginkgo,我是这样安装的:(基于https://onsi.github.io/ginkgo/#installing-ginkgo)

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

我可以这样运行ginkgo测试套件:

ginkgo ./...

然而,这使用的是我的主要Go版本。我想要使用ginkgo来测试另一个版本的Go。目前,我能做的最好的办法是使用go test运行ginkgo测试:

go1.10.7 test ./...

我能让ginkgo使用不同版本的Go进行测试吗?

英文:

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?

答案1

得分: 1

根据他们的源代码,他们只使用命令"go",所以你的选择有:

  1. go临时重命名为go.bak,然后将go.10.7重命名为go(例如使用mv命令)。
  2. 提交一个拉取请求,允许通过环境变量来覆盖Go可执行文件的路径(例如,通过环境变量)。
  3. 继续你现在正在做的事情。

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

相关代码:

func CompileSuite(suite TestSuite, goFlagsConfig types.GoFlagsConfig) TestSuite {

    ...

	cmd := exec.Command("go", args...)
英文:

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

<hr>

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(&quot;go&quot;, args...)

huangapple
  • 本文由 发表于 2022年12月11日 01:39:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/74755199.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定