Skip to content

Commit 0a4bb37

Browse files
authored
Add support for running and debugging unit tests (#1269)
1 parent a432e02 commit 0a4bb37

File tree

11 files changed

+1344
-91
lines changed

11 files changed

+1344
-91
lines changed

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
}
4848
],
4949
"engines": {
50-
"vscode": "^1.75.0"
50+
"vscode": "^1.83.0"
5151
},
5252
"enabledApiProposals": [
5353
"fileSearchProvider",
@@ -1401,7 +1401,7 @@
14011401
"objectscript.compileFlags": {
14021402
"type": "string",
14031403
"default": "cuk",
1404-
"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)."
1404+
"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)."
14051405
},
14061406
"objectscript.overwriteServerChanges": {
14071407
"type": "boolean",
@@ -1526,6 +1526,43 @@
15261526
"description": "Controls whether a prompt to enable VS Code proposed APIs is shown when a server-side workspace folder is opened.",
15271527
"type": "boolean",
15281528
"default": true
1529+
},
1530+
"objectscript.unitTest.relativeTestRoots": {
1531+
"description": "Paths to where client-side test classes are stored. Relative to the workspace folder root.",
1532+
"type": "array",
1533+
"default": [],
1534+
"scope": "resource",
1535+
"items": {
1536+
"type": "string",
1537+
"pattern": "^([\\p{L}\\d_. -]+([\\/\\\\][\\p{L}\\d_. -]*))?$",
1538+
"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."
1539+
}
1540+
},
1541+
"objectscript.unitTest.autoload.folder": {
1542+
"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.",
1543+
"type": "string",
1544+
"default": "_autoload",
1545+
"scope": "resource",
1546+
"pattern": "^[\\p{L}\\d_. -]*$",
1547+
"patternErrorMessage": "Folder name can only contain letters, digits, space, hyphen ('-'), period ('.'), or underscore ('_')."
1548+
},
1549+
"objectscript.unitTest.autoload.xml": {
1550+
"description": "Controls whether the autoload feature loads XML files.",
1551+
"type": "boolean",
1552+
"default": true,
1553+
"scope": "resource"
1554+
},
1555+
"objectscript.unitTest.autoload.udl": {
1556+
"description": "Controls whether the autoload feature loads UDL files (cls, mac, int, inc).",
1557+
"type": "boolean",
1558+
"default": true,
1559+
"scope": "resource"
1560+
},
1561+
"objectscript.unitTest.showOutput": {
1562+
"description": "Controls whether unit test console output is shown.",
1563+
"type": "boolean",
1564+
"default": true,
1565+
"scope": "resource"
15291566
}
15301567
}
15311568
},
@@ -1686,7 +1723,7 @@
16861723
"test": "node ./out/test/runTest.js",
16871724
"lint": "eslint src/**",
16881725
"lint-fix": "eslint --fix src/**",
1689-
"download-api": "dts dev 1.75.0",
1726+
"download-api": "dts dev 1.83.0",
16901727
"postinstall": "npm run download-api"
16911728
},
16921729
"devDependencies": {
@@ -1695,7 +1732,7 @@
16951732
"@types/mocha": "^7.0.2",
16961733
"@types/node": "^14.18.0",
16971734
"@types/semver": "7.5.4",
1698-
"@types/vscode": "1.75.0",
1735+
"@types/vscode": "1.83.0",
16991736
"@types/ws": "8.5.4",
17001737
"@types/xmldom": "^0.1.29",
17011738
"@typescript-eslint/eslint-plugin": "^4.32.0",

src/api/atelier.d.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,12 @@ interface AsyncSearchRequest {
105105
console: false;
106106
}
107107

108-
export type AsyncRequest = AsyncCompileRequest | AsyncSearchRequest;
108+
interface AsyncUnitTestRequest {
109+
request: "unittest";
110+
tests: { class: string; methods?: string[] }[];
111+
load?: { file: string; content: string[] }[];
112+
console?: boolean;
113+
debug?: boolean;
114+
}
115+
116+
export type AsyncRequest = AsyncCompileRequest | AsyncSearchRequest | AsyncUnitTestRequest;

src/api/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -631,13 +631,13 @@ export class AtelierAPI {
631631
}
632632

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

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

643643
// v1+

src/commands/addServerNamespaceToWorkspace.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
FILESYSTEM_SCHEMA,
88
FILESYSTEM_READONLY_SCHEMA,
99
filesystemSchemas,
10+
smExtensionId,
1011
} from "../extension";
1112
import { cspAppsForUri, outputChannel } from "../utils";
1213
import { pickProject } from "./project";
@@ -164,7 +165,7 @@ export async function addServerNamespaceToWorkspace(resource?: vscode.Uri): Prom
164165
}
165166

166167
export async function getServerManagerApi(): Promise<any> {
167-
const targetExtension = vscode.extensions.getExtension("intersystems-community.servermanager");
168+
const targetExtension = vscode.extensions.getExtension(smExtensionId);
168169
if (!targetExtension) {
169170
return undefined;
170171
}

src/commands/connectFolderToServerNamespace.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as vscode from "vscode";
22
import { AtelierAPI } from "../api";
3-
import { panel, resolveConnectionSpec, getResolvedConnectionSpec } from "../extension";
3+
import { panel, resolveConnectionSpec, getResolvedConnectionSpec, smExtensionId } from "../extension";
44

55
interface ConnSettings {
66
server: string;
@@ -89,7 +89,7 @@ export async function connectFolderToServerNamespace(): Promise<void> {
8989
}
9090

9191
async function getServerManagerApi(): Promise<any> {
92-
const targetExtension = vscode.extensions.getExtension("intersystems-community.servermanager");
92+
const targetExtension = vscode.extensions.getExtension(smExtensionId);
9393
if (!targetExtension) {
9494
return undefined;
9595
}

0 commit comments

Comments
 (0)