@@ -22,6 +22,7 @@ import {
22
22
} from '../../../../../client/pythonEnvironments/base/locators/composite/envsCollectionCache' ;
23
23
import { EnvsCollectionService } from '../../../../../client/pythonEnvironments/base/locators/composite/envsCollectionService' ;
24
24
import { PythonEnvCollectionChangedEvent } from '../../../../../client/pythonEnvironments/base/watcher' ;
25
+ import * as externalDependencies from '../../../../../client/pythonEnvironments/common/externalDependencies' ;
25
26
import { noop } from '../../../../core' ;
26
27
import { TEST_LAYOUT_ROOT } from '../../../common/commonTestConstants' ;
27
28
import { SimpleLocator } from '../../common' ;
@@ -546,6 +547,9 @@ suite('Python envs locator - Environments Collection', async () => {
546
547
const resolvedViaLocator = buildEnvInfo ( { executable : 'Resolved via locator' } ) ;
547
548
const cachedEnvs = getCachedEnvs ( ) ;
548
549
const env : PythonEnvLatestInfo = cachedEnvs [ 0 ] ;
550
+ env . executable . ctime = 100 ;
551
+ env . executable . mtime = 100 ;
552
+ sinon . stub ( externalDependencies , 'getFileInfo' ) . resolves ( { ctime : 100 , mtime : 100 } ) ;
549
553
env . hasLatestInfo = true ; // Has complete info
550
554
const parentLocator = new SimpleLocator ( [ ] , {
551
555
resolve : async ( e : PythonEnvInfo ) => {
@@ -565,6 +569,35 @@ suite('Python envs locator - Environments Collection', async () => {
565
569
sinon . assert . calledOnce ( reportInterpretersChangedStub ) ;
566
570
} ) ;
567
571
572
+ test ( 'resolveEnv() uses underlying locator if cache does not have complete info for env' , async ( ) => {
573
+ const cachedEnvs = getCachedEnvs ( ) ;
574
+ const env : PythonEnvLatestInfo = cachedEnvs [ 0 ] ;
575
+ const resolvedViaLocator = buildEnvInfo ( {
576
+ executable : env . executable . filename ,
577
+ sysPrefix : 'Resolved via locator' ,
578
+ } ) ;
579
+ env . executable . ctime = 101 ;
580
+ env . executable . mtime = 90 ;
581
+ sinon . stub ( externalDependencies , 'getFileInfo' ) . resolves ( { ctime : 100 , mtime : 100 } ) ;
582
+ env . hasLatestInfo = true ; // Has complete info
583
+ const parentLocator = new SimpleLocator ( [ ] , {
584
+ resolve : async ( e : PythonEnvInfo ) => {
585
+ if ( env . executable . filename === e . executable . filename ) {
586
+ return resolvedViaLocator ;
587
+ }
588
+ return undefined ;
589
+ } ,
590
+ } ) ;
591
+ const cache = await createCollectionCache ( {
592
+ load : async ( ) => cachedEnvs ,
593
+ store : async ( ) => noop ( ) ,
594
+ } ) ;
595
+ collectionService = new EnvsCollectionService ( cache , parentLocator ) ;
596
+ const resolved = await collectionService . resolveEnv ( env . executable . filename ) ;
597
+ assertEnvEqual ( resolved , resolvedViaLocator ) ;
598
+ sinon . assert . calledOnce ( reportInterpretersChangedStub ) ;
599
+ } ) ;
600
+
568
601
test ( 'resolveEnv() uses underlying locator if cache does not have complete info for env' , async ( ) => {
569
602
const resolvedViaLocator = buildEnvInfo ( { executable : 'Resolved via locator' } ) ;
570
603
const cachedEnvs = getCachedEnvs ( ) ;
0 commit comments