-
Notifications
You must be signed in to change notification settings - Fork 646
add support for testEnvFile #971
Changes from all commits
8d69ca4
5e05330
7be35b5
3ac1883
bb7c3a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,10 @@ | |
|
||
import vscode = require('vscode'); | ||
import path = require('path'); | ||
import { getGoRuntimePath, getBinPathWithPreferredGopath, resolvePath } from './goPath'; | ||
import { parseEnvFile, getGoRuntimePath, getBinPathWithPreferredGopath, resolvePath, stripBOM } from './goPath'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. stripBOM not needed here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch, I'll remove it. |
||
import cp = require('child_process'); | ||
import TelemetryReporter from 'vscode-extension-telemetry'; | ||
import fs = require('fs'); | ||
|
||
const extensionId: string = 'lukehoban.Go'; | ||
const extensionVersion: string = vscode.extensions.getExtension(extensionId).packageJSON.version; | ||
|
@@ -298,6 +299,21 @@ export function getToolsEnvVars(): any { | |
return Object.assign({}, process.env, toolsEnvVars); | ||
} | ||
|
||
export function getTestEnvVars(): any { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll move it :) |
||
const config = vscode.workspace.getConfiguration('go'); | ||
const toolsEnv = getToolsEnvVars(); | ||
const testEnv = config['testEnvVars'] || {}; | ||
|
||
let fileEnv = {}; | ||
let testEnvFile = config['testEnvFile']; | ||
if (testEnvFile) { | ||
testEnvFile = testEnvFile.replace(/\${workspaceRoot}/g, vscode.workspace.rootPath); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, didn't see this function. Will change it. |
||
fileEnv = parseEnvFile(testEnvFile); | ||
} | ||
|
||
return Object.assign({}, toolsEnv, fileEnv, testEnv); | ||
} | ||
|
||
export function getExtensionCommands(): any[] { | ||
let pkgJSON = vscode.extensions.getExtension(extensionId).packageJSON; | ||
if (!pkgJSON.contributes || !pkgJSON.contributes.commands) { | ||
|
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.
am guessing you are removing this because you expect this to be passed in the testEnvFile?
For someone who has set the GOPATH in the settings, but doesn't use the
testEnvVars
or the newtestEnvFile
setting, the debug test codelens will not work if this is removed.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.
I removed because of this line. GoDebug is always loading everything
process.env
. Am I missing something?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.
Good point