Skip to content

Add support for running and debugging unit tests #1269

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

Merged
merged 4 commits into from
Jan 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
16 changes: 8 additions & 8 deletions package-lock.json

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

45 changes: 41 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
}
],
"engines": {
"vscode": "^1.75.0"
"vscode": "^1.83.0"
},
"enabledApiProposals": [
"fileSearchProvider",
Expand Down Expand Up @@ -1401,7 +1401,7 @@
"objectscript.compileFlags": {
"type": "string",
"default": "cuk",
"markdownDescription": "Compilation flags. Common compilation flags are ***b*** (compile dependent classes), ***k*** (keep generated source code) and ***u*** (skip related up-to-date documents). For descriptions of all available flags and qualifiers, click [here](https://docs.intersystems.com/irislatest/csp/docbook/Doc.View.cls?KEY=RCOS_vsystem#RCOS_vsystem_flags_qualifiers)."
"markdownDescription": "Compilation flags. Common compilation flags are ***b*** (compile dependent classes), ***k*** (keep generated source code) and ***u*** (skip related up-to-date documents). For descriptions of all available flags and qualifiers, click [here](https://docs.intersystems.com/irislatest/csp/docbook/Doc.View.cls?KEY=RCOS_vsystem_flags_qualifiers)."
},
"objectscript.overwriteServerChanges": {
"type": "boolean",
Expand Down Expand Up @@ -1526,6 +1526,43 @@
"description": "Controls whether a prompt to enable VS Code proposed APIs is shown when a server-side workspace folder is opened.",
"type": "boolean",
"default": true
},
"objectscript.unitTest.relativeTestRoots": {
"description": "Paths to where client-side test classes are stored. Relative to the workspace folder root.",
"type": "array",
"default": [],
"scope": "resource",
"items": {
"type": "string",
"pattern": "^([\\p{L}\\d_. -]+([\\/\\\\][\\p{L}\\d_. -]*))?$",
"patternErrorMessage": "Each folder name can only contain letters, digits, space, hyphen ('-'), period ('.'), or underscore ('_'), and the full path must neither begin nor end with a slash."
}
},
"objectscript.unitTest.autoload.folder": {
"markdownDescription": "When running client-side test classes, automatically load the contents of sub-directories with this name. See the [%UnitTest /autoload qualifier documentation](https://docs.intersystems.com/irislatest/csp/documatic/%25CSP.Documatic.cls?LIBRARY=%25SYS&CLASSNAME=%25UnitTest.Manager#RunTest) for details.",
"type": "string",
"default": "_autoload",
"scope": "resource",
"pattern": "^[\\p{L}\\d_. -]*$",
"patternErrorMessage": "Folder name can only contain letters, digits, space, hyphen ('-'), period ('.'), or underscore ('_')."
},
"objectscript.unitTest.autoload.xml": {
"description": "Controls whether the autoload feature loads XML files.",
"type": "boolean",
"default": true,
"scope": "resource"
},
"objectscript.unitTest.autoload.udl": {
"description": "Controls whether the autoload feature loads UDL files (cls, mac, int, inc).",
"type": "boolean",
"default": true,
"scope": "resource"
},
"objectscript.unitTest.showOutput": {
"description": "Controls whether unit test console output is shown.",
"type": "boolean",
"default": true,
"scope": "resource"
}
}
},
Expand Down Expand Up @@ -1686,7 +1723,7 @@
"test": "node ./out/test/runTest.js",
"lint": "eslint src/**",
"lint-fix": "eslint --fix src/**",
"download-api": "dts dev 1.75.0",
"download-api": "dts dev 1.83.0",
"postinstall": "npm run download-api"
},
"devDependencies": {
Expand All @@ -1695,7 +1732,7 @@
"@types/mocha": "^7.0.2",
"@types/node": "^14.18.0",
"@types/semver": "7.5.4",
"@types/vscode": "1.75.0",
"@types/vscode": "1.83.0",
"@types/ws": "8.5.4",
"@types/xmldom": "^0.1.29",
"@typescript-eslint/eslint-plugin": "^4.32.0",
Expand Down
10 changes: 9 additions & 1 deletion src/api/atelier.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,12 @@ interface AsyncSearchRequest {
console: false;
}

export type AsyncRequest = AsyncCompileRequest | AsyncSearchRequest;
interface AsyncUnitTestRequest {
request: "unittest";
tests: { class: string; methods?: string[] }[];
load?: { file: string; content: string[] }[];
console?: boolean;
debug?: boolean;
}

export type AsyncRequest = AsyncCompileRequest | AsyncSearchRequest | AsyncUnitTestRequest;
8 changes: 4 additions & 4 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -631,13 +631,13 @@ export class AtelierAPI {
}

// v1+
public queueAsync(request: Atelier.AsyncRequest): Promise<Atelier.Response> {
return this.request(1, "POST", `${this.ns}/work`, request);
public queueAsync(request: Atelier.AsyncRequest, noOutput = false): Promise<Atelier.Response> {
return this.request(1, "POST", `${this.ns}/work`, request, undefined, undefined, { noOutput });
}

// v1+
public pollAsync(id: string): Promise<Atelier.Response> {
return this.request(1, "GET", `${this.ns}/work/${id}`);
public pollAsync(id: string, noOutput = false): Promise<Atelier.Response> {
return this.request(1, "GET", `${this.ns}/work/${id}`, undefined, undefined, { noOutput });
}

// v1+
Expand Down
3 changes: 2 additions & 1 deletion src/commands/addServerNamespaceToWorkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
FILESYSTEM_SCHEMA,
FILESYSTEM_READONLY_SCHEMA,
filesystemSchemas,
smExtensionId,
} from "../extension";
import { cspAppsForUri, outputChannel } from "../utils";
import { pickProject } from "./project";
Expand Down Expand Up @@ -164,7 +165,7 @@ export async function addServerNamespaceToWorkspace(resource?: vscode.Uri): Prom
}

export async function getServerManagerApi(): Promise<any> {
const targetExtension = vscode.extensions.getExtension("intersystems-community.servermanager");
const targetExtension = vscode.extensions.getExtension(smExtensionId);
if (!targetExtension) {
return undefined;
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/connectFolderToServerNamespace.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as vscode from "vscode";
import { AtelierAPI } from "../api";
import { panel, resolveConnectionSpec, getResolvedConnectionSpec } from "../extension";
import { panel, resolveConnectionSpec, getResolvedConnectionSpec, smExtensionId } from "../extension";

interface ConnSettings {
server: string;
Expand Down Expand Up @@ -89,7 +89,7 @@ export async function connectFolderToServerNamespace(): Promise<void> {
}

async function getServerManagerApi(): Promise<any> {
const targetExtension = vscode.extensions.getExtension("intersystems-community.servermanager");
const targetExtension = vscode.extensions.getExtension(smExtensionId);
if (!targetExtension) {
return undefined;
}
Expand Down
Loading