]> Cypherpunks repositories - gostls13.git/commitdiff
testing: use flag.Duration for -timeout flag.
authorDavid Symonds <dsymonds@golang.org>
Sun, 25 Dec 2011 05:07:05 +0000 (16:07 +1100)
committerDavid Symonds <dsymonds@golang.org>
Sun, 25 Dec 2011 05:07:05 +0000 (16:07 +1100)
R=golang-dev, gustavo, r
CC=golang-dev
https://golang.org/cl/5498077

src/Make.pkg
src/cmd/go/test.go
src/cmd/gotest/doc.go
src/pkg/testing/testing.go

index 91562af92ab8cd4b2a18d9bb64ab87a549183aef..3a7ffd812b5aa1ab9d67d074124017191eed9f6f 100644 (file)
@@ -65,7 +65,7 @@ test:
        gotest
 
 testshort:
-       gotest -test.short -test.timeout=120
+       gotest -test.short -test.timeout=2m
 
 bench:
        gotest -test.bench=. -test.run="Do not run tests"
index 4904703ec3f8f82676050cf75fb2ab7494e3675b..1807e42f723263346f1c7d3699624ca885e60054 100644 (file)
@@ -118,8 +118,8 @@ The resulting test binary, called test.out, has its own flags:
            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.
index bb01b54ed3f80b3360814d21ec2a3a390933b59d..8d729f0253066d39d8b382906018deca6cb24a20 100644 (file)
@@ -75,7 +75,7 @@ Usage:
                [-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
@@ -117,7 +117,7 @@ time.  It is off by default but set by all.bash so installations of
 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.
 
index 16890e0b3fa2dc37fed36af4a2d411c5c7e572f7..a61ac0ea0b2ba28595d11de800e51b5f6b37ca76 100644 (file)
@@ -63,7 +63,7 @@ var (
        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")
 
@@ -346,7 +346,7 @@ var timer *time.Timer
 // 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)
        }
 }