-
Notifications
You must be signed in to change notification settings - Fork 645
Set environment variables for go test runs #498
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good - just a few notes in review comments.
return goTest({ | ||
timeout: timeout, | ||
dir: path.dirname(editor.document.fileName), | ||
functions: testFunctions.map(func => { return func.name; }) | ||
}); | ||
}).then(null, err => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put the console.error(err)
to back where it was and returned promise from there
@@ -116,19 +116,23 @@ export function testCurrentFile(timeout: string) { | |||
* | |||
* @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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to make this required and fix up callers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None at all. Made the update to pass goConfig from goMain.ts
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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