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

go test with a specific run regex does not exclude tests #39362

Closed
dprotaso opened this issue Jun 2, 2020 · 1 comment
Closed

go test with a specific run regex does not exclude tests #39362

dprotaso opened this issue Jun 2, 2020 · 1 comment

Comments

@dprotaso
Copy link

@dprotaso dprotaso commented Jun 2, 2020

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

$ go version
go version go1.14.2 darwin/amd64

Does this issue reproduce with the latest release?

Yup

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

go env Output
$ go env
go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/dprotaso/Library/Caches/go-build"
GOENV="/Users/dprotaso/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/dprotaso/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.14.2_1/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.14.2_1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/dprotaso/work/test/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/qn/bxc0sm8j5dgcx260_4r3vr7w0000gn/T/go-build148028377=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

package main

import "testing"

func TestIngressConformance(t *testing.T) {
	t.Run("update", func(t *testing.T) {})
	t.Run("silo", func(t *testing.T) {})
}

Run the tests with a regex to exclude the update subtest

go test -v -run '/[^u]'

What did you expect to see?

TestIngressConformance/silo runs

What did you see instead?

update subtest runs even though it shouldn't have matched the regex

=== RUN   TestIngressConformance
=== RUN   TestIngressConformance/update
=== RUN   TestIngressConformance/silo
--- PASS: TestIngressConformance (0.00s)
    --- PASS: TestIngressConformance/update (0.00s)
    --- PASS: TestIngressConformance/silo (0.00s)
PASS
ok  	blah	0.006s
@dprotaso dprotaso changed the title go test run regex doesn't work go test with specific run regex doesn't work Jun 2, 2020
@dprotaso dprotaso changed the title go test with specific run regex doesn't work go test with a specific run regex does not exclude tests Jun 2, 2020
@dprotaso
Copy link
Author

@dprotaso dprotaso commented Jun 2, 2020

Figured it out - so the run input is split along / with each split-string treated as a regex.

[^u] does match update since it's not anchored.

Thus my regex would need to be ^[^u]

@dprotaso dprotaso closed this Jun 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.