Comments (1)
If anyone stumbles upon this issue while it is not fixed, here is a diff I came up with to get the sample working. Might not be the best way of doing things. Also the run.addCoverage()
call was giving me an error until I properly updated my VS Code to 1.88
.
Details ยป
diff --git a/test-provider-sample/package.json b/test-provider-sample/package.json
index e66acb2..f7aa619 100644
--- a/test-provider-sample/package.json
+++ b/test-provider-sample/package.json
@@ -7,9 +7,6 @@
"private": true,
"license": "MIT",
"repository": "https://github.com/Microsoft/vscode-extension-samples",
- "enabledApiProposals": [
- "testCoverage"
- ],
"engines": {
"vscode": "^1.68.0"
},
diff --git a/test-provider-sample/src/extension.ts b/test-provider-sample/src/extension.ts
index a6d2430..c5d970a 100644
--- a/test-provider-sample/src/extension.ts
+++ b/test-provider-sample/src/extension.ts
@@ -96,28 +96,24 @@ export async function activate(context: vscode.ExtensionContext) {
const fileCoverage = coveredLines.get(test.uri!.toString());
const lineInfo = fileCoverage?.[lineNo];
if (lineInfo) {
- lineInfo.executionCount++;
+ if (typeof lineInfo.executed === 'boolean') {
+ lineInfo.executed = true;
+ } else if (typeof lineInfo.executed === 'number') {
+ lineInfo.executed++;
+ }
}
+ for (const [uri, statements] of coveredLines) {
+ run.addCoverage(
+ vscode.FileCoverage.fromDetails(
+ vscode.Uri.parse(uri),
+ statements.filter((s): s is vscode.StatementCoverage => !!s)
+ )
+ );
+ }
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();
};
diff --git a/test-provider-sample/vscode.proposed.testCoverage.d.ts b/test-provider-sample/vscode.proposed.testCoverage.d.ts
deleted file mode 100644
index fc6e496..0000000
--- a/test-provider-sample/vscode.proposed.testCoverage.d.ts
+++ /dev/null
@@ -1,201 +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' {
-
- // https://github.com/microsoft/vscode/issues/123713
-
- export interface TestRun {
- /**
- * Adds coverage for a file in the run.
- */
- addCoverage(fileCoverage: FileCoverage): void;
-
- /**
- * An event fired when the editor is no longer interested in data
- * associated with the test run.
- */
- onDidDispose: Event<void>;
- }
-
- export interface TestRunProfile {
- /**
- * A function that provides detailed statement and function-level coverage for a file.
- *
- * The {@link FileCoverage} object passed to this function is the same instance
- * emitted on {@link TestRun.addCoverage} calls associated with this profile.
- */
- loadDetailedCoverage?: (testRun: TestRun, fileCoverage: FileCoverage, token: CancellationToken) => Thenable<FileCoverageDetail[]>;
- }
-
- /**
- * A class that contains information about a covered resource. A count can
- * be give for lines, branches, and declarations in a file.
- */
- export class CoveredCount {
- /**
- * Number of items covered in the file.
- */
- covered: number;
- /**
- * Total number of covered items in the file.
- */
- total: number;
-
- /**
- * @param covered Value for {@link CovereredCount.covered}
- * @param total Value for {@link CovereredCount.total}
- */
- constructor(covered: number, total: number);
- }
-
- /**
- * Contains coverage metadata for a file.
- */
- export class FileCoverage {
- /**
- * File URI.
- */
- readonly uri: Uri;
-
- /**
- * Statement coverage information. If the reporter does not provide statement
- * coverage information, this can instead be used to represent line coverage.
- */
- statementCoverage: CoveredCount;
-
- /**
- * Branch coverage information.
- */
- branchCoverage?: CoveredCount;
-
- /**
- * Declaration coverage information. Depending on the reporter and
- * language, this may be types such as functions, methods, or namespaces.
- */
- declarationCoverage?: CoveredCount;
-
- /**
- * Creates a {@link FileCoverage} instance with counts filled in from
- * the coverage details.
- * @param uri Covered file URI
- * @param detailed Detailed coverage information
- */
- static fromDetails(uri: Uri, details: readonly FileCoverageDetail[]): FileCoverage;
-
- /**
- * @param uri Covered file URI
- * @param statementCoverage Statement coverage information. If the reporter
- * does not provide statement coverage information, this can instead be
- * used to represent line coverage.
- * @param branchCoverage Branch coverage information
- * @param declarationCoverage Declaration coverage information
- */
- constructor(
- uri: Uri,
- statementCoverage: CoveredCount,
- branchCoverage?: CoveredCount,
- declarationCoverage?: CoveredCount,
- );
- }
-
- /**
- * Contains coverage information for a single statement or line.
- */
- export class StatementCoverage {
- /**
- * The number of times this statement was executed, or a boolean indicating
- * whether it was executed if the exact count is unknown. If zero or false,
- * the statement will be marked as un-covered.
- */
- executed: number | boolean;
-
- /**
- * Statement location.
- */
- location: Position | Range;
-
- /**
- * Coverage from branches of this line or statement. If it's not a
- * conditional, this will be empty.
- */
- branches: BranchCoverage[];
-
- /**
- * @param location The statement position.
- * @param executed The number of times this statement was executed, or a
- * boolean indicating whether it was executed if the exact count is
- * unknown. If zero or false, the statement will be marked as un-covered.
- * @param branches Coverage from branches of this line. If it's not a
- * conditional, this should be omitted.
- */
- constructor(executed: number | boolean, location: Position | Range, branches?: BranchCoverage[]);
- }
-
- /**
- * Contains coverage information for a branch of a {@link StatementCoverage}.
- */
- export class BranchCoverage {
- /**
- * The number of times this branch was executed, or a boolean indicating
- * whether it was executed if the exact count is unknown. If zero or false,
- * the branch will be marked as un-covered.
- */
- executed: number | boolean;
-
- /**
- * Branch location.
- */
- location?: Position | Range;
-
- /**
- * Label for the branch, used in the context of "the ${label} branch was
- * not taken," for example.
- */
- label?: string;
-
- /**
- * @param executed The number of times this branch was executed, or a
- * boolean indicating whether it was executed if the exact count is
- * unknown. If zero or false, the branch will be marked as un-covered.
- * @param location The branch position.
- */
- constructor(executed: number | boolean, location?: Position | Range, label?: string);
- }
-
- /**
- * Contains coverage information for a declaration. Depending on the reporter
- * and language, this may be types such as functions, methods, or namespaces.
- */
- export class DeclarationCoverage {
- /**
- * Name of the declaration.
- */
- name: string;
-
- /**
- * The number of times this declaration was executed, or a boolean
- * indicating whether it was executed if the exact count is unknown. If
- * zero or false, the declaration will be marked as un-covered.
- */
- executed: number | boolean;
-
- /**
- * Declaration location.
- */
- location: Position | Range;
-
- /**
- * @param executed The number of times this declaration was executed, or a
- * boolean indicating whether it was executed if the exact count is
- * unknown. If zero or false, the declaration will be marked as un-covered.
- * @param location The declaration position.
- */
- constructor(name: string, executed: number | boolean, location: Position | Range);
- }
-
- export type FileCoverageDetail = StatementCoverage | DeclarationCoverage;
-
-}
from vscode-extension-samples.
Related Issues (20)
- chat-sample: Error from participant: Language model 'copilot-gpt-3.5-turbo' errored, check cause for more details HOT 1
- comment-sample has many error when open developer window HOT 1
- helloworld-test-sample failed when rerun HOT 2
- Error while initiating multi LSP server
- Task Provider Sample shows no tasks HOT 1
- the sample is not compitable with the current api HOT 1
- Running VSCode Extension with Proposed GitHub Copilot Chat Integration (using Chat-Sample)
- timeout has wrong type in decorator-sample
- Contributing guide could be improved with getting started section for bugs and issues HOT 3
- wasm:lose an example of a function with a return type of string HOT 2
- chat-sample is not Windows friendly
- github.copilot-chat/1/gpt-3.5-turbo' errored, check cause for more details Unknown Error: Sorry, this message is too long. Please try a shorter question. HOT 1
- Existing Chat-Sample based application is broken with version 1.90 (non-insiders build) HOT 2
- chat-sample run error HOT 8
- hello-world-web-sample doesn't load if developing in WSL HOT 2
- Authentication provider sample can't log out HOT 1
- Inline completion not working
- Custom Text Editor dirty flag inconsistencies
- Create Terminal.shellIntegration sample
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-extension-samples.