You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
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
The text was updated successfully, but these errors were encountered:
I believe we add the -run followed by the test functions when running individual tests or when running all the tests in the file. As you have already noticed, we dont do this when running all the tests in the package.
It might just be easiest to say "Ignore the user settings -run regex commands when the tool is creating its own`
This would be the right approach. Also ignore such user settings when not needed in cases like when we run go test -c to find build errors
PRs are most welcome to make this change.
Code Pointers:
The getTestFlags() function in the testUtils.ts file is the one that reads from the settings. All we need to do is to go through the different features that call this and prune out the run regex as needed
The below are the places where getTestFlags() is used
goBuild.ts: To run go test to file build errors in test file
goCheck.ts: To run tests when either go.testOnSave or go.coverOnSave settings are enabled
goCover.ts: To all tests in the package when the Toggle Code Coverage in Package command is run
goRunTestCodelens.ts: To create the codelens links above test functions
Hey, 👋 I can try to work on this. I'm very new to the codebase and TS itself. I may take some time and would need some help to tackle this. If It's alright I can start working on this 😅 😃
The tool to run tests inserts a
-run TestNameOne|TestNameTwo
when ran by clicking therun file tests
or therun 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:
in it so that when tests are run on a file save, only the unit tests run.
Clicking
run test
results in:When clicking on the
run package tests
hover text, no-run regex
is inserted by the tool so the command looks like: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
The text was updated successfully, but these errors were encountered: