Skip to content

Commit 68c8483

Browse files
Copilotgarrytrinder
andcommitted
Harden fixture path lookup for Windows test runner
Co-authored-by: garrytrinder <11563347+garrytrinder@users.noreply.github.com>
1 parent d08b6ac commit 68c8483

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/test/helpers.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as fs from 'fs';
12
import * as path from 'path';
23
import * as vscode from 'vscode';
34
import { DevProxyInstall } from '../types';
@@ -8,8 +9,20 @@ import { DevProxyInstall } from '../types';
89
* avoiding the need to copy them to out/ during build.
910
*/
1011
export function getFixturePath(fileName: string): string {
11-
const workspaceRoot = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath ?? process.cwd();
12-
return path.resolve(workspaceRoot, 'src', 'test', 'examples', fileName);
12+
const candidateRoots = [
13+
process.cwd(),
14+
path.resolve(__dirname, '..', '..'),
15+
vscode.workspace.workspaceFolders?.[0]?.uri.fsPath,
16+
].filter((root): root is string => Boolean(root));
17+
18+
for (const root of candidateRoots) {
19+
const fixturePath = path.resolve(root, 'src', 'test', 'examples', fileName);
20+
if (fs.existsSync(fixturePath)) {
21+
return fixturePath;
22+
}
23+
}
24+
25+
return path.resolve(process.cwd(), 'src', 'test', 'examples', fileName);
1326
}
1427

1528
/**

0 commit comments

Comments
 (0)