@@ -17,6 +17,11 @@ function errnoError(code: string): NodeJS.ErrnoException {
1717 return error ;
1818}
1919
20+ function pathKey ( filePath : string ) : string {
21+ const normalizedPath = path . normalize ( filePath ) ;
22+ return process . platform === 'win32' ? normalizedPath . toLowerCase ( ) : normalizedPath ;
23+ }
24+
2025suite ( 'PythonEnvVariableManager.getEnvironmentVariables' , ( ) => {
2126 let sandbox : sinon . SinonSandbox ;
2227 let parseEnvFileStub : sinon . SinonStub ;
@@ -29,12 +34,13 @@ suite('PythonEnvVariableManager.getEnvironmentVariables', () => {
2934 const configuredFile = path . normalize ( path . resolve ( '/config/custom.env' ) ) ;
3035
3136 function parsedPaths ( ) : string [ ] {
32- return parseEnvFileStub . getCalls ( ) . map ( ( c ) => ( c . args [ 0 ] as Uri ) . fsPath ) ;
37+ return parseEnvFileStub . getCalls ( ) . map ( ( c ) => pathKey ( ( c . args [ 0 ] as Uri ) . fsPath ) ) ;
3338 }
3439
3540 function stubStat ( results : Map < string , StatResult > ) : void {
41+ const normalizedResults = new Map ( [ ...results ] . map ( ( [ p , result ] ) => [ pathKey ( p ) , result ] ) ) ;
3642 sandbox . stub ( fsapi , 'stat' ) . callsFake ( ( async ( p : string ) => {
37- const result = results . get ( path . normalize ( p ) ) ?? errnoError ( 'ENOENT' ) ;
43+ const result = normalizedResults . get ( pathKey ( p ) ) ?? errnoError ( 'ENOENT' ) ;
3844 if ( result === 'file' || result === 'directory' ) {
3945 return { isFile : ( ) => result === 'file' } as fsapi . Stats ;
4046 }
@@ -61,8 +67,7 @@ suite('PythonEnvVariableManager.getEnvironmentVariables', () => {
6167
6268 parseEnvFileStub = sandbox . stub ( envVarUtils , 'parseEnvFile' ) ;
6369 parseEnvFileStub . callsFake ( async ( uri : Uri ) => {
64- const p = path . normalize ( uri . fsPath ) ;
65- if ( p === projectEnvFile ) {
70+ if ( pathKey ( uri . fsPath ) === pathKey ( projectEnvFile ) ) {
6671 return { PROJECT_VAR : 'project' , SHARED : 'from-project' } ;
6772 }
6873 return { CONFIG_VAR : 'config' , SHARED : 'from-config' } ;
@@ -101,7 +106,7 @@ suite('PythonEnvVariableManager.getEnvironmentVariables', () => {
101106
102107 const env = await manager . getEnvironmentVariables ( projectUri , undefined , { BASE : 'base' } ) ;
103108
104- assert . deepStrictEqual ( parsedPaths ( ) , [ projectEnvFile ] ) ;
109+ assert . deepStrictEqual ( parsedPaths ( ) , [ pathKey ( projectEnvFile ) ] ) ;
105110 assert . strictEqual ( env . PROJECT_VAR , 'project' ) ;
106111 assert . strictEqual ( env . CONFIG_VAR , undefined ) ;
107112 } ) ;
@@ -117,7 +122,7 @@ suite('PythonEnvVariableManager.getEnvironmentVariables', () => {
117122
118123 const env = await manager . getEnvironmentVariables ( projectUri , undefined , { BASE : 'base' } ) ;
119124
120- assert . deepStrictEqual ( parsedPaths ( ) , [ configuredFile ] ) ;
125+ assert . deepStrictEqual ( parsedPaths ( ) , [ pathKey ( configuredFile ) ] ) ;
121126 assert . strictEqual ( env . CONFIG_VAR , 'config' ) ;
122127 assert . strictEqual ( env . SHARED , 'from-config' ) ;
123128 } ) ;
@@ -133,7 +138,7 @@ suite('PythonEnvVariableManager.getEnvironmentVariables', () => {
133138
134139 const env = await manager . getEnvironmentVariables ( projectUri , undefined , { BASE : 'base' } ) ;
135140
136- assert . deepStrictEqual ( parsedPaths ( ) , [ configuredFile , projectEnvFile ] ) ;
141+ assert . deepStrictEqual ( parsedPaths ( ) , [ pathKey ( configuredFile ) , pathKey ( projectEnvFile ) ] ) ;
137142 assert . strictEqual ( env . SHARED , 'from-project' ) ;
138143 assert . strictEqual ( env . PROJECT_VAR , 'project' ) ;
139144 } ) ;
@@ -190,7 +195,7 @@ suite('PythonEnvVariableManager.getEnvironmentVariables', () => {
190195
191196 const env = await manager . getEnvironmentVariables ( projectUri , undefined , { BASE : 'base' } ) ;
192197
193- assert . deepStrictEqual ( parsedPaths ( ) , [ path . normalize ( link ) ] ) ;
198+ assert . deepStrictEqual ( parsedPaths ( ) , [ pathKey ( link ) ] ) ;
194199 assert . strictEqual ( env . CONFIG_VAR , 'config' ) ;
195200 } ) ;
196201
0 commit comments