aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing.go
AgeCommit message (Collapse)Author
2016-03-22testing: added name matcher and sanitizerMarcel van Lohuizen
The matcher is responsible for sanitizing and uniquing the test and benchmark names and thus needs to be included before the API can be exposed. Matching currently uses the regexp to only match the top-level tests/benchmarks. Support for subtest matching is for another CL. Change-Id: I7c8464068faef7ebc179b03a7fe3d01122cc4f0b Reviewed-on: https://go-review.googlesource.com/18897 Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: Marcel van Lohuizen <mpvl@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-21testing: add test for not exceeding maximum parallismMarcel van Lohuizen
Fixed bug that slipped probably slipped in after rebasing and explain why it failed on nacl/netbsd/plan9, which set default maxparallelism to 1. Change-Id: I4d59682fb2843d138b320334189f53fcdda5b2f6 Reviewed-on: https://go-review.googlesource.com/20980 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-18testing: finish implementation of subtestsMarcel van Lohuizen
API not exposed yet. Change-Id: Iaba0adc0fa1ae8075e6b56796f99ee8db9177a78 Reviewed-on: https://go-review.googlesource.com/18896 Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-18testing: hoisted chunks of code to prepare for Run methodMarcel van Lohuizen
testing.go: - run method will evolve into the Run method. - added level field in common benchmark.go: - benchContext will be central to distinguish handling of benchmarks between normal Run methods and ones called from within Benchmark function. - expandCPU will evolve into the processing hook for Run methods called within normal processing. - runBench will evolve into the Run method. Change-Id: I1816f9985d5ba94deb0ad062302ea9aee0bb5338 Reviewed-on: https://go-review.googlesource.com/18894 Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-18testing: prepare for the introduction of Run methodsMarcel van Lohuizen
The biggest change is that each test is now responsible for managing the starting and stopping of its parallel subtests. The "Main" test could be run as a tRunner as well. This shows that the introduction of subtests is merely a generalization of and consistent with the current semantics. Change-Id: Ibf8388c08f85d4b2c0df69c069326762ed36a72e Reviewed-on: https://go-review.googlesource.com/18893 Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-02all: single space after period.Brad Fitzpatrick
The tree's pretty inconsistent about single space vs double space after a period in documentation. Make it consistently a single space, per earlier decisions. This means contributors won't be confused by misleading precedence. This CL doesn't use go/doc to parse. It only addresses // comments. It was generated with: $ perl -i -npe 's,^(\s*// .+[a-z]\.) +([A-Z]),$1 $2,' $(git grep -l -E '^\s*//(.+\.) +([A-Z])') $ go test go/doc -update Change-Id: Iccdb99c37c797ef1f804a94b22ba5ee4b500c4f7 Reviewed-on: https://go-review.googlesource.com/20022 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Dave Day <djd@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-28testing: make failure in benchmark cause non-zero exit statusCaio Marcelo de Oliveira Filho
Moves the implementation of RunBenchmarks to a non-exported function that returns whether the execution was OK, and uses that to identify failure in benchmarks.The exported function is kept for compatibility. Like before, benchmarks will only be executed if tests and examples pass. The PASS message will not be printed if there was a failure in a benchmark. Example output BenchmarkThatCallsFatal-8 --- FAIL: BenchmarkThatCallsFatal-8 x_test.go:6: called by benchmark FAIL exit status 1 FAIL _/.../src/cmd/go/testdata/src/benchfatal 0.009s Fixes #14307. Change-Id: I6f3ddadc7da8a250763168cc099ae8b325a79602 Reviewed-on: https://go-review.googlesource.com/19889 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-01-06testing: move comment inside T.ParallelRuss Cox
This was supposed to be in CL 18204 but I submitted from the web instead of my computer and lost this final edit. Change-Id: I41598e936bb088d77f5e44752eda74222a4208c7 Reviewed-on: https://go-review.googlesource.com/18310 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-04testing: add clear panic for duplicate call to t.ParallelRuss Cox
Change-Id: I155633b58e1823344a26c3edf11f5626fae080ee Reviewed-on: https://go-review.googlesource.com/18204 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-18testing: use debug.SetTraceback("all") to show all goroutines at test timeoutRuss Cox
Fixes #13681. Change-Id: I308930f4d9200fbe0f09cd08c38392ca1bb0db67 Reviewed-on: https://go-review.googlesource.com/18044 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2015-12-01testing: document that T and B are safe for concurrent callsRuss Cox
Fixes #13108. Change-Id: I474cc2a3b7ced1c9eb978fc815f9c6bae9fb3ecc Reviewed-on: https://go-review.googlesource.com/17235 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-24testing: pause the test timer while waiting in T.ParallelCaleb Spare
Before, we reset the timer at the end of T.Parallel, which is okay assuming that T.Parallel is the first thing in the test. Snapshot the elapsed time at the beginning of Parallel and include it in the total duration so that any time spent in the test before calling Parallel is reported in the test duration as well. Updates #12243. Change-Id: Ieca553e1f801e16b9b6416463fa8f7fa65425185 Reviewed-on: https://go-review.googlesource.com/16989 Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-12testing: only call flag.Parse if it has not been called beforeAlberto Bertogli
Calling flag.Parse twice can be problematic if other goroutines called flag.Parsed in between: the race detector complains due to the write after read from a different goroutine. This can happen if TestMain calls flag.Parse and launches goroutines that call flag.Parsed, for example if it initializes a server which checks flags. This patch makes testing.M.Run only parse the flags if they have not been parsed already. Change-Id: Id9f8c31c5f90614e3f34c63d1a32cf7e9055d68e Reviewed-on: https://go-review.googlesource.com/16739 Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-22runtime/trace: add new packageDmitry Vyukov
Move tracing functions from runtime/pprof to the new runtime/trace package. Fixes #9710 Change-Id: I718bcb2ae3e5959d9f72cab5e6708289e5c8ebd5 Reviewed-on: https://go-review.googlesource.com/12511 Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-11all: link to https instead of httpBrad Fitzpatrick
The one in misc/makerelease/makerelease.go is particularly bad and probably warrants rotating our keys. I didn't update old weekly notes, and reverted some changes involving test code for now, since we're late in the Go 1.5 freeze. Otherwise, the rest are all auto-generated changes, and all manually reviewed. Change-Id: Ia2753576ab5d64826a167d259f48a2f50508792d Reviewed-on: https://go-review.googlesource.com/12048 Reviewed-by: Rob Pike <r@golang.org>
2015-06-15testing: don't print CPU count for tests, only benchmarksRob Pike
The number of CPUs is of value when benchmarking but mostly noise when testing. The recent change to default to the number of CPUs available has made the tests noisier and confusing. Fixes #11200 Change-Id: Ifc87d9ccb4177d73e304fb7ffcef4367bd163c9e Reviewed-on: https://go-review.googlesource.com/11121 Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-05testing: add -test.count flag to run tests and benchmarks multiple timesRuss Cox
The flag is available from the go test command as -count: % go test -run XXX -bench . -count 3 PASS BenchmarkSprintfEmpty 30000000 54.0 ns/op BenchmarkSprintfEmpty 30000000 51.9 ns/op BenchmarkSprintfEmpty 30000000 53.8 ns/op BenchmarkSprintfString 10000000 238 ns/op BenchmarkSprintfString 10000000 239 ns/op BenchmarkSprintfString 10000000 234 ns/op BenchmarkSprintfInt 10000000 232 ns/op BenchmarkSprintfInt 10000000 226 ns/op BenchmarkSprintfInt 10000000 225 ns/op ... If -cpu is set, each test is run n times for each cpu value. Original by r (CL 10663). Change-Id: If3dfbdf21698952daac9249b5dbca66f5301e91b Reviewed-on: https://go-review.googlesource.com/10669 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-05-12testing: fix typoShenghou Ma
Fixes #10794. Change-Id: Id91485394ddbadc28c800e1d0c3ec281ba6cd098 Reviewed-on: https://go-review.googlesource.com/9990 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-05-08testing: make the output of -v more uniform and aligned when using ↵Rob Pike
fixed-width fonts Delete the colon from RUN: for examples, since it's not there for tests. Add spaces to line up RUN and PASS: lines. Before: === RUN TestCount --- PASS: TestCount (0.00s) === RUN: ExampleFields --- PASS: ExampleFields (0.00s) After: === RUN TestCount --- PASS: TestCount (0.00s) === RUN ExampleFields --- PASS: ExampleFields (0.00s) Fixes #10594. Change-Id: I189c80a5d99101ee72d8c9c3a4639c07e640cbd8 Reviewed-on: https://go-review.googlesource.com/9846 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-05-06testing: document that Log and Logf always print in benchmarksRob Pike
Fixes #10713. Change-Id: Ifdafc340ae3bba751236f0482246c568346a569c Reviewed-on: https://go-review.googlesource.com/9763 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-03-20testing: document that flag.Parse is not called when TestMain runsShenghou Ma
Fixes #9825. Change-Id: Id7eeaa14c26201db34db0820371c92a63af485b0 Reviewed-on: https://go-review.googlesource.com/7604 Reviewed-by: Rob Pike <r@golang.org>
2015-01-28testing: add tracing supportDmitry Vyukov
testing part of tracing functionality: https://docs.google.com/document/u/1/d/1FP5apqzBgr7ahCCgFO-yoVhk4YZrNIDNf9RybngBc14/pub Full change: https://codereview.appspot.com/146920043 Change-Id: Ia3c2c4417106937d5775b0e7064db92c1fc36679 Reviewed-on: https://go-review.googlesource.com/1461 Reviewed-by: Russ Cox <rsc@golang.org>
2014-10-16runtime: fix memory profilerDmitriy Vyukov
There are 3 issues: 1. Skip argument of callers is off by 3, so that all allocations are deep inside of memory profiler. 2. Memory profiling statistics are not updated after runtime.GC. 3. Testing package does not update memory profiling statistics before capturing the profile. Also add an end-to-end test. Fixes #8867. LGTM=rsc R=rsc CC=golang-codereviews https://golang.org/cl/148710043
2014-10-01testing: clearer commentRobert Griesemer
Fixes #8797. LGTM=r R=r CC=golang-codereviews https://golang.org/cl/146680043
2014-09-19cmd/go, testing: add TestMain supportRuss Cox
Fixes #8202. LGTM=r, bradfitz R=r, josharian, bradfitz CC=golang-codereviews https://golang.org/cl/148770043
2014-09-08build: move package sources from src/pkg to srcRuss Cox
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.