Skip to content

Commit 8d1dfad

Browse files
committed
More fine grained file check
1 parent 6f86106 commit 8d1dfad

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

test/suite/extension.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,16 @@ async function deleteWorkspaceFiles() {
4444
suite('Extension Test Suite', () => {
4545
const disposables: vscode.Disposable[] = [];
4646

47-
async function existsWorkspaceFile(pattern: string) {
47+
async function existsWorkspaceFile(pattern: string, pred?: (uri: vscode.Uri) => boolean) {
4848
const relPath: vscode.RelativePattern = new vscode.RelativePattern(getWorkspaceRoot(), pattern);
4949
const watcher = vscode.workspace.createFileSystemWatcher(relPath);
5050
disposables.push(watcher);
5151
return new Promise<vscode.Uri>((resolve) => {
5252
watcher.onDidCreate((uri) => {
5353
console.log(`Created: ${uri}`);
54-
resolve(uri);
54+
if (!pred || pred(uri)) {
55+
resolve(uri);
56+
}
5557
});
5658
});
5759
}
@@ -80,14 +82,15 @@ suite('Extension Test Suite', () => {
8082
await vscode.workspace.openTextDocument(getWorkspaceFile('Main.hs'));
8183
const exeExt = os.platform.toString() === 'win32' ? '.exe' : '';
8284
console.log('Testing wrapper');
85+
const pred = (uri: vscode.Uri) => !['download', 'gz', 'zip'].includes(path.extname(uri.fsPath));
8386
assert.ok(
84-
await withTimeout(30, existsWorkspaceFile(`bin/haskell-language-server-wrapper*${exeExt}[!.]`)),
87+
await withTimeout(30, existsWorkspaceFile(`bin/haskell-language-server-wrapper*${exeExt}`, pred)),
8588
'The wrapper executable was not downloaded in 30 seconds'
8689
);
8790
console.log('Testing server');
8891
assert.ok(
89-
await withTimeout(60, existsWorkspaceFile(`bin/haskell-language-server-[1-9]*${exeExt}[!.]`)),
90-
'The server executable was not downloaded in 30 seconds'
92+
await withTimeout(60, existsWorkspaceFile(`bin/haskell-language-server-[1-9]*${exeExt}`, pred)),
93+
'The server executable was not downloaded in 60 seconds'
9194
);
9295
});
9396

0 commit comments

Comments
 (0)