Skip to content
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
19 changes: 10 additions & 9 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"url": "https://github.com/denoland/vscode_deno"
},
"engines": {
"vscode": "^1.60.0"
"vscode": "^1.77.0"
},
"dependencies": {
"dotenv": "^16.4.5",
Expand All @@ -21,7 +21,7 @@
},
"devDependencies": {
"@types/semver": "7.3.9",
"@types/vscode": "1.67.0",
"@types/vscode": "1.77.0",
"vscode-test": "^1.6.1"
}
}
9 changes: 9 additions & 0 deletions client/src/lsp_extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ export interface TestRunRequestParams {
/** The run kind. Currently Deno only supports `"run"` */
kind: "run" | "coverage" | "debug";

/** Whether the run should watch the files and continously re-run. */
isContinuous: boolean;

/** Test modules or tests to exclude from the test run. */
exclude?: TestIdentifier[];

Expand Down Expand Up @@ -210,6 +213,11 @@ interface TestOutput {
location?: Location;
}

interface TestRunRestart {
type: "restart";
enqueued: EnqueuedTestModule[]
}

interface TestEnd {
/** The test run has ended. */
type: "end";
Expand All @@ -220,6 +228,7 @@ type TestRunProgressMessage =
| TestFailedErrored
| TestPassed
| TestOutput
| TestRunRestart
| TestEnd;

export interface TestRunProgressParams {
Expand Down
56 changes: 51 additions & 5 deletions client/src/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,18 @@ function getTestItem(
}
}

interface TestRunRequestInfo {
readonly include: readonly vscode.TestItem[] | undefined;
readonly exclude: readonly vscode.TestItem[] | undefined;
readonly profile: vscode.TestRunProfile | undefined;
}

export class DenoTestController implements vscode.Disposable {
#runCount = 0;
#runs = new Map<number, vscode.TestRun>();
#runs = new Map<
number,
{ run: vscode.TestRun; request: TestRunRequestInfo }
>();
#subscriptions: vscode.Disposable[] = [];

constructor(client: LanguageClient) {
Expand All @@ -148,7 +157,14 @@ export class DenoTestController implements vscode.Disposable {
) => {
const run = testController.createTestRun(request);
const id = ++this.#runCount;
this.#runs.set(id, run);
this.#runs.set(id, {
run,
request: {
include: request.include,
exclude: request.exclude,
profile: request.profile,
},
});
// currently on "run" is implemented and exposed
let kind: "run" | "coverage" | "debug" = "run";
switch (request.profile?.kind) {
Expand All @@ -159,6 +175,7 @@ export class DenoTestController implements vscode.Disposable {
kind = "debug";
break;
}
const isContinuous = request.continuous ?? false;
const include = request.include
? request.include.map(asTestIdentifier)
: undefined;
Expand All @@ -168,13 +185,16 @@ export class DenoTestController implements vscode.Disposable {
const { enqueued } = await client.sendRequest(testRun, {
id,
kind,
isContinuous,
include,
exclude,
});

cancellation.onCancellationRequested(async () => {
await client.sendRequest(testRunCancel, { id });
run.end();
// The run can be replaced
const runData = this.#runs.get(id);
runData?.run.end();
this.#runs.delete(id);
});

Expand All @@ -194,6 +214,8 @@ export class DenoTestController implements vscode.Disposable {
vscode.TestRunProfileKind.Run,
runHandler,
true,
undefined,
true,
);
// TODO(@kitsonk) add debug run profile
// TODO(@kitsonk) add coverage run profile
Expand Down Expand Up @@ -277,10 +299,11 @@ export class DenoTestController implements vscode.Disposable {
);

client.onNotification(testRunProgress, ({ id, message }) => {
const run = this.#runs.get(id);
if (!run) {
const runData = this.#runs.get(id);
if (!runData) {
return;
}
const { run } = runData;
switch (message.type) {
case "enqueued":
case "started":
Expand Down Expand Up @@ -317,6 +340,29 @@ export class DenoTestController implements vscode.Disposable {
run.appendOutput(value, loc, item);
break;
}
case "restart": {
const { enqueued } = message;
run.end();
const newRun = testController.createTestRun(
new vscode.TestRunRequest(
runData.request.include,
runData.request.exclude,
runData.request.profile,
true,
),
);
for (const { textDocument, ids } of enqueued) {
for (const id of ids) {
const item = getTestItem(testController, { textDocument, id });
if (!item) {
continue;
}
newRun.enqueued(item);
}
}
this.#runs.set(id, { run: newRun, request: runData.request });
break;
}
case "end": {
run.end();
this.#runs.delete(id);
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"deno"
],
"engines": {
"vscode": "^1.60.0"
"vscode": "^1.77.0"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this make a difference to the currently resolved version and is it essential? I'd like to avoid it because the TS plugin API communication has been brittle in the past

Copy link
Contributor Author

@stefnotch stefnotch Feb 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this bit is essential. It's what is required to get request.continuous and the final argument in

new vscode.TestRunRequest(
              runData.request.include,
              runData.request.exclude,
              runData.request.profile,
              true,
            ),

Without that, we don't have the typings for the continuous run feature in vscode.

I believe that 1.77.0 is also the minimal version bump to get access to said feature.

},
"activationEvents": [
"onLanguage:typescript",
Expand Down Expand Up @@ -257,7 +257,9 @@
"markdownDescription": "Additional environment variables to pass to Deno processes. Overrides the user's env and `deno.envFile`. These will be overridden by more specific settings such as `deno.future` for `DENO_FUTURE`, and invariables like `NO_COLOR=1`.",
"scope": "window",
"examples": [
{ "HTTP_PROXY": "http://localhost:8080" }
{
"HTTP_PROXY": "http://localhost:8080"
}
]
},
"deno.envFile": {
Expand Down Expand Up @@ -479,7 +481,11 @@
"scope": "resource"
},
"deno.trace.server": {
"enum": ["messages", "off", "verbose"],
"enum": [
"messages",
"off",
"verbose"
],
"default": "off",
"markdownDescription": "Traces the communication between VS Code and the Deno Language Server.",
"scope": "window"
Expand Down
2 changes: 1 addition & 1 deletion typescript-deno-plugin/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion typescript-deno-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"url": "https://github.com/denoland/vscode_deno"
},
"engines": {
"vscode": "^1.60.0"
"vscode": "^1.77.0"
},
"devDependencies": {
"typescript": "^5.0.2"
Expand Down
Loading