summaryrefslogtreecommitdiff
path: root/src/testing/example.go
Commit message (Collapse)AuthorAgeFilesLines
* all: gofmt -w -r 'interface{} -> any' srcRuss Cox2021-12-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* testing: fail Example tests that invoke runtime.GoexitChangkun Ou2020-09-011-3/+8
| | | | | | | | | | | | | | | | | Previously, if an example test invoked runtime.Goexit, it would pass yet hang until a timeout, while regular tests that invoke runtime.Goexit do fail. This change removes that inconsistent behavior and makes such example tests fail, and panic with an indication of having invoked runtime.Goexit. Fixes #41084 Change-Id: I0ffa152204f2b1580f4d5d6961ba1ce6b13fc022 Reviewed-on: https://go-review.googlesource.com/c/go/+/251857 Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
* testing: use conventional comments for exported internal funcs & structsvovapi2019-12-101-2/+2
| | | | | | | | Change-Id: I2dd5ddc22bfff143b81d5945992d8c5fccf387f4 GitHub-Last-Rev: aa637756e772f5ee9094b802df3be9945c8466c4 GitHub-Pull-Request: golang/go#36054 Reviewed-on: https://go-review.googlesource.com/c/go/+/210497 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* testing: enable examples on js/wasm with non os.Pipe runExampleEmmanuel T Odeke2019-03-111-61/+31
| | | | | | | | | | | | | | | | | | os.Pipe is not implemented on wasm/js so for that purpose use a temporary file for js/wasm. This change creates two versions of runExample: * runExample verbatim that still uses os.Pipe for non js/wasm * runExample that uses a temporary file Also added a TODO to re-unify these function versions back into example.go wasm/js gets an os.Pipe implementation. Change-Id: I9f418a49b2c397e1667724c7442b7bbe8942225e Reviewed-on: https://go-review.googlesource.com/c/go/+/165357 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* all: use strings.Builder instead of bytes.Buffer where appropriateBrad Fitzpatrick2018-03-261-2/+1
| | | | | | | | | | | | | | I grepped for "bytes.Buffer" and "buf.String" and mostly ignored test files. I skipped a few on purpose and probably missed a few others, but otherwise I think this should be most of them. Updates #18990 Change-Id: I5a6ae4296b87b416d8da02d7bfaf981d8cc14774 Reviewed-on: https://go-review.googlesource.com/102479 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* testing: use time.Since instead of time.Now().SubDaniel Martí2017-09-061-1/+1
| | | | | | | | Change-Id: Ia0479f65a6ef033a65acf9ac8692777839a53b8c Reviewed-on: https://go-review.googlesource.com/61990 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* cmd/go, testing: indicate when no tests are runCaio Marcelo de Oliveira Filho2016-10-191-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | For example, testing the current directory: $ go test -run XXX testing: warning: no tests to run PASS ok testing 0.013s $ And in a summary: $ go test -run XXX testing ok testing 0.013s [no tests to run] $ These make it easy to spot when the -run regexp hasn't matched anything or there are no tests. Previously the message was printed in the "current directory" case when there were no tests at all, but not for no matches, and either way was not surfaced in the directory list summary form. Fixes #15211. Change-Id: I1c82a423d6bd429fb991c9ca964c9d26c96fd3c5 Reviewed-on: https://go-review.googlesource.com/22341 Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
* testing: implement 'Unordered Output' in Examples.Brady Catherman2016-03-091-5/+21
| | | | | | | | | | | | | | | | | Adds a type of output to Examples that allows tests to have unordered output. This is intended to help clarify when the output of a command will produce a fixed return, but that return might not be in an constant order. Examples where this is useful would be documenting the rand.Perm() call, or perhaps the (os.File).Readdir(), both of which can not guarantee order, but can guarantee the elements of the output. Fixes #10149 Change-Id: Iaf0cf1580b686afebd79718ed67ea744f5ed9fc5 Reviewed-on: https://go-review.googlesource.com/19280 Reviewed-by: Andrew Gerrand <adg@golang.org>
* testing: make the output of -v more uniform and aligned when using ↵Rob Pike2015-05-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* testing: style change: omit unnecessary newIan Lance Taylor2014-12-201-2/+2
| | | | | | | | | | | This was brought to my attention because a user thought that because the file was named "example.go" it served as an example of good coding practice. It's not an example, of course, but may as well use a more idiomatic style anyhow. Change-Id: I7aa720f603f09f7d597fb7536dbf46ef09144e28 Reviewed-on: https://go-review.googlesource.com/1902 Reviewed-by: Minux Ma <minux@golang.org>
* build: move package sources from src/pkg to srcRuss Cox2014-09-081-0/+100
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.