英文:
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"
,所以你的选择有:
- 将
go
临时重命名为go.bak
,然后将go.10.7
重命名为go
(例如使用mv
命令)。 - 提交一个拉取请求,允许通过环境变量来覆盖Go可执行文件的路径(例如,通过环境变量)。
- 继续你现在正在做的事情。
来源: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:
- Temporarily rename
go
togo.bak
and then renamego.10.7
togo
(e.g. usingmv
) - Open up a pull request to allow support for overriding the path to the Go executable (via an environment variable, for example)
- 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("go", args...)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论