testing: finalize attributable test coverage API (#234686)

* testing: finalize attributable test coverage API

Closes #212196

* fixup
pull/234694/head
Connor Peet 2024-11-26 10:53:38 -08:00 committed by GitHub
parent ccdf7f67e7
commit 436f1e99c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 34 additions and 56 deletions

View File

@ -142,7 +142,7 @@ class ScriptCoverageTracker {
}
}
export class V8CoverageFile extends vscode.FileCoverage2 {
export class V8CoverageFile extends vscode.FileCoverage {
public details: vscode.StatementCoverage[] = [];
constructor(

View File

@ -11,7 +11,6 @@
"src/**/*",
"../../../src/vscode-dts/vscode.d.ts",
"../../../src/vscode-dts/vscode.proposed.testObserver.d.ts",
"../../../src/vscode-dts/vscode.proposed.testRelatedCode.d.ts",
"../../../src/vscode-dts/vscode.proposed.attributableCoverage.d.ts"
"../../../src/vscode-dts/vscode.proposed.testRelatedCode.d.ts"
]
}

View File

@ -16,9 +16,6 @@ const _allApiProposals = {
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.aiTextSearchProvider.d.ts',
version: 2
},
attributableCoverage: {
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.attributableCoverage.d.ts',
},
authLearnMore: {
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.authLearnMore.d.ts',
},

View File

@ -1732,7 +1732,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
DataTransferItem: extHostTypes.DataTransferItem,
TestCoverageCount: extHostTypes.TestCoverageCount,
FileCoverage: extHostTypes.FileCoverage,
FileCoverage2: extHostTypes.FileCoverage,
StatementCoverage: extHostTypes.StatementCoverage,
BranchCoverage: extHostTypes.BranchCoverage,
DeclarationCoverage: extHostTypes.DeclarationCoverage,

View File

@ -757,7 +757,6 @@ class TestRunTracker extends Disposable {
const includesTests = coverage instanceof FileCoverage ? coverage.includesTests : [];
if (includesTests.length) {
checkProposedApiEnabled(this.extension, 'attributableCoverage');
for (const test of includesTests) {
this.ensureTestIsKnown(test);
}

View File

@ -17614,6 +17614,29 @@ declare module 'vscode' {
*/
loadDetailedCoverage?: (testRun: TestRun, fileCoverage: FileCoverage, token: CancellationToken) => Thenable<FileCoverageDetail[]>;
/**
* An extension-provided function that provides detailed statement and
* function-level coverage for a single test in a file. This is the per-test
* sibling of {@link TestRunProfile.loadDetailedCoverage}, called only if
* a test item is provided in {@link FileCoverage.includesTests} and only
* for files where such data is reported.
*
* Often {@link TestRunProfile.loadDetailedCoverage} will be called first
* when a user opens a file, and then this method will be called if they
* drill down into specific per-test coverage information. This method
* should then return coverage data only for constructs the given test item
* executed during the test run.
*
* The {@link FileCoverage} object passed to this function is the same
* instance emitted on {@link TestRun.addCoverage} calls associated with this profile.
*
* @param testRun The test run that generated the coverage data.
* @param fileCoverage The file coverage object to load detailed coverage for.
* @param fromTestItem The test item to request coverage information for.
* @param token A cancellation token that indicates the operation should be cancelled.
*/
loadDetailedCoverageForTest?: (testRun: TestRun, fileCoverage: FileCoverage, fromTestItem: TestItem, token: CancellationToken) => Thenable<FileCoverageDetail[]>;
/**
* Deletes the run profile.
*/
@ -18207,6 +18230,13 @@ declare module 'vscode' {
*/
declarationCoverage?: TestCoverageCount;
/**
* A list of {@link TestItem test cases} that generated coverage in this
* file. If set, then {@link TestRunProfile.loadDetailedCoverageForTest}
* should also be defined in order to retrieve detailed coverage information.
*/
includesTests?: TestItem[];
/**
* Creates a {@link FileCoverage} instance with counts filled in from
* the coverage details.
@ -18222,12 +18252,14 @@ declare module 'vscode' {
* used to represent line coverage.
* @param branchCoverage Branch coverage information
* @param declarationCoverage Declaration coverage information
* @param includesTests Test cases included in this coverage report, see {@link includesTests}
*/
constructor(
uri: Uri,
statementCoverage: TestCoverageCount,
branchCoverage?: TestCoverageCount,
declarationCoverage?: TestCoverageCount,
includesTests?: TestItem[],
);
}

View File

@ -1,48 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
declare module 'vscode' {
export class FileCoverage2 extends FileCoverage {
/**
* A list of {@link TestItem test cases} that generated coverage in this
* file. If set, then {@link TestRunProfile.loadDetailedCoverageForTest}
* should also be defined in order to retrieve detailed coverage information.
*/
includesTests?: TestItem[];
constructor(
uri: Uri,
statementCoverage: TestCoverageCount,
branchCoverage?: TestCoverageCount,
declarationCoverage?: TestCoverageCount,
includesTests?: TestItem[],
);
}
export interface TestRunProfile {
/**
* An extension-provided function that provides detailed statement and
* function-level coverage for a single test in a file. This is the per-test
* sibling of {@link TestRunProfile.loadDetailedCoverage}, called only if
* a test item is provided in {@link FileCoverage.includesTests} and only
* for files where such data is reported.
*
* Often {@link TestRunProfile.loadDetailedCoverage} will be called first
* when a user opens a file, and then this method will be called if they
* drill down into specific per-test coverage information. This method
* should then return coverage data only for constructs the given test item
* executed during the test run.
*
* The {@link FileCoverage} object passed to this function is the same
* instance emitted on {@link TestRun.addCoverage} calls associated with this profile.
*
* @param testRun The test run that generated the coverage data.
* @param fileCoverage The file coverage object to load detailed coverage for.
* @param fromTestItem The test item to request coverage information for.
* @param token A cancellation token that indicates the operation should be cancelled.
*/
loadDetailedCoverageForTest?: (testRun: TestRun, fileCoverage: FileCoverage, fromTestItem: TestItem, token: CancellationToken) => Thenable<FileCoverageDetail[]>;
}
}