You've missed the regexp argument to -bench; try just a . to match all 
benchmarks.

(In fact go test will be interpreting crypto/tls/... as the regular 
expression, and with no further parameter is trying to test what's in the 
current directory.)

-bench regexp
    Run only those benchmarks matching a regular expression.
    By default, no benchmarks are run.
    To run all benchmarks, use '-bench .' or '-bench=.'.
    The regular expression is split by unbracketed slash (/)
    characters into a sequence of regular expressions, and each
    part of a benchmark's identifier must match the corresponding
    element in the sequence, if any. Possible parents of matches
    are run with b.N=1 to identify sub-benchmarks. For example,
    given -bench=X/Y, top-level benchmarks matching X are run
    with b.N=1 to find any sub-benchmarks matching Y, which are
    then run in full.

On Saturday, October 21, 2017 at 2:54:16 PM UTC+1, Leon Klingele wrote:
>
> `go test crypto/tls/...` indeed works fine (from $HOME), but I want to 
> run benchmarks as well, which fails: 
> ``` 
> $ pwd 
> /home/leon 
> $ go test -bench crypto/tls/... 
> can't load package: package .: no Go files in /home/leon 
> ``` 
>
> ``` 
> $ go env | grep "GO\(PATH\|ROOT\).*" 
> GOPATH="/home/leon/dev/go" 
> GOROOT="/usr/local/Cellar/go/1.9.1/libexec" # <- Homebrew install 
> ``` 
>
> Running benchs from inside $GOROOT however works :o 
> ``` 
> $ pwd 
> /usr/local/Cellar/go/1.9.1/libexec # <- Homebrew install 
> $ go test -bench ./... 
> ``` 
>
> Why do benchs of the Go standard library need to be run from 
> $GOROOT? This is so confusing. 
>
>
> On 17.10.2017, at 23:54, Ian Lance Taylor <ia...@golang.org <javascript:>> 
> wrote: 
> > 
> > On Tue, Oct 17, 2017 at 2:43 PM,  <goo...@leonklingele.de <javascript:>> 
> wrote: 
> >> 
> >> I was wondering how to run tests and benchmarks of the Go standard 
> library 
> >> such as this one: 
> >> 
> https://go-review.googlesource.com/c/go/+/44730/4/src/crypto/tls/handshake_server_test.go#1056
>  
> >> 
> >> $ pwd 
> >> $GOPATH/src/github.com/golang/go/src/crypto/tls 
> >> $ git rev-parse HEAD 
> >> 5f740d6875ab6961381f2f4614b21ff6ddf448a4 
> >> $ go version 
> >> go version go1.9.1 linux/amd64 
> >> $ go test -v ./... 
> >> common.go:10:2: use of internal package not allowed 
> > 
> > My first guess would be that the version of `go` on your PATH does not 
> > think that $GOPATH/src/github.com/golang/go/src/crypto/tls is in 
> > GOROOT.  Which is also suggested by the fact that it is in GOPATH. 
> > Normally GOROOT and GOPATH should be distinct. 
> > 
> > Note that in general you can run `go test crypto/tls/...` from any 
> > directory to test the crypto/tls directory and its subdirectories. 
> > 
> > Ian 
>
>
>
> ----------------------------------------------------------------------- 
> ------------------------------------------------------------------------ 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to