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

feat: allow --inspect-wait when debugging test #893

Merged
merged 1 commit into from
Aug 25, 2023
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
11 changes: 8 additions & 3 deletions client/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ import * as tasks from "./tasks";
import { DenoTestController, TestingFeature } from "./testing";
import type { DenoExtensionContext, TestCommandOptions } from "./types";
import { WelcomePanel } from "./welcome";
import { assert, getDenoCommandName, getDenoCommandPath } from "./util";
import {
assert,
getDenoCommandName,
getDenoCommandPath,
getInspectArg,
} from "./util";
import { registryState } from "./lsp_extensions";
import { createRegistryStateHandler } from "./notification_handlers";
import { DenoServerInfo } from "./server_info";
Expand Down Expand Up @@ -284,7 +289,7 @@ export function status(

export function test(
_context: vscode.ExtensionContext,
_extensionContext: DenoExtensionContext,
extensionContext: DenoExtensionContext,
): Callback {
return async (uriStr: string, name: string, options: TestCommandOptions) => {
const uri = vscode.Uri.parse(uriStr, true);
Expand All @@ -297,7 +302,7 @@ export function test(
testArgs.push("--unstable");
}
if (options?.inspect) {
testArgs.push("--inspect-brk");
testArgs.push(getInspectArg(extensionContext.serverInfo?.version));
}
if (!testArgs.includes("--import-map")) {
const importMap: string | undefined | null = config.get("importMap");
Expand Down
15 changes: 3 additions & 12 deletions client/src/debug_config_provider.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.

import type { DenoExtensionContext } from "./types";
import { getDenoCommandName } from "./util";
import * as semver from "semver";
import * as vscode from "vscode";
import type { DenoExtensionContext } from "./types";
import { getDenoCommandName, getInspectArg } from "./util";

export class DenoDebugConfigurationProvider
implements vscode.DebugConfigurationProvider {
Expand Down Expand Up @@ -34,15 +33,7 @@ export class DenoDebugConfigurationProvider
}

#getInspectArg() {
const version = this.#extensionContext.serverInfo?.version;

if (
version && semver.valid(version) && semver.satisfies(version, ">=1.29.0")
) {
return "--inspect-wait";
} else {
return "--inspect-brk";
}
return getInspectArg(this.#extensionContext.serverInfo?.version);
}

constructor(extensionContext: DenoExtensionContext) {
Expand Down
12 changes: 12 additions & 0 deletions client/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as fs from "fs";
import * as os from "os";
import * as path from "path";
import * as process from "process";
import * as semver from "semver";
import * as vscode from "vscode";

/** Assert that the condition is "truthy", otherwise throw. */
Expand Down Expand Up @@ -114,3 +115,14 @@ function fileExists(executableFilePath: string): Promise<boolean> {
return false;
});
}

export function getInspectArg(denoVersion?: string) {
if (
denoVersion && semver.valid(denoVersion) &&
semver.satisfies(denoVersion, ">=1.29.0")
) {
return "--inspect-wait";
} else {
return "--inspect-brk";
}
}