Skip to content

cmd/go: go test -fuzz='^FuzzName$' uses default value of -run flag and runs all regular tests as well #50432

Closed as not planned
@dnwe

Description

@dnwe

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

$ gotip version
go version devel go1.18-95b240b2 Mon Jan 3 23:45:12 2022 +0000 darwin/amd64

Does this issue reproduce with the latest release?

Yes, this was reproduced on latest tip (95b240b) and had also been seen to reproduce on my previously installed version of gotip from Sep 22nd (09d3df0) too

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

go env Output
darwin/amd64

What did you do?

  • wrote a simple fuzz_test.go and attempted to run it with gotip test -fuzz=FuzzName as per the docs, but was surprised to find it taking a long time to run
  • added -v to see the output and noted that all of my others tests were being run too

What did you expect to see?

I expected -fuzz=^FuzzName$ to match the docs and spec and behave like -run=^TestName$:

In order to run a fuzz test with the mutation engine, -fuzz will take a regexp which must match only one fuzz test. In this situtation, only the fuzz test will run (ignoring all other tests)

What did you see instead?

gotip test proceeded to execute all of my regular tests in addition to the single fuzzing test that I'd specified. A workaround was to change the cmd to gotip test -fuzz='^FuzzName$' -run='^FuzzName$' and then it behaved as expected, running a single fuzzing test and nothing else.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoCommandcmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.fuzzIssues related to native fuzzing support

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions