Skip to content

Commit e08a261

Browse files
committed
Move file watchers to test suite scope
1 parent 56e0aea commit e08a261

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

test/suite/extension.test.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import * as os from 'os';
44
import * as path from 'path';
55
import { TextEncoder } from 'util';
66
import * as vscode from 'vscode';
7-
import { Disposable } from 'vscode-languageserver-protocol';
87
import { CommandNames } from '../../src/commands/constants';
98

109
function getExtension() {
@@ -32,21 +31,21 @@ function getWorkspaceFile(name: string) {
3231
return wsroot.with({ path: path.posix.join(wsroot.path, name) });
3332
}
3433

35-
const disposables: Disposable[] = [];
34+
suite('Extension Test Suite', () => {
35+
const disposables: vscode.Disposable[] = [];
3636

37-
async function existsWorkspaceFile(pattern: string) {
38-
return new Promise<vscode.Uri>((resolve) => {
39-
const pat: vscode.RelativePattern = new vscode.RelativePattern(getWorkspaceRoot(), pattern);
40-
console.log(`Creating file system watcher for ${pat}`);
41-
const watcher = vscode.workspace.createFileSystemWatcher(pat).onDidCreate((uri) => {
42-
console.log(`Created: ${uri}`);
43-
resolve(uri);
44-
});
37+
async function existsWorkspaceFile(pattern: string) {
38+
const relPath: vscode.RelativePattern = new vscode.RelativePattern(getWorkspaceRoot(), pattern);
39+
const watcher = vscode.workspace.createFileSystemWatcher(relPath);
4540
disposables.push(watcher);
46-
});
47-
}
41+
return new Promise<vscode.Uri>((resolve) => {
42+
watcher.onDidCreate((uri) => {
43+
console.log(`Created: ${uri}`);
44+
resolve(uri);
45+
});
46+
});
47+
}
4848

49-
suite('Extension Test Suite', () => {
5049
vscode.window.showInformationMessage('Start all tests.');
5150

5251
suiteSetup(async () => {
@@ -66,13 +65,15 @@ suite('Extension Test Suite', () => {
6665
assert.ok(true);
6766
});
6867

69-
test('Server executables should be downloaded', async () => {
68+
test('HLS executables should be downloaded', async () => {
7069
await vscode.workspace.openTextDocument(getWorkspaceFile('Main.hs'));
7170
const exeExt = os.platform.toString() === 'win32' ? '.exe' : '';
71+
console.log('Testing wrapper');
7272
assert.ok(
7373
await withTimeout(30, existsWorkspaceFile(`bin/haskell-language-server-wrapper${exeExt}`)),
7474
'The wrapper executable was not downloaded in 30 seconds'
7575
);
76+
console.log('Testing server');
7677
assert.ok(
7778
await withTimeout(60, existsWorkspaceFile(`bin/haskell-language-server${exeExt}`)),
7879
'The server executable was not downloaded in 30 seconds'

0 commit comments

Comments
 (0)