mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
testresolver: kill server process, more settings
This commit is contained in:
@@ -43,11 +43,6 @@
|
|||||||
"category": "Remote-TestResolver",
|
"category": "Remote-TestResolver",
|
||||||
"command": "vscode-testresolver.newWindow"
|
"command": "vscode-testresolver.newWindow"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"title": "New Window with Error",
|
|
||||||
"category": "Remote-TestResolver",
|
|
||||||
"command": "vscode-testresolver.newWindowWithError"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"title": "Show Log",
|
"title": "Show Log",
|
||||||
"category": "Remote-TestResolver",
|
"category": "Remote-TestResolver",
|
||||||
@@ -61,11 +56,6 @@
|
|||||||
"when": "!remoteAuthority",
|
"when": "!remoteAuthority",
|
||||||
"group": "9_local_testresolver@2"
|
"group": "9_local_testresolver@2"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"command": "vscode-testresolver.newWindowWithError",
|
|
||||||
"when": "!remoteAuthority",
|
|
||||||
"group": "9_local_testresolver@3"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"command": "vscode-testresolver.showLog",
|
"command": "vscode-testresolver.showLog",
|
||||||
"when": "remoteAuthority =~ /^test\\+.*$/",
|
"when": "remoteAuthority =~ /^test\\+.*$/",
|
||||||
@@ -75,13 +65,22 @@
|
|||||||
"command": "vscode-testresolver.newWindow",
|
"command": "vscode-testresolver.newWindow",
|
||||||
"when": "remoteAuthority =~ /^test\\+.*$/",
|
"when": "remoteAuthority =~ /^test\\+.*$/",
|
||||||
"group": "1_remote_testresolver_open@1"
|
"group": "1_remote_testresolver_open@1"
|
||||||
},
|
|
||||||
{
|
|
||||||
"command": "vscode-testresolver.newWindowWithError",
|
|
||||||
"when": "remoteAuthority =~ /^test\\+.*$/",
|
|
||||||
"group": "1_remote_testresolver_open@2"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"configuration": {
|
||||||
|
"properties": {
|
||||||
|
"testresolver.startupDelay": {
|
||||||
|
"description": "If set, the resolver will delay for the given amount of seconds. Use ths setting for testing a slow resolver",
|
||||||
|
"type": "number",
|
||||||
|
"default": 0
|
||||||
|
},
|
||||||
|
"testresolver.startupError": {
|
||||||
|
"description": "If set, the resolver will fail. Use ths setting for testing the failure of a resolver.",
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,9 +60,19 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const delay = vscode.workspace.getConfiguration('testresolver').get('startupDelay');
|
||||||
|
if (typeof delay === 'number') {
|
||||||
|
let remaining = Math.ceil(delay);
|
||||||
|
outputChannel.append(`Delaying startup by ${remaining} seconds (configured by "testresolver.startupDelay").`);
|
||||||
|
while (remaining > 0) {
|
||||||
|
progress.report({ message: `Delayed resolving: Remaining ${remaining}s` });
|
||||||
|
await (sleep(1000));
|
||||||
|
remaining--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_authority === 'test+error' || vscode.workspace.getConfiguration('testresolver').get('error') === true) {
|
if (vscode.workspace.getConfiguration('testresolver').get('startupError') === true) {
|
||||||
processError('Unable to start the Test Resolver.');
|
processError('Test Resolver failed for testing purposes (configured by "testresolver.startupError").');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,19 +87,32 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
if (!commit) { // dev mode
|
if (!commit) { // dev mode
|
||||||
const vscodePath = path.resolve(path.join(context.extensionPath, '..', '..'));
|
const vscodePath = path.resolve(path.join(context.extensionPath, '..', '..'));
|
||||||
const serverCommandPath = path.join(vscodePath, 'resources', 'server', 'bin-dev', serverCommand);
|
const serverCommandPath = path.join(vscodePath, 'resources', 'server', 'bin-dev', serverCommand);
|
||||||
extHostProcess = cp.spawn(serverCommandPath, commandArgs, { env, cwd: vscodePath });
|
extHostProcess = cp.spawn(serverCommandPath, commandArgs, { env, cwd: vscodePath, detached: true });
|
||||||
} else {
|
} else {
|
||||||
const serverBin = path.join(remoteDataDir, 'bin');
|
const serverBin = path.join(remoteDataDir, 'bin');
|
||||||
progress.report({ message: 'Installing VSCode Server' });
|
progress.report({ message: 'Installing VSCode Server' });
|
||||||
const serverLocation = await downloadAndUnzipVSCodeServer(updateUrl, commit, quality, serverBin);
|
const serverLocation = await downloadAndUnzipVSCodeServer(updateUrl, commit, quality, serverBin);
|
||||||
outputChannel.appendLine(`Using server build at ${serverLocation}`);
|
outputChannel.appendLine(`Using server build at ${serverLocation}`);
|
||||||
|
|
||||||
extHostProcess = cp.spawn(path.join(serverLocation, serverCommand), commandArgs, { env, cwd: serverLocation });
|
extHostProcess = cp.spawn(path.join(serverLocation, serverCommand), commandArgs, { env, cwd: serverLocation, detached: true });
|
||||||
}
|
}
|
||||||
extHostProcess.stdout.on('data', (data: Buffer) => processOutput(data.toString()));
|
extHostProcess.stdout.on('data', (data: Buffer) => processOutput(data.toString()));
|
||||||
extHostProcess.stderr.on('data', (data: Buffer) => processOutput(data.toString()));
|
extHostProcess.stderr.on('data', (data: Buffer) => processOutput(data.toString()));
|
||||||
extHostProcess.on('error', (error: Error) => processError(`server failed with error:\n${error.message}`));
|
extHostProcess.on('error', (error: Error) => {
|
||||||
extHostProcess.on('close', (code: number) => processError(`server closed unexpectedly.\nError code: ${code}`));
|
processError(`server failed with error:\n${error.message}`);
|
||||||
|
extHostProcess = undefined;
|
||||||
|
});
|
||||||
|
extHostProcess.on('close', (code: number) => {
|
||||||
|
processError(`server closed unexpectedly.\nError code: ${code}`);
|
||||||
|
extHostProcess = undefined;
|
||||||
|
});
|
||||||
|
context.subscriptions.push({
|
||||||
|
dispose: () => {
|
||||||
|
if (extHostProcess) {
|
||||||
|
process.kill(-extHostProcess.pid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,8 +191,8 @@ function getNewEnv(): { [x: string]: string | undefined } {
|
|||||||
return env;
|
return env;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function deactivate() {
|
function sleep(ms: number): Promise<void> {
|
||||||
if (extHostProcess) {
|
return new Promise(resolve => {
|
||||||
extHostProcess.kill();
|
setTimeout(resolve, ms);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user