Skip to content

testing: -bench does not honor the import path wild cards #18847

@l3x

Description

@l3x

What version of Go are you using (go version)?

go version go1.7.4 darwin/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN="/Users/lex/dev/go/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/lex/clients/packt/dev/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.7.4_2/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.7.4_2/libexec/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/vl/zj0n4b_9015_22chhpcjjw4h0000gn/T/go-build724604650=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"

What did you do?

My project directory looks like this:

book
+ chapter1
   + 01_fib
   + 02_recursive
   chapter1.go
+ chapter2 
( etc...) 

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions