Skip to content

Commit

Permalink
testing: finalize attributable test coverage API (#234686)
Browse files Browse the repository at this point in the history
* testing: finalize attributable test coverage API

Closes #212196

* fixup
  • Loading branch information
connor4312 authored Nov 26, 2024
1 parent ccdf7f6 commit 436f1e9
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class ScriptCoverageTracker {
}
}

export class V8CoverageFile extends vscode.FileCoverage2 {
export class V8CoverageFile extends vscode.FileCoverage {
public details: vscode.StatementCoverage[] = [];

constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
3 changes: 0 additions & 3 deletions src/vs/platform/extensions/common/extensionsApiProposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
Expand Down
1 change: 0 additions & 1 deletion src/vs/workbench/api/common/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/vs/workbench/api/common/extHostTesting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
32 changes: 32 additions & 0 deletions src/vscode-dts/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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.
Expand All @@ -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[],
);
}

Expand Down
48 changes: 0 additions & 48 deletions src/vscode-dts/vscode.proposed.attributableCoverage.d.ts

This file was deleted.

0 comments on commit 436f1e9

Please sign in to comment.