[Code] try fix ts-lang shutdown unit test (#37618)

This commit is contained in:
Yulong 2019-09-03 16:51:35 +08:00 committed by GitHub
parent 049cf70e99
commit c429b0ba92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 11 deletions

View file

@ -18,4 +18,4 @@ JOB:
# - x-pack-visualRegression
# `~` is yaml for `null`
exclude: ~
exclude: ~

View file

@ -11,7 +11,7 @@ import { ConsoleLoggerFactory } from '../utils/console_logger_factory';
import { TYPESCRIPT } from './language_servers';
import { TypescriptServerLauncher } from './ts_launcher';
jest.setTimeout(10000);
jest.setTimeout(15000);
// @ts-ignore
const options: ServerOptions = createTestServerOption();
@ -29,13 +29,12 @@ function delay(seconds: number) {
});
}
test.skip('typescript language server could be shutdown', async () => {
test('typescript language server could be shutdown', async () => {
const tsLauncher = new TypescriptServerLauncher('localhost', options, new ConsoleLoggerFactory());
const proxy = await tsLauncher.launch(true, 1, TYPESCRIPT.embedPath!);
await proxy.initialize(options.workspacePath);
await delay(2);
expect(tsLauncher.running).toBeTruthy();
await proxy.initialize(options.workspacePath);
await proxy.exit();
await delay(2);
await delay(3);
expect(tsLauncher.running).toBeFalsy();
});

View file

@ -245,12 +245,7 @@ export class LanguageServerProxy implements ILanguageServerHandler {
}
private onSocketClosed() {
const conn = this.clientConnection;
this.clientConnection = null;
if (conn) {
conn.dispose();
}
this.eventEmitter.emit('close');
}

View file

@ -33,6 +33,8 @@ export class TypescriptServerLauncher extends AbstractLauncher {
return TS_LANG_DETACH_PORT;
}
protected startupTimeout = 5000;
createExpander(
proxy: LanguageServerProxy,
builtinWorkspace: boolean,