From bc9df3b1a82143a619740cd6ddf6f8373c48bff1 Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Mon, 25 Nov 2024 14:46:36 -0800 Subject: [PATCH] testing: apply coverage comments for attributable coverage Refs #233709 --- src/vs/workbench/api/common/extHostTesting.ts | 10 +++++----- src/vs/workbench/api/common/extHostTypeConverters.ts | 4 ++-- src/vs/workbench/api/common/extHostTypes.ts | 2 +- .../vscode.proposed.attributableCoverage.d.ts | 12 ++++++++---- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/vs/workbench/api/common/extHostTesting.ts b/src/vs/workbench/api/common/extHostTesting.ts index e3ae92ae4c8461..23836b825b3a7a 100644 --- a/src/vs/workbench/api/common/extHostTesting.ts +++ b/src/vs/workbench/api/common/extHostTesting.ts @@ -696,7 +696,7 @@ class TestRunTracker extends Disposable { if (index === -1) { return []; // ?? } - testItem = report.fromTests[index]; + testItem = report.includesTests[index]; } const details = testItem @@ -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); } } @@ -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 diff --git a/src/vs/workbench/api/common/extHostTypeConverters.ts b/src/vs/workbench/api/common/extHostTypeConverters.ts index f33ea98cf4f3c8..ba476aa6d730dd 100644 --- a/src/vs/workbench/api/common/extHostTypeConverters.ts +++ b/src/vs/workbench/api/common/extHostTypeConverters.ts @@ -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, }; } } diff --git a/src/vs/workbench/api/common/extHostTypes.ts b/src/vs/workbench/api/common/extHostTypes.ts index 35082a1e9e9d36..26a90feb23ae25 100644 --- a/src/vs/workbench/api/common/extHostTypes.ts +++ b/src/vs/workbench/api/common/extHostTypes.ts @@ -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[] = [], ) { } } diff --git a/src/vscode-dts/vscode.proposed.attributableCoverage.d.ts b/src/vscode-dts/vscode.proposed.attributableCoverage.d.ts index cbd71e1686bfe0..b56f976670dc15 100644 --- a/src/vscode-dts/vscode.proposed.attributableCoverage.d.ts +++ b/src/vscode-dts/vscode.proposed.attributableCoverage.d.ts @@ -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[]; // TODO: `from` feels weird to me. Maybe `sourceTests` or `contributingTests` or even just `tests` + includesTests?: TestItem[]; constructor( uri: Uri, statementCoverage: TestCoverageCount, branchCoverage?: TestCoverageCount, declarationCoverage?: TestCoverageCount, - fromTests?: TestItem[], + includesTests?: TestItem[], ); } @@ -26,8 +26,12 @@ 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. + * + * 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. * * // TODO: clarify how this works with `loadDetailedCoverage`. Does it replace `loadDetailedCoverage` or will it be called in addition to it? *