Add command to kill server and trigger handled error

This commit is contained in:
Alex Dima 2021-01-13 20:45:27 +01:00
parent 23be24d828
commit 31a15b5b9a
No known key found for this signature in database
GPG key ID: 6E58D7B045760DA0
3 changed files with 19 additions and 3 deletions

View file

@ -47,6 +47,11 @@
"title": "Show Log",
"category": "Remote-TestResolver",
"command": "vscode-testresolver.showLog"
},
{
"title": "Kill Server and Trigger Handled Error",
"category": "Remote-TestResolver",
"command": "vscode-testresolver.killServerAndTriggerHandledError"
}
],
"menus": {

View file

@ -206,7 +206,7 @@ export function activate(context: vscode.ExtensionContext) {
});
}
vscode.workspace.registerRemoteAuthorityResolver('test', {
const authorityResolverDisposable = vscode.workspace.registerRemoteAuthorityResolver('test', {
resolve(_authority: string): Thenable<vscode.ResolvedAuthority> {
return vscode.window.withProgress({
location: vscode.ProgressLocation.Notification,
@ -222,6 +222,17 @@ export function activate(context: vscode.ExtensionContext) {
vscode.commands.registerCommand('vscode-testresolver.newWindowWithError', () => {
return vscode.commands.executeCommand('vscode.newWindow', { remoteAuthority: 'test+error' });
});
vscode.commands.registerCommand('vscode-testresolver.killServerAndTriggerHandledError', () => {
authorityResolverDisposable.dispose();
if (extHostProcess) {
terminateProcess(extHostProcess, context.extensionPath);
}
vscode.workspace.registerRemoteAuthorityResolver('test', {
async resolve(_authority: string): Promise<vscode.ResolvedAuthority> {
throw vscode.RemoteAuthorityResolverError.NotAvailable('Intentional Error', true);
}
});
});
vscode.commands.registerCommand('vscode-testresolver.showLog', () => {
if (outputChannel) {
outputChannel.show();

View file

@ -23,7 +23,7 @@ export function terminateProcess(p: cp.ChildProcess, extensionPath: string): Ter
} else if (process.platform === 'darwin' || process.platform === 'linux') {
try {
const cmd = path.join(extensionPath, 'scripts', 'terminateProcess.sh');
const result = cp.spawnSync(cmd, [process.pid.toString()]);
const result = cp.spawnSync(cmd, [p.pid.toString()]);
if (result.error) {
return { success: false, error: result.error };
}
@ -34,4 +34,4 @@ export function terminateProcess(p: cp.ChildProcess, extensionPath: string): Ter
p.kill('SIGKILL');
}
return { success: true };
}
}