如何在“Go测试”上设置超时超时标志 [英] How to set the go timeout flag on "Go test"
问题描述
go test -timeout 99999
抛出这种无意义错误
标志-test.timeout的无效值99999:
时间:持续时间内缺少单位99999
这是一个错误吗?
我使用
go版本go1.3
helpcli也没用。它表示 -test.timeout = 0:如果为正数,则为所有测试设置一个总计时间限制
。但是,如果你去测试-test.timeout 99999你会得到同样的错误
-test.timeout = 0:为所有测试设置一个合计时间限制
time.ParseDuration
输入。例如,
$ go test -timeout 300ms
$ go test -timeout 99999s
- 超时t
$ c $如果一个测试的运行时间超过t
,panic code>。
。
持续时间标记接受任何有效的<
time.ParseDuration
func ParseDuration(s string)(持续时间,错误)
ParseDuration分析持续时间字符串。持续时间字符串是
可能带符号的十进制数字序列,每一个都带有可选的
分数和一个单位后缀,例如300ms
,-1.5h
或2h45m
。有效的
时间单位是ns
,us
(或μs
),ms
,s
,m
,h
。
go test -timeout 99999
throws this non sense error
invalid value "99999" for flag -test.timeout:
time: missing unit in duration 99999
Is it a bug ? I'm using go version go1.3
The "help" cli is useless too. It says -test.timeout=0: if positive, sets an aggregate time limit for all tests
. However if you do go test -test.timeout 99999 you get the same error
-test.timeout=0: if positive, sets an aggregate time limit for all tests
Use a valid time.ParseDuration
input. For example,
$ go test -timeout 300ms
$ go test -timeout 99999s
-timeout t
If a test runs longer than
t
,panic
.Duration flags accept any input valid for
time.ParseDuration
.func ParseDuration(s string) (Duration, error)
ParseDuration parses a duration string. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "
300ms
", "-1.5h
" or "2h45m
". Valid time units are "ns
", "us
" (or "µs
"), "ms
", "s
", "m
", "h
".
这篇关于如何在“Go测试”上设置超时超时标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!