aboutsummaryrefslogtreecommitdiff
path: root/src/testing
AgeCommit message (Collapse)Author
2023-01-09all: fix typos in go file commentsMarcel Meyer
These typos were found by executing grep, aspell, sort, and uniq in a pipe and searching the resulting list manually for possible typos. grep -r --include '*.go' -E '^// .*$' . | aspell list | sort | uniq Change-Id: I56281eda3b178968fbf104de1f71316c1feac64f GitHub-Last-Rev: e91c7cee340fadfa32b0c1773e4e5cd1ca567638 GitHub-Pull-Request: golang/go#57669 Reviewed-on: https://go-review.googlesource.com/c/go/+/460767 Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-12-23testing: rephrase the sentence about naming test filesAndrey Bozhko
This updates the explanation about naming test files to be a little more clear. Fixes #57389 Change-Id: I9b3a8e2dae5e3ad398b55624e183809b7d90864c GitHub-Last-Rev: 9ff81b74b201ca032fd373424aa02a3fedaec008 GitHub-Pull-Request: golang/go#57399 Reviewed-on: https://go-review.googlesource.com/c/go/+/458435 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Fahad King <fahadking750@gmail.com> Reviewed-by: Rob Pike <r@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com>
2022-11-16testing: in TestRacyOutput, ensure that the Run calls complete before cleanupBryan C. Mills
Also tweak the failure message added in CL 352349. Updates #18741. Updates #48515. Change-Id: I46ed84c6f498d7a68414cc3dab3c1cd55da69aa9 Reviewed-on: https://go-review.googlesource.com/c/go/+/451215 Reviewed-by: Austin Clements <austin@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Changkun Ou <mail@changkun.de> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-11-16testing: reject calls to Run within Cleanup callbacksChangkun Ou
Calling t.Run inside t.Cleanup can mess up the execution order of registered Cleanup callbacks. Reject calls to Run within Cleanup callbacks. Fixes #48515 Change-Id: I61e4cb35253db1a8bbe3351d59055433030aa289 Reviewed-on: https://go-review.googlesource.com/c/go/+/352349 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Joedian Reid <joedian@golang.org> Run-TryBot: Changkun Ou <mail@changkun.de> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
2022-11-14testing: fix error message when a parallel Cleanup calls runtime.GoexitChangkun Ou
Fixes #48502 Change-Id: I6054b043ebd2237e19897fdf1234b311d19facc7 Reviewed-on: https://go-review.googlesource.com/c/go/+/352350 Reviewed-by: Joedian Reid <joedian@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Changkun Ou <mail@changkun.de> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com>
2022-11-07testing: Document RunParallel ns/op behaviorFelix Geisendörfer
Updates #31884 Change-Id: Ibad3d31038a8426c0bce61c1726392880f934865 Reviewed-on: https://go-review.googlesource.com/c/go/+/447136 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Benny Siegert <bsiegert@gmail.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-11-03testing: add Get method for -test.v optionIan Lance Taylor
There is existing code that calls flag.Lookup("test.v") and inspects the value. That stopped working as of CL 443596. Make code like that continue to work at least for the case where we aren't using -test.v=test2json. Change-Id: Idb30b149b48ee3987a201e349cf4d9bfe9ddee56 Reviewed-on: https://go-review.googlesource.com/c/go/+/447796 Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
2022-11-02testing: implement -cpu and -count for fuzz testsRuss Cox
Fuzz tests are meant to be run just like ordinary tests, so copy the same loop cpu and count loops used in testing.go (and benchmark.go) into fuzz.go. Change-Id: Ic585df8ccc577869c877b1055e0493803dbeb828 Reviewed-on: https://go-review.googlesource.com/c/go/+/443377 Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org>
2022-11-01testing: print names of running tests on test timeoutRuss Cox
Track the running tests and when they started, so that we can report the running tests on a test timeout. % go test -timeout=5s panic: test timed out after 5s running tests: TestTCPSpuriousConnSetupCompletion (4s) ... stack traces as usual ... % go test -run=Script -timeout=10s cmd/go vcs-test.golang.org rerouted to http://127.0.0.1:65168 https://vcs-test.golang.org rerouted to https://127.0.0.1:65169 go test proxy running at GOPROXY=http://127.0.0.1:65170/mod panic: test timed out after 10s running tests: TestScript (10s) TestScript/mod_get_patchcycle (0s) TestScript/mod_get_prefer_incompatible (0s) TestScript/mod_get_promote_implicit (0s) TestScript/mod_get_pseudo (0s) TestScript/mod_get_pseudo_other_branch (0s) TestScript/mod_get_pseudo_prefix (0s) TestScript/mod_get_test (0s) TestScript/mod_get_trailing_slash (0s) TestScript/mod_get_update_unrelated_sum (0s) TestScript/mod_gobuild_import (0s) TestScript/mod_gomodcache (0s) TestScript/mod_gonoproxy (0s) TestScript/mod_load_badchain (0s) TestScript/mod_overlay (0s) TestScript/test_fuzz_minimize (6s) TestScript/test_fuzz_minimize_dirty_cov (7s) ... stack traces as usual ... Change-Id: I3a6647c029097becc06664ebd76a2597c7ed7b8e Reviewed-on: https://go-review.googlesource.com/c/go/+/446176 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Russ Cox <rsc@golang.org>
2022-10-28testing: change Error to Errorf in commentIan Lance Taylor
Fixes #56479 Change-Id: I1d97eb3ea97304e429e178ad05cb9f861b2bce84 Reviewed-on: https://go-review.googlesource.com/c/go/+/446275 Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-10-26testing: fix many test2json inaccuraciesRuss Cox
Test2json is parsing the output stream from the test, which includes package testing's own framing lines intermingled with other output, in particular any output printed via fmt.Printf, println, and so on. We have had recurring problems with unexpected partial output lines causing a framing line to be missed. A recent talk at GopherCon gave an example of an integration test involving Docker that happened to print \r-terminated lines instead of \n-terminated lines in some configurations, which in turn broke test2json badly. (https://www.gophercon.com/agenda/session/944259) There are also a variety of open reported issues with similar problems, which this CL also addresses. The general approach is to add a new testing flag -test.v=json that means to print additional output to help test2json. And then test2json takes advantage of that output. Among the fixes: - Identify testing framing more reliably, using ^V (#23036, #26325, #43683, GopherCon talk) - Test that output with \r\n endings is handled correctly (#43683, #34286) - Use === RUN in fuzz tests (#52636, #48132) - Add === RUN lines to note benchmark starts (#27764, #49505) - Print subtest --- PASS/FAIL lines as they happen (#29811) - Add === NAME lines to emit more test change events, such as when a subtest stops and the parent continues running. - Fix event shown in overall test failure (#27568) - Avoid interleaving of writes to os.Stdout and os.Stderr (#33419) Fixes #23036. Fixes #26325. Fixes #27568. Fixes #27764. Fixes #29811. Fixes #33419. Fixes #34286. Fixes #43683. Fixes #49505. Fixes #52636. Change-Id: Id4207b746a20693f92e52d68c6e4a7f8c41cc7c6 Reviewed-on: https://go-review.googlesource.com/c/go/+/443596 Auto-Submit: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-10-07testing: add an example showcasing B.RunParallel with B.ReportMetricEddie Lopez
This commit was dedicated to adding an example of using B.ReportMetrics with B.RunParallel called ExampleB_ReportMetric_parallel. In this example, the same algorithm for ExampleB_ReportMetric was used, instead with a concurrent for loop using PB.Next instead of a standard one. There is also notes noting when to use the B.ReportMetric methods when running concurrent testing. Fixes #50756 Change-Id: I2a621b4e367af5f4ec47d38a0da1035a8d52f628 Reviewed-on: https://go-review.googlesource.com/c/go/+/437815 Reviewed-by: Carlos Amedee <carlos@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com>
2022-09-29testing: update description of SetenvNobuki Fujii
Add the description of Setenv that it cannot use if the test have parallel ancestors. Fixes #55128 Change-Id: Ia5a1deaa1a3116d1ebb439600a7d316c7d155412 Reviewed-on: https://go-review.googlesource.com/c/go/+/434115 Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
2022-09-29runtime/coverage: improve unit testsThan McIntosh
Add a testpoint to cover support routines used to help implement "go test -cover". Change-Id: Ic28bf884a4e0d2c0a6d8fd04fc29c0c949227f21 Reviewed-on: https://go-review.googlesource.com/c/go/+/432315 Reviewed-by: Bryan Mills <bcmills@google.com>
2022-09-28testing: fail if T.Setenv is called via T.Run in a parallel testNobuki Fujii
The existing implementation can call to T.Setenv in T.Run even after calling to T.Parallel, so I changed it to cause a panic in that case. Fixes #55128 Change-Id: Ib89d998ff56f00f96a5ca218af071bd35fdae53a Reviewed-on: https://go-review.googlesource.com/c/go/+/431101 Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com>
2022-09-28cmd/go: support new hybrid coverage instrumentationThan McIntosh
If GOEXPERIMENT=coverageredesign is in effect, introduce a new top-level '-cover' option to "go build" to turn on new-style hybrid code coverage instrumentation. Similarly, use the new instrumentation for "go test -cover". The main effects of "-cover" under the hood are to instrument files at the package level using cmd/cover and to pass additional options to the compiler when building instrumented packages. The previous workflow for "go tool -cover mypkg" would expand to a series of "go tool cover" commands (one per file) followed by a single package compilation command to build the rewritten sources. With the new workflow, the Go command will pass all of the Go files in a package to the cover tool as a chunk (along with a config file containing other parameters), then the cover tool will write instrumented versions of the sources along with another "output" config with info on coverage variable names for the the compiler. The Go command will then kick off the compiler on the modified source files, also passing in the config file generated by cmd/cover. Updates #51430. Change-Id: Id65621ff6a8c70a30168c1412c2d6f805ff3b9e7 Reviewed-on: https://go-review.googlesource.com/c/go/+/355452 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Than McIntosh <thanm@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
2022-09-16testing: allow go test -run=^$ testingRuss Cox
This should fix the ssacheck builder. Change-Id: I4b6172df33d6447f7ec8fd8e301c6380efb92588 Reviewed-on: https://go-review.googlesource.com/c/go/+/431336 Auto-Submit: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-16cmd/go, testing: add go test -skip flagRuss Cox
For proposal #41583, add a new 'go test -skip' flag to make it easy to disable specific tests, benchmarks, examples, or fuzz targets. Fixes #41583. Change-Id: Id12a6575f505dafdce4a149aedc454a002e93afa Reviewed-on: https://go-review.googlesource.com/c/go/+/421439 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
2022-09-07testing: use strings.Buildercuiweixie
Change-Id: Ied8a3019f1e21c0e74c798d2b1b279a606a38554 Reviewed-on: https://go-review.googlesource.com/c/go/+/428279 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-08-30testing: increment tempDirSeq non-atomicallycuiweixie
It's unnecessary to to call atomic.AddInt32 since there is a mutex lock. Change-Id: I31fcece17c34f99a95772d744aebd3f6a8cf1d23 Reviewed-on: https://go-review.googlesource.com/c/go/+/426081 Reviewed-by: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> Auto-Submit: Bryan Mills <bcmills@google.com>
2022-08-29testing: convert common.hasSub to atomic typecuiweixie
Change-Id: I3d8a9b901efabe62f432c06361826f46c78d2605 Reviewed-on: https://go-review.googlesource.com/c/go/+/426080 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> Auto-Submit: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-29testing: explain using a _test packagebyarbrough
The existing documentation did not explain the difference between placing a _test.go file in the same package as what is being tested vs. adding it to a separate _test package. This explains the distinction and adds an example. Concept is explained well here: https://stackoverflow.com/a/31443271 Fixes #25223 Change-Id: Iebaba15207d8aa24f0b370d8dd4062eadb504b5c GitHub-Last-Rev: 7f49c5f4624b358af8052272da8ac3240751ada0 GitHub-Pull-Request: golang/go#54160 Reviewed-on: https://go-review.googlesource.com/c/go/+/420415 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com>
2022-08-29testing: convert numFailed to atomic typecuiweixie
Change-Id: Ic3464e95ad8901df5477d7717760b8c6d08ce97b Reviewed-on: https://go-review.googlesource.com/c/go/+/426078 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2022-08-25testing: add Elapsed method to testing.Bhopehook
Elapsed returns the measured elapsed time of the benchmark, but does not change the running state of the timer. Fixes #43620. Change-Id: Idd9f64c4632518eec759d2ffccbf0050d84fcc03 Reviewed-on: https://go-review.googlesource.com/c/go/+/420254 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: hopehook <hopehook@qq.com> Reviewed-by: Bryan Mills <bcmills@google.com>
2022-08-16testing: do not print 'root' benchName during test of package testingRuss Cox
$ cd $GOROOT/src/testing $ go test root root root root PASS $ The root prints have been happening since Go 1.14. There is a test in sub_test.go that calls b.Run directly with a benchmark named "root", which triggers the print. Silence them. Change-Id: I2f0c186f04c6139bc24fab0e91975fcf0a8e80fc Reviewed-on: https://go-review.googlesource.com/c/go/+/421437 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-08all: use io.Seek* instead of deprecated os.SEEK_*Tobias Klauser
These are available since Go 1.7. The version used for bootstrap is Go 1.17 for Go 1.20. For #44505 Change-Id: I497c9f617baefdeb273cd115b08b6e31bd10aad2 Reviewed-on: https://go-review.googlesource.com/c/go/+/421634 Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-05-26cmd/compile: mark closures made for generic function expressions as wrappersKeith Randall
Fixes #52237 Change-Id: I7488020c8d157e069202017a293d18230e3aef0d Reviewed-on: https://go-review.googlesource.com/c/go/+/408876 Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com>
2022-05-11Revert "testing: document -race goroutine limits"Keith Randall
This reverts commit 4907c62f99fbfc8608a79a17c20d89f50956d9fc. Reason for revert: Race detector v3, which we just upgraded to, no longer has a goroutine limit. (small caveat: openbsd/amd64 can't be updated, windows/amd64 isn't updated yet but should be by release time.) Change-Id: I90017834501e81d3990d888f1b2baf3432452846 Reviewed-on: https://go-review.googlesource.com/c/go/+/405595 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2022-05-08all: fix some lint issuesRyan Leung
Make some code more simple. Change-Id: I801adf0dba5f6c515681345c732dbb907f945419 GitHub-Last-Rev: a505146baca00a1b3268d11d10510afa8cea6f1d GitHub-Pull-Request: golang/go#49626 Reviewed-on: https://go-review.googlesource.com/c/go/+/364634 Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
2022-04-11all: gofmt main repoRuss Cox
[This CL is part of a sequence implementing the proposal #51082. The design doc is at https://go.dev/s/godocfmt-design.] Run the updated gofmt, which reformats doc comments, on the main repository. Vendored files are excluded. For #51082. Change-Id: I7332f099b60f716295fb34719c98c04eb1a85407 Reviewed-on: https://go-review.googlesource.com/c/go/+/384268 Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-04-08all: consistently use US spelling of present participlesDaniel Martí
It has been agreed that we should prefer the US spelling of words like "canceling" over "cancelling"; for example, see https://go.dev/cl/14526. Fix a few occurrences of the "canceling" inconsistency, as well as: * signaling * tunneling * marshaling Change-Id: I99f3ba0a700a9f0292bc6c1b110af31dd05f1ff0 Reviewed-on: https://go-review.googlesource.com/c/go/+/398734 Trust: Daniel Martí <mvdan@mvdan.cc> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-04-01all: remove trailing blank doc comment linesRuss Cox
A future change to gofmt will rewrite // Doc comment. // func f() to // Doc comment. func f() Apply that change preemptively to all doc comments. For #51082. Change-Id: I4023e16cfb0729b64a8590f071cd92f17343081d Reviewed-on: https://go-review.googlesource.com/c/go/+/384259 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-03testing: include ERROR_SHARING_VIOLATION in Windows cleanup retriesBryan C. Mills
Fixes #51442 Updates #50051 Change-Id: I1bfbc08c907077467fd50febbec6299a9b73af41 Reviewed-on: https://go-review.googlesource.com/c/go/+/388916 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-02-16testing: panic in Fuzz if the function returns a valueBryan C. Mills
Otherwise, the behavior of a fuzz target that returns an error could be confusing. Fuzz is already documented to require a function “with no return value”, so this fixes the implementation to match the existing documentation. Fixes #51222 Change-Id: I44ca7ee10960214c92f5ac066ac8484c8bb9cd6f Reviewed-on: https://go-review.googlesource.com/c/go/+/386175 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Nooras Saba‎ <saba@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-04testing: remove TODO and link to fuzz docsKatie Hockman
Change-Id: I3f5ee9629b0b0f3f29a021a656dbf3bca27e582d Reviewed-on: https://go-review.googlesource.com/c/go/+/383415 Trust: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-10testing: only snapshot coverage during fuzzingRoland Shoemaker
Only snapshot/reset coverage counters when we are actually fuzzing. This prevents a race when running corpus/seed values during the testing phase. Fixes #50488 Change-Id: I7dd5a0353a296c0b13eede29ad9af7c78814fa2d Reviewed-on: https://go-review.googlesource.com/c/go/+/376554 Trust: Katie Hockman <katie@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> Trust: Roland Shoemaker <roland@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-06testing: fix deadlock with t.Parallel in testing seed corpusKatie Hockman
The c.startParallel channel on the testContext is stuck in t.Parallel() because c.running starts at 1 for the main fuzz parent test, and is causing a deadlock because it is never released. It would normally be released by tRunner, but needs to instead be released by fRunner instead for fuzz tests. Fixes #50217 Change-Id: I2d010e9adddfd8e8321ff2f9dd2e43daf46c128f Reviewed-on: https://go-review.googlesource.com/c/go/+/374054 Reviewed-by: Roland Shoemaker <roland@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Trust: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-20all: fix spelling errors found by misspellDan Kortschak
Change-Id: Icedd0c3d49259d5aee249ecb33374e9b78e0c275 Reviewed-on: https://go-review.googlesource.com/c/go/+/373376 Reviewed-by: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-12-15all: fix typo in commentichxxx
Remove duplicate 'the' Change-Id: I3ed81c8d9c488662387e45580a3bcd462448ba44 GitHub-Last-Rev: 86443993b9b58c6fce4e09e283604c32ccc44cec GitHub-Pull-Request: golang/go#50017 Reviewed-on: https://go-review.googlesource.com/c/go/+/372394 Reviewed-by: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-12-14testing: retry spurious errors from RemoveAll for temp directoriesBryan C. Mills
This works around what appears to be either a kernel bug or a Go runtime or syscall bug affecting certain Windows versions (possibly all pre-2016?). The retry loop is a simplified version of the one used in cmd/go/internal/robustio. We use the same 2-second arbitrary timeout as was used in that package, since it seems to be reliable in practice on the affected builders. (If it proves to be too short, we can lengthen it, within reason, in a followup CL.) Since this puts a higher-level workaround in place, we can also revert the lower-level workaround added to a specific test in CL 345670. This addresses the specific occurrences of the bug for users of (*testing.T).TempDir, but does not fix the underlying bug for Go users outside the "testing" package (which remains open as #25965). Fixes #50051 Updates #48012 Updates #25965 Change-Id: I35be7125f32f05c8350787f5ca9a22974b8d0770 Reviewed-on: https://go-review.googlesource.com/c/go/+/371296 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Patrik Nyblom <pnyb@google.com> Trust: Patrik Nyblom <pnyb@google.com> Run-TryBot: Patrik Nyblom <pnyb@google.com>
2021-12-13testing: update docs for fuzzcachedirKatie Hockman
Although most of the code seems to be already implemented to support this for general use, it didn't make it in for Go 1.18, so for now we should at least document that it's only for use by the go command. Change-Id: Id559e72d590aedeaaa50bcf880bca1a385d858dd Reviewed-on: https://go-review.googlesource.com/c/go/+/370954 Trust: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
2021-12-13all: gofmt -w -r 'interface{} -> any' srcRuss Cox
And then revert the bootstrap cmd directories and certain testdata. And adjust tests as needed. Not reverting the changes in std that are bootstrapped, because some of those changes would appear in API docs, and we want to use any consistently. Instead, rewrite 'any' to 'interface{}' in cmd/dist for those directories when preparing the bootstrap copy. A few files changed as a result of running gofmt -w not because of interface{} -> any but because they hadn't been updated for the new //go:build lines. Fixes #49884. Change-Id: Ie8045cba995f65bd79c694ec77a1b3d1fe01bb09 Reviewed-on: https://go-review.googlesource.com/c/go/+/368254 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-11-27testing: simplify fuzzResult.String to avoid unnecessarily using fmt.Sprintfsivchari
Change-Id: I16b6bfb6b0f02672c894b20845aa14d8dd1979b4 GitHub-Last-Rev: 75ab90123a8a5ad42e96795b756d3a9e898aaa06 GitHub-Pull-Request: golang/go#49819 Reviewed-on: https://go-review.googlesource.com/c/go/+/367314 Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-11-22testing: mention that TB also covers the new type FBharath Kumar Uppala
Fixes #48146 Change-Id: I7c667a7915db81558514bc9fada6898c565eb0fd Reviewed-on: https://go-review.googlesource.com/c/go/+/365894 Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Katie Hockman <katie@golang.org> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Katie Hockman <katie@golang.org> Trust: Ian Lance Taylor <iant@golang.org>
2021-11-11all: update terminology for fuzzingKatie Hockman
This change doesn't modify any functionality. It also doesn't update all of the comments and variable names of the internal code, but everything user facing should be correct. Updates #49185 Change-Id: Ia8b2c94b89ba45897c4085ea0c17a3d8896f7ec7 Reviewed-on: https://go-review.googlesource.com/c/go/+/362794 Trust: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Roland Shoemaker <roland@golang.org>
2021-11-09testing: remove package from fuzz crasher messageKatie Hockman
Fixes #48149 Change-Id: Iaf91d2c54fda809c7da90cdfb6d1d075f474c69b Reviewed-on: https://go-review.googlesource.com/c/go/+/362116 Trust: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Julie Qiu <julie@golang.org>
2021-11-01testing: reduce memory used by subtest namesBryan C. Mills
This is heavily based on CL 341336 by Joe Tsai and CL 351452 by Jay Conrod. T.Run and T.Name use a map[string]int64 to hold the next suffix to use when duplicate names are passed to T.Run. This map necessarily retains one entry per unique name. However, it's a waste of memory to retain one entry per duplicate name: when we encounter the Nth duplicate, we know that names 00 through N-1 have been used just by looking at N. We do still need to store (and check for collisions againsts) explicit names provided by the caller. For example, if the user passes in "a", then "a#01", then "a" again, we cannot deduplicate the second "a" to "a#01" — we need to instead skip ahead to "a#02". We can do so by checking the count of "a", then generating a proposed deduplicated name, then double-checking that proposed name against only the explicit names so far. This somewhat reduces memory usage for tests that spawn large numbers of duplicate subtests, but doesn't solve the problem of memory growth for fuzzing — we still have to track all of the explicit, user-provided subtest names, and in a long-running fuzz test that set alone may be unbounded. This fixes memory growth for the example described in https://golang.org/issue/44517#issuecomment-897104060, but not the one in https://golang.org/issue/44517#issuecomment-933825661. For #44517 Change-Id: Ia159ecfcf44561ba67508d3af6377c27856df31d Reviewed-on: https://go-review.googlesource.com/c/go/+/354749 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-10-31testing: remove redundant type conversionAlexander Melentyev
Change-Id: Ib6415bb09af02e9ebc0099f50bf0fd7b572f2516 GitHub-Last-Rev: ebaa849d66efa45bd8ca50a8306652d823a41678 GitHub-Pull-Request: golang/go#49244 Reviewed-on: https://go-review.googlesource.com/c/go/+/360214 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-10-28all: go fix -fix=buildtag std cmd (except for bootstrap deps, vendor)Russ Cox
When these packages are released as part of Go 1.18, Go 1.16 will no longer be supported, so we can remove the +build tags in these files. Ran go fix -fix=buildtag std cmd and then reverted the bootstrapDirs as defined in src/cmd/dist/buildtool.go, which need to continue to build with Go 1.4 for now. Also reverted src/vendor and src/cmd/vendor, which will need to be updated in their own repos first. Manual changes in runtime/pprof/mprof_test.go to adjust line numbers. For #41184. Change-Id: Ic0f93f7091295b6abc76ed5cd6e6746e1280861e Reviewed-on: https://go-review.googlesource.com/c/go/+/344955 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-26all: use reflect.{Pointer,PointerTo}Cuong Manh Le
Updates #47651 Updates #48665 Change-Id: I69a87b45a5cad7a07fbd855040cd9935cf874554 Reviewed-on: https://go-review.googlesource.com/c/go/+/358454 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>