未验证 提交 31a15b5b 编写于 作者: A Alex Dima

Add command to kill server and trigger handled error

上级 23be24d8
......@@ -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": {
......
......@@ -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();
......
......@@ -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 };
}
\ No newline at end of file
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册