【发布时间】:2021-07-12 09:05:44
【问题描述】:
在运行中,我可以使用 -race 选项为测试启用竞争检测器,例如
go test -race ./foo/bar
如何在 bazel 中做到这一点?
【问题讨论】:
在运行中,我可以使用 -race 选项为测试启用竞争检测器,例如
go test -race ./foo/bar
如何在 bazel 中做到这一点?
【问题讨论】:
使用--@io_bazel_rules_go//go/config:race (docs) 作为标志进行 bazel 测试。
--features=race 不再受支持,测试将警告不支持。
bazel test --@io_bazel_rules_go//go/config:race //src/foo/bar
【讨论】:
go_test 以便自动包含在其中吗?编辑:nvm 只需将race = "on" 添加到规则中
从 https://github.com/bazelbuild/rules_go/pull/635 开始,您可以使用选项 --features race 运行 bazel 测试,以提供 -race 标志来进行测试。例如
bazel test --features race //src/foo/bar
【讨论】: