Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: -bench regexp doesn't apply to subbenchmarks #15126

Closed
valyala opened this issue Apr 5, 2016 · 8 comments

Comments

Projects
None yet
5 participants
@valyala
Copy link
Contributor

commented Apr 5, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
go version devel +1f5b1b2 Mon Apr 4 10:05:05 2016 +0000 linux/amd64
  1. What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build773049645=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
  1. What did you do?

Given the following subbenchmarks:

func BenchmarkFoo(b *testing.B) {
    b.Run("sub1", subbenchmark1)
    b.Run("sub2", subbenchamrk2)
}

I wanted to run only BenchmarkFoo/sub1 with:

go test -bench=BenchmarkFoo/sub1
  1. What did you expect to see?

Only BenchmarkFoo/sub1 should be executed

  1. What did you see instead?

No benchmarks are executed.

@valyala valyala changed the title testing: -bench regexp doesn't apply do subbenchmarks testing: -bench regexp doesn't apply to subbenchmarks Apr 5, 2016

@valyala

This comment has been minimized.

Copy link
Contributor Author

commented Apr 6, 2016

@mpvl , could you look into this?

@bradfitz

This comment has been minimized.

Copy link
Member

commented Apr 6, 2016

Tests too, or just benchmarks?

When I wrote https://go-review.googlesource.com/#/c/18370/, @adg asked me why not use a table-driven test. I replied in the Gerrit comments that I found regexps to be very useful for describing which tests to run.

@bradfitz bradfitz added this to the Go1.7 milestone Apr 6, 2016

@valyala

This comment has been minimized.

Copy link
Contributor Author

commented Apr 6, 2016

I couldn't figure out how to run subtests. The following example hangs forever with go tip when TestSubtest is executed:

func TestSubtest(t *testing.T) {
        t.Run("bar", func(t *testing.T) {})
        t.Run("baz", func(t *testing.T) {})
}
@mpvl

This comment has been minimized.

Copy link
Member

commented Apr 6, 2016

It applies to both tests and benchmarks. The CL to take care of this (https://go-review.googlesource.com/#/c/19122/) is the last step of the subtest/subbenchmark implementation and has taken a bit of time to review. You will be able to select subtests and subbenchmarks as you suggested once this CL is in.

(the hanging was a silly thing that is fixed in tip, btw).

@mpvl

This comment has been minimized.

Copy link
Member

commented Apr 8, 2016

@bradfitz: that was, in fact, one of my main motivations to start doing this in the first place. Run enables a bunch of other functionality that people have asked for, but I'm looking forward to using this one myself. :)

@gopherbot

This comment has been minimized.

Copy link

commented Apr 8, 2016

CL https://golang.org/cl/19122 mentions this issue.

@valyala

This comment has been minimized.

Copy link
Contributor Author

commented Apr 22, 2016

The issue should be fixed now by the CL. @bradfitz , could you close it, since it didn't close automatically due to a typo in the CL description?

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Apr 22, 2016

Closing. Thanks.

@golang golang locked and limited conversation to collaborators Apr 22, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.