readdirRecursive returns backslash-separated paths on Windows whereas typespec expects forward slash separated paths. This PR normalizes them.
+9
-3
packages/emitter/test/integration.test.ts
+9
-3
packages/emitter/test/integration.test.ts
···
64
64
// Create a virtual main.tsp that imports all other files
65
65
const mainContent =
66
66
'import "@typelex/emitter";\n' +
67
-
tspFiles.map((f) => `import "./${f}";`).join("\n");
67
+
tspFiles.map((f) => `import "./${normalizePathToPosix(f)}";`).join("\n");
68
68
const filesWithMain = { ...inputFiles, "main.tsp": mainContent };
69
69
emitResult = await doEmit(filesWithMain, "main.tsp");
70
70
} else {
···
91
91
);
92
92
}
93
93
94
+
const normalizedExpectedPath = normalizePathToPosix(expectedPath);
95
+
94
96
assert.ok(
95
97
Object.prototype.hasOwnProperty.call(
96
98
emitResult.files,
97
-
expectedPath,
99
+
normalizedExpectedPath,
98
100
),
99
101
`Expected file ${expectedPath} was not produced`,
100
102
);
101
103
102
-
const actual = JSON.parse(emitResult.files[expectedPath]);
104
+
const actual = JSON.parse(emitResult.files[normalizedExpectedPath]);
103
105
const expected = JSON.parse(expectedFiles[expectedPath]);
104
106
assert.deepStrictEqual(actual, expected);
105
107
});
···
180
182
await walk(dir, "");
181
183
return result;
182
184
}
185
+
186
+
function normalizePathToPosix(thePath: string): string {
187
+
return thePath.replaceAll(path.sep, path.posix.sep);
188
+
}
+9
-3
packages/emitter/test/spec.test.ts
+9
-3
packages/emitter/test/spec.test.ts
···
64
64
// Create a virtual main.tsp that imports all other files
65
65
const mainContent =
66
66
'import "@typelex/emitter";\n' +
67
-
tspFiles.map((f) => `import "./${f}";`).join("\n");
67
+
tspFiles.map((f) => `import "./${normalizePathToPosix(f)}";`).join("\n");
68
68
const filesWithMain = { ...inputFiles, "main.tsp": mainContent };
69
69
emitResult = await doEmit(filesWithMain, "main.tsp");
70
70
} else {
···
91
91
);
92
92
}
93
93
94
+
const normalizedExpectedPath = normalizePathToPosix(expectedPath);
95
+
94
96
assert.ok(
95
97
Object.prototype.hasOwnProperty.call(
96
98
emitResult.files,
97
-
expectedPath,
99
+
normalizedExpectedPath,
98
100
),
99
101
`Expected file ${expectedPath} was not produced`,
100
102
);
101
103
102
-
const actual = JSON.parse(emitResult.files[expectedPath]);
104
+
const actual = JSON.parse(emitResult.files[normalizedExpectedPath]);
103
105
const expected = JSON.parse(expectedFiles[expectedPath]);
104
106
assert.deepStrictEqual(actual, expected);
105
107
});
···
180
182
await walk(dir, "");
181
183
return result;
182
184
}
185
+
186
+
function normalizePathToPosix(thePath: string): string {
187
+
return thePath.replaceAll(path.sep, path.posix.sep);
188
+
}
History
1 round
1 comment
maxine.puppykitty.racing
submitted
#0
1 commit
expand
collapse
Fix tests on Windows filesystems
expand 1 comment
pull request successfully merged
thanks!