add setting to apply test coverage when single test file is run (#2884)
This commit is contained in:
Родитель
5916863d76
Коммит
6ffbcd8513
|
@ -883,6 +883,11 @@
|
|||
"default": false,
|
||||
"description": "If true, shows test coverage when Go: Test Function at cursor command is run."
|
||||
},
|
||||
"go.coverOnSingleTestFile": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "If true, shows test coverage when Go: Test Single File command is run."
|
||||
},
|
||||
"go.coverageOptions": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
|
|
|
@ -195,6 +195,7 @@ export function testCurrentFile(goConfig: vscode.WorkspaceConfiguration, isBench
|
|||
return;
|
||||
}
|
||||
|
||||
const { tmpCoverPath, testFlags } = makeCoverData(goConfig, 'coverOnSingleTestFile', args);
|
||||
const getFunctions = isBenchmark ? getBenchmarkFunctions : getTestFunctions;
|
||||
|
||||
return editor.document.save().then(() => {
|
||||
|
@ -202,7 +203,7 @@ export function testCurrentFile(goConfig: vscode.WorkspaceConfiguration, isBench
|
|||
const testConfig: TestConfig = {
|
||||
goConfig,
|
||||
dir: path.dirname(editor.document.fileName),
|
||||
flags: getTestFlags(goConfig, args),
|
||||
flags: testFlags,
|
||||
functions: testFunctions.map(sym => sym.name),
|
||||
isBenchmark,
|
||||
};
|
||||
|
@ -211,7 +212,14 @@ export function testCurrentFile(goConfig: vscode.WorkspaceConfiguration, isBench
|
|||
|
||||
return isModSupported(editor.document.uri).then(isMod => {
|
||||
testConfig.isMod = isMod;
|
||||
return goTest(testConfig);
|
||||
return goTest(testConfig).then(success => {
|
||||
if (tmpCoverPath) {
|
||||
applyCodeCoverageToAllEditors(tmpCoverPath, testConfig.dir);
|
||||
}
|
||||
return Promise.resolve(success);
|
||||
}, err => {
|
||||
console.log(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
}).then(null, err => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче