You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
testing: -bench does not honor the import path wild cards #18847
I would like to run tests for all chapters from the root (book) directory.
go test ./... works as expected, running all tests found in all subdirectories.
$ go test ./...
? bitbucket.org/lsheehan/fp-in-go [no test files]
? bitbucket.org/lsheehan/fp-in-go/chapter1 [no test files]
ok bitbucket.org/lsheehan/fp-in-go/chapter1/01_fib 2.860s
go test -bench ./... does not. Here's what it does:
$ go test -bench ./...
? bitbucket.org/lsheehan/fp-in-go [no test files]
I can, however, move into the directory that contains the tests and get good results from the benchmark test:
... chapter1/fib $ go test -bench=.
1
BenchmarkFibFunc-8 100
10000
1000000
3000000
3000000 570 ns/op
PASS
ok bitbucket.org/lsheehan/fp-in-go/chapter1/fib 5.100s
Activity
davecheney commentedon Jan 29, 2017
This is working as intended.
-benchtakes an argument, a regex to match against benchmarks in the _test.go files.Your non working example passes
./...as that regex which doesn't match anything and will only run in the current directory.try
l3x commentedon Jan 30, 2017
Yup. Works like a charm when called properly. Thank you for sharing your wisdom with articles like: https://dave.cheney.net/2013/06/30/how-to-write-benchmarks-in-go