go test的两个标志-parallel和-test.parallel之间的区别以及哪个标志优先?
-parallel n
Allow parallel execution of test functions that call t.Parallel.
The value of this flag is the maximum number of tests to run
simultaneously; by default, it is set to the value of GOMAXPROCS.
Note that -parallel only applies within a single test binary.
The 'go test' command may run tests for different packages
in parallel as well, according to the setting of the -p flag
(see 'go help build').上面的文档说,如果没有提供任何东西,并行运行的测试数量等于GOMAXPROCS,但我的行为与此不同。因为我在一台只有4个内核的机器上运行测试。但对我来说,8个测试是并行运行的,所以行为更像是这样:
-test.parallel int
maximum test parallelism (default 8)那么这两者之间的区别是什么呢?何时使用哪个标志。
更多信息
我在一个有9个测试的包上运行所有的测试,所有的测试都是并行运行的,所有这些都存在于单个测试函数中。
发布于 2017-08-31 14:45:59
-test.标志由go test命令生成。go test命令动态生成pkg.test二进制文件,并使用修改后的参数运行它。传递给go test的所有可识别的参数都将被转换。因此,在您的示例中:-parallel n变成了-test.parallel n。
所以这个命令:
go test -parallel 6创建:
pkg.test -test.parallel 6https://stackoverflow.com/questions/45974414
复制相似问题