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
// Create a virtual main.tsp that imports all other files
65
const mainContent =
66
'import "@typelex/emitter";\n' +
67
-
tspFiles.map((f) => `import "./${f}";`).join("\n");
68
const filesWithMain = { ...inputFiles, "main.tsp": mainContent };
69
emitResult = await doEmit(filesWithMain, "main.tsp");
70
} else {
···
91
);
92
}
93
94
assert.ok(
95
Object.prototype.hasOwnProperty.call(
96
emitResult.files,
97
-
expectedPath,
98
),
99
`Expected file ${expectedPath} was not produced`,
100
);
101
102
-
const actual = JSON.parse(emitResult.files[expectedPath]);
103
const expected = JSON.parse(expectedFiles[expectedPath]);
104
assert.deepStrictEqual(actual, expected);
105
});
···
180
await walk(dir, "");
181
return result;
182
}
···
64
// Create a virtual main.tsp that imports all other files
65
const mainContent =
66
'import "@typelex/emitter";\n' +
67
+
tspFiles.map((f) => `import "./${normalizePathToPosix(f)}";`).join("\n");
68
const filesWithMain = { ...inputFiles, "main.tsp": mainContent };
69
emitResult = await doEmit(filesWithMain, "main.tsp");
70
} else {
···
91
);
92
}
93
94
+
const normalizedExpectedPath = normalizePathToPosix(expectedPath);
95
+
96
assert.ok(
97
Object.prototype.hasOwnProperty.call(
98
emitResult.files,
99
+
normalizedExpectedPath,
100
),
101
`Expected file ${expectedPath} was not produced`,
102
);
103
104
+
const actual = JSON.parse(emitResult.files[normalizedExpectedPath]);
105
const expected = JSON.parse(expectedFiles[expectedPath]);
106
assert.deepStrictEqual(actual, expected);
107
});
···
182
await walk(dir, "");
183
return result;
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
// Create a virtual main.tsp that imports all other files
65
const mainContent =
66
'import "@typelex/emitter";\n' +
67
-
tspFiles.map((f) => `import "./${f}";`).join("\n");
68
const filesWithMain = { ...inputFiles, "main.tsp": mainContent };
69
emitResult = await doEmit(filesWithMain, "main.tsp");
70
} else {
···
91
);
92
}
93
94
assert.ok(
95
Object.prototype.hasOwnProperty.call(
96
emitResult.files,
97
-
expectedPath,
98
),
99
`Expected file ${expectedPath} was not produced`,
100
);
101
102
-
const actual = JSON.parse(emitResult.files[expectedPath]);
103
const expected = JSON.parse(expectedFiles[expectedPath]);
104
assert.deepStrictEqual(actual, expected);
105
});
···
180
await walk(dir, "");
181
return result;
182
}
···
64
// Create a virtual main.tsp that imports all other files
65
const mainContent =
66
'import "@typelex/emitter";\n' +
67
+
tspFiles.map((f) => `import "./${normalizePathToPosix(f)}";`).join("\n");
68
const filesWithMain = { ...inputFiles, "main.tsp": mainContent };
69
emitResult = await doEmit(filesWithMain, "main.tsp");
70
} else {
···
91
);
92
}
93
94
+
const normalizedExpectedPath = normalizePathToPosix(expectedPath);
95
+
96
assert.ok(
97
Object.prototype.hasOwnProperty.call(
98
emitResult.files,
99
+
normalizedExpectedPath,
100
),
101
`Expected file ${expectedPath} was not produced`,
102
);
103
104
+
const actual = JSON.parse(emitResult.files[normalizedExpectedPath]);
105
const expected = JSON.parse(expectedFiles[expectedPath]);
106
assert.deepStrictEqual(actual, expected);
107
});
···
182
await walk(dir, "");
183
return result;
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!