Skip to content

Commit

Permalink
Remove task reference and reduce timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
badsyntax committed May 19, 2020
1 parent ea59cb2 commit 6b078fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions extension/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ export interface ServerOptions {
}

export class GradleTasksServer implements vscode.Disposable {
private task?: vscode.Task;
private taskExecution?: Thenable<vscode.TaskExecution>;
private taskExecution?: vscode.TaskExecution;
private _onReady: vscode.EventEmitter<null> = new vscode.EventEmitter<null>();
private _onStop: vscode.EventEmitter<null> = new vscode.EventEmitter<null>();
private isRestarting = false;
Expand All @@ -42,7 +41,6 @@ export class GradleTasksServer implements vscode.Disposable {
logger.info(
localize('server.gradleServerStopped', 'Gradle server stopped')
);
this.task = undefined;
this.taskExecution = undefined;
this.showRestartMessage();
}
Expand All @@ -58,16 +56,16 @@ export class GradleTasksServer implements vscode.Disposable {
} else {
this.port = await getPort();
const cwd = this.context.asAbsolutePath('lib');
this.task = buildGradleServerTask(SERVER_TASK_NAME, cwd, [
const task = buildGradleServerTask(SERVER_TASK_NAME, cwd, [
String(this.port),
]);
logger.debug('Starting server');
this.taskExecution = vscode.tasks.executeTask(this.task);
this.taskExecution = await vscode.tasks.executeTask(task);
}
}

public isStarted(): boolean {
return this.task !== undefined;
return this.taskExecution !== undefined;
}

public async showRestartMessage(): Promise<void> {
Expand All @@ -89,7 +87,7 @@ export class GradleTasksServer implements vscode.Disposable {
localize('server.gradleServerRestarting', 'Restarting gradle server')
);
if (!this.isRestarting) {
if (this.task) {
if (this.taskExecution) {
this.isRestarting = true;
const disposable = vscode.tasks.onDidEndTaskProcess((event) => {
if (event.execution.task.name === SERVER_TASK_NAME) {
Expand All @@ -98,7 +96,7 @@ export class GradleTasksServer implements vscode.Disposable {
this.start();
}
});
this.taskExecution?.then((execution) => execution.terminate());
this.taskExecution?.terminate();
} else {
this.start();
}
Expand All @@ -113,7 +111,7 @@ export class GradleTasksServer implements vscode.Disposable {
}

public dispose(): void {
this.taskExecution?.then((execution) => execution.terminate());
this.taskExecution?.terminate();
this._onReady.dispose();
this._onStop.dispose();
}
Expand Down
2 changes: 1 addition & 1 deletion extension/src/test/testUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function createTestRunner(pattern: string) {
// Create the mocha test
const mocha = new Mocha({
ui: 'bdd',
timeout: 90000,
timeout: 60000,
color: true,
});
mocha.bail(true);
Expand Down

0 comments on commit 6b078fa

Please sign in to comment.