Skip to content

Commit 06f4454

Browse files
committed
test(linter/plugins): fix tests on Windows (#15966)
#15911 broke NAPI tests on Windows, because it failed to replace `\` with `/` in file paths in snapshots. https://github.com/oxc-project/oxc/actions/runs/19581028169/job/56078684915#step:8:479 Fix this by normalizing slashes in file paths before outputting them in snapshots.
1 parent 6c72e84 commit 06f4454

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

apps/oxlint/test/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ interface TestFixtureOptions {
9191
* @param options - Options for running the test
9292
*/
9393
export async function testFixtureWithCommand(options: TestFixtureOptions): Promise<void> {
94-
const { name: fixtureName, dirPath } = options.fixture;
94+
const { name: fixtureName, dirPath } = options.fixture,
95+
pathPrefixLen = dirPath.length + 1;
9596

9697
// Read all the files in fixture's directory
9798
const fileObjs = await fs.readdir(dirPath, { withFileTypes: true, recursive: true });
@@ -102,7 +103,7 @@ export async function testFixtureWithCommand(options: TestFixtureOptions): Promi
102103
if (fileObj.isFile()) {
103104
const path = pathJoin(fileObj.parentPath, fileObj.name);
104105
files.push({
105-
filename: path.slice(dirPath.length + 1),
106+
filename: normalizeSlashes(path.slice(pathPrefixLen)),
106107
code: await fs.readFile(path, 'utf8'),
107108
});
108109
}

0 commit comments

Comments
 (0)