gotest
testshort:
- gotest -test.short -test.timeout=120
+ gotest -test.short -test.timeout=2m
bench:
gotest -test.bench=. -test.run="Do not run tests"
the Go tree can run a sanity check but not spend time running
exhaustive tests.
- -test.timeout n
- If a test runs longer than n seconds, panic.
+ -test.timeout t
+ If a test runs longer than t, panic.
-test.benchtime n
Run enough iterations of each benchmark to take n seconds.
[-test.cpuprofile=cpu.out] \
[-test.memprofile=mem.out] [-test.memprofilerate=1] \
[-test.parallel=$GOMAXPROCS] \
- [-test.timeout=10] [-test.short] \
+ [-test.timeout=10s] [-test.short] \
[-test.benchtime=3] [-test.cpu=1,2,3,4]
The -test.v flag causes the tests to be logged as they run. The
the Go tree can do a sanity check but not spend time running
exhaustive tests.
-The -test.timeout flag sets a timeout for the test in seconds. If the
+The -test.timeout flag sets a timeout for the test. If the
test runs for longer than that, it will panic, dumping a stack trace
of all existing goroutines.
memProfile = flag.String("test.memprofile", "", "write a memory profile to the named file after execution")
memProfileRate = flag.Int("test.memprofilerate", 0, "if >=0, sets runtime.MemProfileRate")
cpuProfile = flag.String("test.cpuprofile", "", "write a cpu profile to the named file during execution")
- timeout = flag.Int64("test.timeout", 0, "if > 0, sets time limit for tests in seconds")
+ timeout = flag.Duration("test.timeout", 0, "if positive, sets an aggregate time limit for all tests")
cpuListStr = flag.String("test.cpu", "", "comma-separated list of number of CPUs to use for each test")
parallel = flag.Int("test.parallel", runtime.GOMAXPROCS(0), "maximum test parallelism")
// startAlarm starts an alarm if requested.
func startAlarm() {
if *timeout > 0 {
- timer = time.AfterFunc(time.Duration(*timeout)*time.Second, alarm)
+ timer = time.AfterFunc(*timeout, alarm)
}
}