Do not reregister watchers on every file change for qltests
During the qltest discovery, we were recreating the watchers for qltests on every file change. This was causing the watchers to be recreated on each change, while there were no functional changes to the watchers themselves. This commit moves the creation of the watchers to the constructor of the QLTestDiscovery class, and removes the creation of the watchers from the discover() method. The behavior should be the same.
This commit is contained in:
@@ -31,6 +31,15 @@ export class QLTestDiscovery extends Discovery {
|
||||
super("QL Test Discovery", extLogger);
|
||||
|
||||
this.push(this.watcher.onDidChange(this.handleDidChange, this));
|
||||
|
||||
// Watch for changes to any `.ql` or `.qlref` file in any of the QL packs that contain tests.
|
||||
this.watcher.addWatch(
|
||||
new RelativePattern(this.workspaceFolder.uri.fsPath, "**/*.{ql,qlref}"),
|
||||
);
|
||||
// need to explicitly watch for changes to directories themselves.
|
||||
this.watcher.addWatch(
|
||||
new RelativePattern(this.workspaceFolder.uri.fsPath, "**/"),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,15 +65,6 @@ export class QLTestDiscovery extends Discovery {
|
||||
protected async discover() {
|
||||
this._testDirectory = await this.discoverTests();
|
||||
|
||||
this.watcher.clear();
|
||||
// Watch for changes to any `.ql` or `.qlref` file in any of the QL packs that contain tests.
|
||||
this.watcher.addWatch(
|
||||
new RelativePattern(this.workspaceFolder.uri.fsPath, "**/*.{ql,qlref}"),
|
||||
);
|
||||
// need to explicitly watch for changes to directories themselves.
|
||||
this.watcher.addWatch(
|
||||
new RelativePattern(this.workspaceFolder.uri.fsPath, "**/"),
|
||||
);
|
||||
this._onDidChangeTests.fire(undefined);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user