@@ -27,7 +27,7 @@ export async function run() {
2727 const required : { mochaGlobalSetup ?: ( ) => unknown ; mochaGlobalTeardown ?: ( ) => unknown } [ ] = [
2828 ...preload ,
2929 ...ensureArray ( mochaOpts . require ) ,
30- ] . map ( ( f ) => require ( f ) ) ;
30+ ] . map ( ( f ) => require ( normalizeCasing ( f ) ) ) ;
3131
3232 // currently `require` only seems to take effect for parallel runs, but remove
3333 // the option in case it's supported for serial runs in the future since we're
@@ -39,7 +39,7 @@ export async function run() {
3939 }
4040
4141 for ( const file of files ) {
42- mocha . addFile ( file ) ;
42+ mocha . addFile ( normalizeCasing ( file ) ) ;
4343 }
4444
4545 await new Promise < void > ( ( resolve , reject ) =>
@@ -55,5 +55,17 @@ export async function run() {
5555 }
5656}
5757
58+ const normalizeCasing = ( path : string ) => {
59+ // Normalize to lower-case drive letter to avoid path sensitivity in the loader
60+ // duplicating imports. VS Code normalizes to lower case drive letters in its
61+ // URIs, so do the same here
62+ // https://github.com/microsoft/vscode/blob/032c1b75447ade317715c3d2a82c2d9cd3e55dde/src/vs/base/common/uri.ts#L181-L185
63+ if ( process . platform === 'win32' && path . match ( / ^ [ A - Z ] : / ) ) {
64+ return path [ 0 ] . toLowerCase ( ) + path . slice ( 1 ) ;
65+ }
66+
67+ return path ;
68+ } ;
69+
5870const ensureArray = < T , > ( value : T | T [ ] | undefined ) : T [ ] =>
5971 value ? ( Array . isArray ( value ) ? value : [ value ] ) : [ ] ;
0 commit comments