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,
|
"default": false,
|
||||||
"description": "If true, shows test coverage when Go: Test Function at cursor command is run."
|
"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": {
|
"go.coverageOptions": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
|
|
|
@ -195,6 +195,7 @@ export function testCurrentFile(goConfig: vscode.WorkspaceConfiguration, isBench
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { tmpCoverPath, testFlags } = makeCoverData(goConfig, 'coverOnSingleTestFile', args);
|
||||||
const getFunctions = isBenchmark ? getBenchmarkFunctions : getTestFunctions;
|
const getFunctions = isBenchmark ? getBenchmarkFunctions : getTestFunctions;
|
||||||
|
|
||||||
return editor.document.save().then(() => {
|
return editor.document.save().then(() => {
|
||||||
|
@ -202,7 +203,7 @@ export function testCurrentFile(goConfig: vscode.WorkspaceConfiguration, isBench
|
||||||
const testConfig: TestConfig = {
|
const testConfig: TestConfig = {
|
||||||
goConfig,
|
goConfig,
|
||||||
dir: path.dirname(editor.document.fileName),
|
dir: path.dirname(editor.document.fileName),
|
||||||
flags: getTestFlags(goConfig, args),
|
flags: testFlags,
|
||||||
functions: testFunctions.map(sym => sym.name),
|
functions: testFunctions.map(sym => sym.name),
|
||||||
isBenchmark,
|
isBenchmark,
|
||||||
};
|
};
|
||||||
|
@ -211,7 +212,14 @@ export function testCurrentFile(goConfig: vscode.WorkspaceConfiguration, isBench
|
||||||
|
|
||||||
return isModSupported(editor.document.uri).then(isMod => {
|
return isModSupported(editor.document.uri).then(isMod => {
|
||||||
testConfig.isMod = 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 => {
|
}).then(null, err => {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче