4
4
import { assert } from 'chai' ;
5
5
import * as fs from 'fs-extra' ;
6
6
import * as path from 'path' ;
7
+ import * as sinon from 'sinon' ;
8
+ import { DiscoveryVariants } from '../../../../client/common/experiments/groups' ;
7
9
import { traceWarning } from '../../../../client/common/logger' ;
8
10
import { FileChangeType } from '../../../../client/common/platform/fileSystemWatcher' ;
9
11
import { createDeferred , Deferred , sleep } from '../../../../client/common/utils/async' ;
10
12
import { PythonEnvKind } from '../../../../client/pythonEnvironments/base/info' ;
11
13
import { getEnvs } from '../../../../client/pythonEnvironments/base/locatorUtils' ;
12
14
import { PythonEnvsChangedEvent } from '../../../../client/pythonEnvironments/base/watcher' ;
13
- import { arePathsSame } from '../../../../client/pythonEnvironments/common/externalDependencies' ;
15
+ import * as externalDeps from '../../../../client/pythonEnvironments/common/externalDependencies' ;
14
16
import { WindowsStoreLocator } from '../../../../client/pythonEnvironments/discovery/locators/services/windowsStoreLocator' ;
15
17
import { TEST_TIMEOUT } from '../../../constants' ;
16
18
import { TEST_LAYOUT_ROOT } from '../../common/commonTestConstants' ;
@@ -54,6 +56,7 @@ class WindowsStoreEnvs {
54
56
}
55
57
56
58
suite ( 'Windows Store Locator' , async ( ) => {
59
+ let inExperimentStub : sinon . SinonStub ;
57
60
const testLocalAppData = path . join ( TEST_LAYOUT_ROOT , 'storeApps' ) ;
58
61
const testStoreAppRoot = path . join ( testLocalAppData , 'Microsoft' , 'WindowsApps' ) ;
59
62
const windowsStoreEnvs = new WindowsStoreEnvs ( testStoreAppRoot ) ;
@@ -74,14 +77,19 @@ suite('Windows Store Locator', async () => {
74
77
75
78
async function isLocated ( executable : string ) : Promise < boolean > {
76
79
const items = await getEnvs ( locator . iterEnvs ( ) ) ;
77
- return items . some ( ( item ) => arePathsSame ( item . executable . filename , executable ) ) ;
80
+ return items . some ( ( item ) => externalDeps . arePathsSame ( item . executable . filename , executable ) ) ;
78
81
}
79
82
80
83
suiteSetup ( async ( ) => {
81
84
process . env . LOCALAPPDATA = testLocalAppData ;
82
85
await windowsStoreEnvs . cleanUp ( ) ;
83
86
} ) ;
84
87
88
+ setup ( ( ) => {
89
+ inExperimentStub = sinon . stub ( externalDeps , 'inExperiment' ) ;
90
+ inExperimentStub . withArgs ( DiscoveryVariants . discoverWithFileWatching ) . resolves ( true ) ;
91
+ } ) ;
92
+
85
93
async function setupLocator ( onChanged : ( e : PythonEnvsChangedEvent ) => Promise < void > ) {
86
94
locator = new WindowsStoreLocator ( ) ;
87
95
await getEnvs ( locator . iterEnvs ( ) ) ; // Force the watchers to start.
@@ -91,6 +99,7 @@ suite('Windows Store Locator', async () => {
91
99
}
92
100
93
101
teardown ( async ( ) => {
102
+ inExperimentStub . restore ( ) ;
94
103
await windowsStoreEnvs . cleanUp ( ) ;
95
104
await locator . dispose ( ) ;
96
105
} ) ;
0 commit comments