From 8ce52eb57f7856b88f1d62572ff6403467934d62 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Mon, 22 Aug 2016 18:04:33 +0200 Subject: [PATCH] fix tests on windows --- src/vs/base/node/config.ts | 6 ++++++ src/vs/base/test/node/config.test.ts | 2 ++ .../configuration/test/node/configurationService.test.ts | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/vs/base/node/config.ts b/src/vs/base/node/config.ts index 46b7cad4214..f4f9301b12c 100644 --- a/src/vs/base/node/config.ts +++ b/src/vs/base/node/config.ts @@ -40,6 +40,7 @@ export interface IConfigOptions { export class ConfigWatcher implements IConfigWatcher, IDisposable { private cache: T; private parseErrors: json.ParseError[]; + private disposed: boolean; private loaded: boolean; private timeoutHandle: number; private disposables: IDisposable[]; @@ -140,6 +141,10 @@ export class ConfigWatcher implements IConfigWatcher, IDisposable { } private watch(path: string): void { + if (this.disposed) { + return; // avoid watchers that will never get disposed by checking for being disposed + } + const watcher = fs.watch(path); watcher.on('change', () => this.onConfigFileChange()); @@ -201,6 +206,7 @@ export class ConfigWatcher implements IConfigWatcher, IDisposable { } public dispose(): void { + this.disposed = true; this.disposables = dispose(this.disposables); } } \ No newline at end of file diff --git a/src/vs/base/test/node/config.test.ts b/src/vs/base/test/node/config.test.ts index e4651c215d1..36d83d7bdae 100644 --- a/src/vs/base/test/node/config.test.ts +++ b/src/vs/base/test/node/config.test.ts @@ -130,6 +130,8 @@ suite('Config', () => { assert.equal(watcher.getConfig().foo, 'changed'); assert.equal(watcher.getValue('foo'), 'changed'); + watcher.dispose(); + cleanUp(done); }); }, 50); diff --git a/src/vs/platform/configuration/test/node/configurationService.test.ts b/src/vs/platform/configuration/test/node/configurationService.test.ts index a9e0bab1af1..662ffa1d2fe 100644 --- a/src/vs/platform/configuration/test/node/configurationService.test.ts +++ b/src/vs/platform/configuration/test/node/configurationService.test.ts @@ -28,7 +28,7 @@ class SettingsTestEnvironmentService extends EnvironmentService { get appSettingsPath(): string { return this.customAppSettingsHome; } } -suite('pasero', () => { +suite('ConfigurationService - Node', () => { function testFile(callback: (path: string, cleanUp: (callback: () => void) => void) => void): void { const id = uuid.generateUuid(); -- GitLab