11import assert from 'node:assert' ;
2+ import path from 'node:path' ;
23import * as sinon from 'sinon' ;
34import { Uri } from 'vscode' ;
45import * as logging from '../../../common/logging' ;
@@ -235,18 +236,17 @@ suite('getAllExtraSearchPaths Integration Tests', () => {
235236 workspaceFolderValue : [ 'folder-level-path' ] ,
236237 } ) ;
237238
238- mockGetWorkspaceFolders . returns ( [
239- { uri : Uri . file ( '/workspace/project1' ) } ,
240- { uri : Uri . file ( '/workspace/project2' ) } ,
241- ] ) ;
239+ const workspace1 = Uri . file ( '/workspace/project1' ) ;
240+ const workspace2 = Uri . file ( '/workspace/project2' ) ;
241+ mockGetWorkspaceFolders . returns ( [ { uri : workspace1 } , { uri : workspace2 } ] ) ;
242242
243243 // Run
244244 const result = await getAllExtraSearchPaths ( ) ;
245245
246- // Assert
246+ // Assert - Use dynamic path construction based on actual workspace URIs
247247 const expected = new Set ( [
248- '/workspace/project1/ folder-level-path',
249- '/workspace/project2/ folder-level-path',
248+ path . resolve ( workspace1 . fsPath , ' folder-level-path') ,
249+ path . resolve ( workspace2 . fsPath , ' folder-level-path') ,
250250 ] ) ;
251251 const actual = new Set ( result ) ;
252252 assert . strictEqual ( actual . size , expected . size , 'Should have correct number of unique paths' ) ;
@@ -310,12 +310,13 @@ suite('getAllExtraSearchPaths Integration Tests', () => {
310310 workspaceFolderValue : [ '/absolute/workspace/path' ] ,
311311 } ) ;
312312
313- mockGetWorkspaceFolders . returns ( [ { uri : Uri . file ( '/workspace' ) } ] ) ;
313+ const workspace = Uri . file ( '/workspace' ) ;
314+ mockGetWorkspaceFolders . returns ( [ { uri : workspace } ] ) ;
314315
315316 // Run
316317 const result = await getAllExtraSearchPaths ( ) ;
317318
318- // Assert
319+ // Assert - For absolute paths, they should remain unchanged regardless of platform
319320 const expected = new Set ( [ '/absolute/path1' , '/absolute/path2' , '/absolute/workspace/path' ] ) ;
320321 const actual = new Set ( result ) ;
321322 assert . strictEqual ( actual . size , expected . size , 'Should have correct number of unique paths' ) ;
@@ -331,19 +332,19 @@ suite('getAllExtraSearchPaths Integration Tests', () => {
331332 workspaceFolderValue : [ 'venvs' , '../shared-envs' ] ,
332333 } ) ;
333334
334- mockGetWorkspaceFolders . returns ( [
335- { uri : Uri . file ( '/workspace/project1' ) } ,
336- { uri : Uri . file ( '/workspace/project2' ) } ,
337- ] ) ;
335+ const workspace1 = Uri . file ( '/workspace/project1' ) ;
336+ const workspace2 = Uri . file ( '/workspace/project2' ) ;
337+ mockGetWorkspaceFolders . returns ( [ { uri : workspace1 } , { uri : workspace2 } ] ) ;
338338
339339 // Run
340340 const result = await getAllExtraSearchPaths ( ) ;
341341
342342 // Assert - path.resolve() correctly resolves relative paths (order doesn't matter)
343343 const expected = new Set ( [
344- '/workspace/project1/venvs' ,
345- '/workspace/project2/venvs' ,
346- '/workspace/shared-envs' , // ../shared-envs resolves to /workspace/shared-envs
344+ path . resolve ( workspace1 . fsPath , 'venvs' ) ,
345+ path . resolve ( workspace2 . fsPath , 'venvs' ) ,
346+ path . resolve ( workspace1 . fsPath , '../shared-envs' ) , // Resolves against workspace1
347+ path . resolve ( workspace2 . fsPath , '../shared-envs' ) , // Resolves against workspace2
347348 ] ) ;
348349 const actual = new Set ( result ) ;
349350 assert . strictEqual ( actual . size , expected . size , 'Should have correct number of unique paths' ) ;
@@ -384,7 +385,8 @@ suite('getAllExtraSearchPaths Integration Tests', () => {
384385 workspaceFolderValue : [ 'valid-relative' , '' , ' \t\n ' , 'another-valid' ] ,
385386 } ) ;
386387
387- mockGetWorkspaceFolders . returns ( [ { uri : Uri . file ( '/workspace' ) } ] ) ;
388+ const workspace = Uri . file ( '/workspace' ) ;
389+ mockGetWorkspaceFolders . returns ( [ { uri : workspace } ] ) ;
388390
389391 // Run
390392 const result = await getAllExtraSearchPaths ( ) ;
@@ -393,8 +395,8 @@ suite('getAllExtraSearchPaths Integration Tests', () => {
393395 const expected = new Set ( [
394396 '/valid/path' ,
395397 '/another/valid/path' ,
396- '/ workspace/ valid-relative',
397- '/ workspace/ another-valid',
398+ path . resolve ( workspace . fsPath , ' valid-relative') ,
399+ path . resolve ( workspace . fsPath , ' another-valid') ,
398400 ] ) ;
399401 const actual = new Set ( result ) ;
400402 assert . strictEqual ( actual . size , expected . size , 'Should have correct number of unique paths' ) ;
@@ -428,10 +430,9 @@ suite('getAllExtraSearchPaths Integration Tests', () => {
428430 workspaceFolderValue : [ '.venv' , 'project-envs' , '/shared/team/envs' ] ,
429431 } ) ;
430432
431- mockGetWorkspaceFolders . returns ( [
432- { uri : Uri . file ( '/workspace/project1' ) } ,
433- { uri : Uri . file ( '/workspace/project2' ) } ,
434- ] ) ;
433+ const workspace1 = Uri . file ( '/workspace/project1' ) ;
434+ const workspace2 = Uri . file ( '/workspace/project2' ) ;
435+ mockGetWorkspaceFolders . returns ( [ { uri : workspace1 } , { uri : workspace2 } ] ) ;
435436
436437 mockUntildify . withArgs ( '~/personal/envs' ) . returns ( '/home/user/personal/envs' ) ;
437438
@@ -444,10 +445,10 @@ suite('getAllExtraSearchPaths Integration Tests', () => {
444445 '/legacy/venvs' ,
445446 '/global/conda' ,
446447 '/home/user/personal/envs' ,
447- '/workspace/project1/ .venv',
448- '/workspace/project2/ .venv',
449- '/workspace/project1/ project-envs',
450- '/workspace/project2/ project-envs',
448+ path . resolve ( workspace1 . fsPath , ' .venv') ,
449+ path . resolve ( workspace2 . fsPath , ' .venv') ,
450+ path . resolve ( workspace1 . fsPath , ' project-envs') ,
451+ path . resolve ( workspace2 . fsPath , ' project-envs') ,
451452 '/shared/team/envs' ,
452453 ] ) ;
453454 const actual = new Set ( result ) ;
@@ -468,13 +469,18 @@ suite('getAllExtraSearchPaths Integration Tests', () => {
468469 workspaceFolderValue : [ '/shared/path' , 'workspace-unique' ] ,
469470 } ) ;
470471
471- mockGetWorkspaceFolders . returns ( [ { uri : Uri . file ( '/workspace' ) } ] ) ;
472+ const workspace = Uri . file ( '/workspace' ) ;
473+ mockGetWorkspaceFolders . returns ( [ { uri : workspace } ] ) ;
472474
473475 // Run
474476 const result = await getAllExtraSearchPaths ( ) ;
475477
476478 // Assert - Duplicates should be removed (order doesn't matter)
477- const expected = new Set ( [ '/shared/path' , '/global/unique' , '/workspace/workspace-unique' ] ) ;
479+ const expected = new Set ( [
480+ '/shared/path' ,
481+ '/global/unique' ,
482+ path . resolve ( workspace . fsPath , 'workspace-unique' ) ,
483+ ] ) ;
478484 const actual = new Set ( result ) ;
479485 assert . strictEqual ( actual . size , expected . size , 'Should have correct number of unique paths' ) ;
480486 assert . deepStrictEqual ( actual , expected , 'Should contain exactly the expected paths' ) ;
0 commit comments