提交 8ce52eb5 编写于 作者: B Benjamin Pasero

fix tests on windows

上级 f9a2ff4e
...@@ -40,6 +40,7 @@ export interface IConfigOptions<T> { ...@@ -40,6 +40,7 @@ export interface IConfigOptions<T> {
export class ConfigWatcher<T> implements IConfigWatcher<T>, IDisposable { export class ConfigWatcher<T> implements IConfigWatcher<T>, IDisposable {
private cache: T; private cache: T;
private parseErrors: json.ParseError[]; private parseErrors: json.ParseError[];
private disposed: boolean;
private loaded: boolean; private loaded: boolean;
private timeoutHandle: number; private timeoutHandle: number;
private disposables: IDisposable[]; private disposables: IDisposable[];
...@@ -140,6 +141,10 @@ export class ConfigWatcher<T> implements IConfigWatcher<T>, IDisposable { ...@@ -140,6 +141,10 @@ export class ConfigWatcher<T> implements IConfigWatcher<T>, IDisposable {
} }
private watch(path: string): void { 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); const watcher = fs.watch(path);
watcher.on('change', () => this.onConfigFileChange()); watcher.on('change', () => this.onConfigFileChange());
...@@ -201,6 +206,7 @@ export class ConfigWatcher<T> implements IConfigWatcher<T>, IDisposable { ...@@ -201,6 +206,7 @@ export class ConfigWatcher<T> implements IConfigWatcher<T>, IDisposable {
} }
public dispose(): void { public dispose(): void {
this.disposed = true;
this.disposables = dispose(this.disposables); this.disposables = dispose(this.disposables);
} }
} }
\ No newline at end of file
...@@ -130,6 +130,8 @@ suite('Config', () => { ...@@ -130,6 +130,8 @@ suite('Config', () => {
assert.equal(watcher.getConfig().foo, 'changed'); assert.equal(watcher.getConfig().foo, 'changed');
assert.equal(watcher.getValue('foo'), 'changed'); assert.equal(watcher.getValue('foo'), 'changed');
watcher.dispose();
cleanUp(done); cleanUp(done);
}); });
}, 50); }, 50);
......
...@@ -28,7 +28,7 @@ class SettingsTestEnvironmentService extends EnvironmentService { ...@@ -28,7 +28,7 @@ class SettingsTestEnvironmentService extends EnvironmentService {
get appSettingsPath(): string { return this.customAppSettingsHome; } get appSettingsPath(): string { return this.customAppSettingsHome; }
} }
suite('pasero', () => { suite('ConfigurationService - Node', () => {
function testFile(callback: (path: string, cleanUp: (callback: () => void) => void) => void): void { function testFile(callback: (path: string, cleanUp: (callback: () => void) => void) => void): void {
const id = uuid.generateUuid(); const id = uuid.generateUuid();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册