An experimental TypeSpec syntax for Lexicon

Fix tests on Windows filesystems #1

readdirRecursive returns backslash-separated paths on Windows whereas typespec expects forward slash separated paths. This PR normalizes them.

Labels

None yet.

assignee

None yet.

Participants 2
AT URI
at://did:plc:nmc77zslrwafxn75j66mep6o/sh.tangled.repo.pull/3m2oi6ne2bm22
+18 -6
Diff #0
+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
··· 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
sign up or login to add to the discussion
1 commit
expand
Fix tests on Windows filesystems
expand 1 comment
pull request successfully merged