Set environment variables for go test runs#498
Conversation
lukehoban
left a comment
There was a problem hiding this comment.
Looks good - just a few notes in review comments.
| dir: path.dirname(editor.document.fileName), | ||
| functions: testFunctions.map(func => { return func.name; }) | ||
| }); | ||
| }).then(null, err => { |
There was a problem hiding this comment.
Possibly minor - but this change will mean that any exceptions thrown during execution of goTest are not handled and reported to console.error. A weirdness of .then on promises. Possibly just leave the additional .then call.
There was a problem hiding this comment.
Put the console.error(err) to back where it was and returned promise from there
| * @param config the test execution configuration. | ||
| */ | ||
| function goTest(config: TestConfig): Thenable<boolean> { | ||
| function goTest(config: TestConfig, goConfig?: vscode.WorkspaceConfiguration): Thenable<boolean> { |
There was a problem hiding this comment.
Any reason not to make this required and fix up callers?
There was a problem hiding this comment.
None at all. Made the update to pass goConfig from goMain.ts
| let buildFlags: string[] = goConfig['buildFlags']; | ||
| let buildTags: string = goConfig['buildTags']; | ||
| let args = ['test', '-v', '-timeout', config.timeout, '-tags', buildTags, ...buildFlags]; | ||
| let testEnvVars = Object.assign({}, goConfig['testEnvVars'], process.env); |
There was a problem hiding this comment.
Doesn't the order need to be changed to ensure that the testEnvVars overrride the process environment settings?
There was a problem hiding this comment.
True, nice catch. Corrected
|
For those trying to figure out how to use this, you have to set a value in your vs code Ex: |
|
Or "go.testEnvVars": {
"APP_DEBUG": "1",
"MY_ENV": "my-value"
}, |
Fixes #475