Skip to content

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

Closed

Description

@valyala

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.

Activity

  1. changed the title [-]testing: -bench regexp doesn't apply do subbenchmarks[/-] [+]testing: -bench regexp doesn't apply to subbenchmarks[/+] on Apr 5, 2016
  2. valyala commented on Apr 6, 2016

    @valyala
    ContributorAuthor

    @mpvl , could you look into this?

  3. bradfitz commented on Apr 6, 2016

    @bradfitz
    Contributor

    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.

  4. added this to the Go1.7 milestone on Apr 6, 2016
  5. valyala commented on Apr 6, 2016

    @valyala
    ContributorAuthor

    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) {})
    }
  6. mpvl commented on Apr 6, 2016

    @mpvl
    Contributor

    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).

  7. mpvl commented on Apr 8, 2016

    @mpvl
    Contributor

    @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. :)

  8. gopherbot commented on Apr 8, 2016

    @gopherbot
    Contributor

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

  9. valyala commented on Apr 22, 2016

    @valyala
    ContributorAuthor

    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?

  10. ianlancetaylor commented on Apr 22, 2016

    @ianlancetaylor
    Contributor

    Closing. Thanks.

  11. locked and limited conversation to collaborators on Apr 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions