publish test coverage at the right time in the test sample (#924)

This commit is contained in:
Connor Peet
2023-11-27 17:31:25 -05:00
committed by GitHub
parent 3c6d40304c
commit b8bd441237
2 changed files with 22 additions and 17 deletions

View File

@ -102,25 +102,25 @@ export async function activate(context: vscode.ExtensionContext) {
run.appendOutput(`Completed ${test.id}\r\n`);
}
run.coverageProvider = {
provideFileCoverage() {
const coverage: vscode.FileCoverage[] = [];
for (const [uri, statements] of coveredLines) {
coverage.push(
vscode.FileCoverage.fromDetails(
vscode.Uri.parse(uri),
statements.filter((s): s is vscode.StatementCoverage => !!s)
)
);
}
return coverage;
},
};
run.end();
};
run.coverageProvider = {
provideFileCoverage() {
const coverage: vscode.FileCoverage[] = [];
for (const [uri, statements] of coveredLines) {
coverage.push(
vscode.FileCoverage.fromDetails(
vscode.Uri.parse(uri),
statements.filter((s): s is vscode.StatementCoverage => !!s)
)
);
}
return coverage;
},
};
discoverTests(request.include ?? gatherTestItems(ctrl.items)).then(runTestQueue);
};

View File

@ -175,6 +175,11 @@ declare module 'vscode' {
* Contains coverage information for a function or method.
*/
export class FunctionCoverage {
/**
* Name of the function or method.
*/
name: string;
/**
* The number of times this function was executed. If zero, the
* function will be marked as un-covered.
@ -190,7 +195,7 @@ declare module 'vscode' {
* @param executionCount The number of times this function was executed.
* @param location The function position.
*/
constructor(executionCount: number, location: Position | Range);
constructor(name: string, executionCount: number, location: Position | Range);
}
export type DetailedCoverage = StatementCoverage | FunctionCoverage;