gotest -run flag needs to override user setting supplied -run flag #2260
Description
openedon Jan 18, 2019
The tool to run tests inserts a -run TestNameOne|TestNameTwo
when ran by clicking the run file tests
or the run test
hover text in a *_test.go file. (see vscode-go/src/testUtils.ts:375)
This conflicts with user settings supplied -run regex
flags, resulting in the error of:
go test: run flag may be set only once
In our project, our tests have suffixes of "_unit", "_acceptance", "_regression", etc... so our user settings file has:
"go.testFlags": [
"-run",
"^(.*_unit)$"
],
in it so that when tests are run on a file save, only the unit tests run.
Clicking run test
results in:
Running tool: /usr/local/go/bin/go test github.com/CompanyName/projectName/packageName -run ^(TestNameOne_unit)$ -run ^(.*_unit)$
go test: run flag may be set only once
run "go help test" or "go help testflag" for more information
Error: Tests failed.
When clicking on the run package tests
hover text, no -run regex
is inserted by the tool so the command looks like:
Running tool: /usr/local/go/bin/go test -timeout 120s github.com/CompanyName/projectName/packageName -v -run ^(.*_unit)$
and it runs as expected.
It seems to us that there are a few potential solutions here, but we don't want to dictate any solution to you. It might just be easiest to say "Ignore the user settings -run regex
commands when the tool is creating its own`
Thank you for your help, please let me know if there is anything else I can provide.
-Dan