Skip to content

Commit bac91e5

Browse files
committed
Advise when /_vscode webapp is missing
1 parent 50fa7be commit bac91e5

1 file changed

Lines changed: 28 additions & 13 deletions

File tree

src/commonRunTestsHandler.ts

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as vscode from 'vscode';
22
import { allTestRuns, extensionId, IServerSpec, osAPI } from './extension';
33
import { relativeTestRoot } from './localTests';
44
import logger from './logger';
5+
import { makeRESTRequest } from './makeRESTRequest';
56

67
export async function commonRunTestsHandler(controller: vscode.TestController, resolveItemChildren: (item: vscode.TestItem) => Promise<void>, request: vscode.TestRunRequest, cancellation: vscode.CancellationToken) {
78
logger.info(`commonRunTestsHandler invoked by controller id=${controller.id}`);
@@ -71,7 +72,7 @@ export async function commonRunTestsHandler(controller: vscode.TestController, r
7172
return;
7273
}
7374

74-
// Stop debugging sessions we started
75+
// Arrange for cancellation to stop the debugging sessions we start
7576
cancellation.onCancellationRequested(() => {
7677
runIndices.forEach((runIndex) => {
7778
const session = allTestRuns[runIndex]?.debugSession;
@@ -99,7 +100,32 @@ export async function commonRunTestsHandler(controller: vscode.TestController, r
99100
// First, clear out the server-side folder for the classes whose testmethods will be run
100101
const folder = vscode.workspace.getWorkspaceFolder(oneUri);
101102
const server = osAPI.serverForUri(oneUri);
102-
const username = server.username || 'UnknownUser';
103+
const serverSpec: IServerSpec = {
104+
username: server.username,
105+
name: server.serverName,
106+
webServer: {
107+
host: server.host,
108+
port: server.port,
109+
pathPrefix: server.pathPrefix,
110+
scheme: server.scheme
111+
}
112+
};
113+
const namespace: string = server.namespace.toUpperCase();
114+
const responseCspapps = await makeRESTRequest(
115+
"GET",
116+
serverSpec,
117+
{ apiVersion: 1, namespace: "%SYS", path: "/cspapps/%SYS" }
118+
);
119+
120+
if (!responseCspapps?.data?.result?.content?.includes("/_vscode")) {
121+
const reply = await vscode.window.showErrorMessage(`A '/_vscode' web application must be configured for the %SYS namespace of server '${serverSpec.name}'. The ${namespace} namespace also requires its ^UnitTestRoot global to point to the '${namespace}/UnitTestRoot' subfolder of that web application's path.`, { modal: true }, 'Instructions');
122+
if (reply === 'Instructions') {
123+
vscode.commands.executeCommand('vscode.open', 'https://intersystems-community.github.io/vscode-objectscript/serverside/#configuring-storage-for-folder-specific-settings');
124+
}
125+
return;
126+
}
127+
128+
const username: string = server.username || 'UnknownUser';
103129
const testRoot = vscode.Uri.from({ scheme: 'isfs', authority, path: `/.vscode/UnitTestRoot/${username}` });
104130
try {
105131
// Limitation of the Atelier API means this can only delete the files, not the folders
@@ -134,17 +160,6 @@ export async function commonRunTestsHandler(controller: vscode.TestController, r
134160
}
135161

136162
// Finally, run the tests using the debugger API
137-
const serverSpec: IServerSpec = {
138-
username: server.username,
139-
name: server.serverName,
140-
webServer: {
141-
host: server.host,
142-
port: server.port,
143-
pathPrefix: server.pathPrefix,
144-
scheme: server.scheme
145-
}
146-
};
147-
const namespace: string = server.namespace.toUpperCase();
148163
const runQualifiers = controller.id === `${extensionId}-Local` ? "" : "/noload/nodelete";
149164
// Run tests through the debugger but only stop at breakpoints etc if user chose "Debug Test" instead of "Run Test"
150165
const runIndex = allTestRuns.push(run) - 1;

0 commit comments

Comments
 (0)