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

Running subtest does not handle pipes in name #2624

Closed
rittneje opened this issue Jan 24, 2023 · 5 comments
Closed

Running subtest does not handle pipes in name #2624

rittneje opened this issue Jan 24, 2023 · 5 comments
Assignees
Labels
go-test issues related to go test support (test output, test explorer, ...) HelpWanted Issues that are not prioritized by the maintainers. Help is requested from community contributors. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@rittneje
Copy link

What version of Go, VS Code & VS Code Go extension are you using?

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.

    • go version go1.18.9 darwin/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.

    • bash: gopls: command not found
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    This command doesn't do anything.
    The UI says 1.74.3.

  • Check your installed extensions to get the version of the VS Code Go extension

    • v0.37.1
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
    Checking configured tools....
    GOBIN: undefined
    toolsGopath: /Users/rittneje/gotools
    gopath: /Users/rittneje/iot-cloud-go-applications
    GOROOT: /Users/rittneje/go1.18.9
    PATH: /Users/rittneje/go1.18.9/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/rittneje/Library/Python/3.11/bin

    go: /Users/rittneje/go1.18.9/bin/go: go version go1.18.9 darwin/amd64

    gocode: /Users/rittneje/gotools/bin/gocode (version: v0.0.0-20200405233807-4acdcbdea79d built with go: go1.18.9)
    go-outline: /Users/rittneje/gotools/bin/go-outline (version: v0.0.0-20210608161538-9736a4bde949 built with go: go1.18.9)
    go-symbols: /Users/rittneje/gotools/bin/go-symbols (version: v0.1.1 built with go: go1.18.9)
    guru: /Users/rittneje/gotools/bin/guru (version: v0.4.0 built with go: go1.18.9)
    gorename: /Users/rittneje/gotools/bin/gorename (version: v0.4.0 built with go: go1.18.9)
    gotests: /Users/rittneje/gotools/bin/gotests (version: v1.6.0 built with go: go1.18.9)
    gomodifytags: /Users/rittneje/gotools/bin/gomodifytags (version: v1.16.0 built with go: go1.18.9)
    impl: /Users/rittneje/gotools/bin/impl (version: v1.1.0 built with go: go1.18.9)
    fillstruct: /Users/rittneje/gotools/bin/fillstruct (version: v0.0.0-20210213085015-40322ffdc2e4 built with go: go1.18.9)
    goplay: /Users/rittneje/gotools/bin/goplay (version: v1.0.0 built with go: go1.18.9)
    godoctor: /Users/rittneje/gotools/bin/godoctor (version: v0.0.0-20220520165350-b665b8ff3f35 built with go: go1.18.9)
    dlv: /Users/rittneje/gotools/bin/dlv (version: v1.9.1 built with go: go1.18.9)
    gocode-gomod: /Users/rittneje/gotools/bin/gocode-gomod (version: v1.0.0 built with go: go1.18.9)
    godef: /Users/rittneje/gotools/bin/godef (version: v1.1.2 built with go: go1.18.9)
    goimports: /Users/rittneje/gotools/bin/goimports (version: v0.4.0 built with go: go1.18.9)
    golangci-lint: /Users/rittneje/gotools/bin/golangci-lint (version: v1.50.1 built with go: go1.18.9)

go env
Workspace Folder (iot-cloud-go-applications): /Users/rittneje/iot-cloud-go-applications
GO111MODULE="auto"
GOARCH="amd64"
GOBIN=""
GOCACHE="/tmp/.gocache"
GOENV="/Users/rittneje/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/rittneje/iot-cloud-go-applications/pkg/mod"
GONOPROXY="[redacted]"
GONOSUMDB="[redacted]"
GOOS="darwin"
GOPATH="[redacted]"
GOPRIVATE="[redacted]"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/rittneje/go1.18.9"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/rittneje/go1.18.9/pkg/tool/darwin_amd64"
GOVCS="[redacted]"
GOVERSION="go1.18.9"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/kf/kr7_s3xx0l12zbj3jrn082hmzy5gvy/T/go-build2467560491=/tmp/go-build -gno-record-gcc-switches -fno-common"

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] or gopls prefixes.

Describe the bug

Directly running a subtest that contains the pipe character does not work.

Steps to reproduce the behavior:

func TestFoo(t *testing.T) {
	t.Run("Bar|Baz", func(t *testing.T) {
		// pass
	})
}

Click the "Run test" button above the subtest (NOT the one above TestFoo).

Running tool: /Users/rittneje/go1.18.9/bin/go test -timeout 30s -run ^\QTestFoo\E$/^\QBar|Baz\E$ testpackage

testing: invalid regexp for alternation 1 of element 0 of -test.run ("Baz\E$"): error parsing regexp: invalid escape sequence: \E

@gopherbot gopherbot added this to the Untriaged milestone Jan 24, 2023
@findleyr
Copy link
Contributor

This looks plainly like incorrect escaping of the subtest name.

@findleyr findleyr added the NeedsFix The path to resolution is known, but the work has not been done. label Jan 26, 2023
@findleyr findleyr modified the milestones: Untriaged, vscode-go/later Jan 26, 2023
@findleyr findleyr added HelpWanted Issues that are not prioritized by the maintainers. Help is requested from community contributors. go-test issues related to go test support (test output, test explorer, ...) labels Jan 26, 2023
@rittneje
Copy link
Author

rittneje commented Jan 26, 2023

I would think the fix is to use regexp.QuoteMeta (or whatever the equivalent is in the language in question) instead of the \Q and \E business.

@rittneje
Copy link
Author

By the way, the same issue unfolds if my subtest name contains \Q or \E.

func TestFoo(t *testing.T) {
	t.Run("\\Q", func(t *testing.T) {
		// pass
	})
	t.Run("\\E", func(t *testing.T) {
		// pass
	})
}

If I run the first one, it says "no tests to run". If I run the second one, it fails with an error.

@findleyr
Copy link
Contributor

Hmm, @hyangah points out that there isn't an easy way to get the actual subtest name from the string constant. I wonder if we should propose this addition to the testing package?

(or we could borrow the code)

@gopherbot
Copy link
Collaborator

Change https://go.dev/cl/546260 mentions this issue: src/goTest: fix bugs in subtest handling

@hyangah hyangah modified the milestones: vscode-go/backlog, v0.41.0 Dec 5, 2023
@hyangah hyangah self-assigned this Dec 5, 2023
@hyangah hyangah modified the milestones: v0.41.0, v0.40.1 Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go-test issues related to go test support (test output, test explorer, ...) HelpWanted Issues that are not prioritized by the maintainers. Help is requested from community contributors. NeedsFix The path to resolution is known, but the work has not been done.
Projects
Status: Done
Development

No branches or pull requests

4 participants