Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: apply coverage comments for attributable coverage #234619

Merged
merged 3 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/vs/workbench/api/common/extHostTesting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ class TestRunTracker extends Disposable {
if (index === -1) {
return []; // ??
}
testItem = report.fromTests[index];
testItem = report.includesTests[index];
}

const details = testItem
Expand Down Expand Up @@ -755,10 +755,10 @@ class TestRunTracker extends Disposable {
return;
}

const fromTests = coverage instanceof FileCoverage ? coverage.fromTests : [];
if (fromTests.length) {
const includesTests = coverage instanceof FileCoverage ? coverage.includesTests : [];
if (includesTests.length) {
checkProposedApiEnabled(this.extension, 'attributableCoverage');
for (const test of fromTests) {
for (const test of includesTests) {
this.ensureTestIsKnown(test);
}
}
Expand All @@ -769,7 +769,7 @@ class TestRunTracker extends Disposable {
// it's been reported if it's rehomed under a different parent. Record its
// ID at the time when the coverage report is generated so we can reference
// it later if needeed.
this.publishedCoverage.set(id, { report: coverage, extIds: fromTests.map(t => TestId.fromExtHostTestItem(t, ctrlId).toString()) });
this.publishedCoverage.set(id, { report: coverage, extIds: includesTests.map(t => TestId.fromExtHostTestItem(t, ctrlId).toString()) });
this.proxy.$appendCoverage(runId, taskId, Convert.TestCoverage.fromFile(ctrlId, id, coverage));
},
//#region state mutation
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/api/common/extHostTypeConverters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2149,8 +2149,8 @@ export namespace TestCoverage {
statement: fromCoverageCount(coverage.statementCoverage),
branch: coverage.branchCoverage && fromCoverageCount(coverage.branchCoverage),
declaration: coverage.declarationCoverage && fromCoverageCount(coverage.declarationCoverage),
testIds: coverage instanceof types.FileCoverage && coverage.fromTests.length ?
coverage.fromTests.map(t => TestId.fromExtHostTestItem(t, controllerId).toString()) : undefined,
testIds: coverage instanceof types.FileCoverage && coverage.includesTests.length ?
coverage.includesTests.map(t => TestId.fromExtHostTestItem(t, controllerId).toString()) : undefined,
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/common/extHostTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4262,7 +4262,7 @@ export class FileCoverage implements vscode.FileCoverage {
public statementCoverage: vscode.TestCoverageCount,
public branchCoverage?: vscode.TestCoverageCount,
public declarationCoverage?: vscode.TestCoverageCount,
public fromTests: vscode.TestItem[] = [],
public includesTests: vscode.TestItem[] = [],
) {
}
}
Expand Down
16 changes: 9 additions & 7 deletions src/vscode-dts/vscode.proposed.attributableCoverage.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ declare module 'vscode' {
* file. If set, then {@link TestRunProfile.loadDetailedCoverageForTest}
* should also be defined in order to retrieve detailed coverage information.
*/
fromTests: TestItem[];
includesTests?: TestItem[];

constructor(
uri: Uri,
statementCoverage: TestCoverageCount,
branchCoverage?: TestCoverageCount,
declarationCoverage?: TestCoverageCount,
fromTests?: TestItem[],
includesTests?: TestItem[],
);
}

Expand All @@ -26,12 +26,14 @@ declare module 'vscode' {
* 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.fromTests} and only for
* files where such data is reported.
* a test item is provided in {@link FileCoverage.includesTests} and only
* for files where such data is reported.
*
* The editor will call this when user asks to view coverage for a test in
* a file, and the returned coverage information is used to display exactly
* what code was run by that test.
* 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.
Expand Down
Loading