@@ -73,8 +73,7 @@ suite('Python envs locator utils - getQueryFilter', () => {
73
73
const queries : PythonLocatorQuery [ ] = [
74
74
{ } ,
75
75
{ kinds : [ ] } ,
76
- { searchLocations : [ ] } ,
77
- { kinds : [ ] , searchLocations : [ ] } ,
76
+ // Any "defined" value for searchLocations causes filtering...
78
77
] ;
79
78
queries . forEach ( ( query ) => {
80
79
test ( `all envs kept (query ${ query } )` , ( ) => {
@@ -144,7 +143,11 @@ suite('Python envs locator utils - getQueryFilter', () => {
144
143
145
144
suite ( 'searchLocations' , ( ) => {
146
145
test ( 'match none' , ( ) => {
147
- const query : PythonLocatorQuery = { searchLocations : [ doesNotExist ] } ;
146
+ const query : PythonLocatorQuery = {
147
+ searchLocations : {
148
+ roots : [ doesNotExist ] ,
149
+ } ,
150
+ } ;
148
151
149
152
const filter = getQueryFilter ( query ) ;
150
153
const filtered = envs . filter ( filter ) ;
@@ -154,11 +157,13 @@ suite('Python envs locator utils - getQueryFilter', () => {
154
157
155
158
test ( 'match one (multiple locations)' , ( ) => {
156
159
const expected = [ envSL4 ] ;
157
- const searchLocations = [
158
- envSL4 . searchLocation ! ,
159
- doesNotExist ,
160
- envSL4 . searchLocation ! , // repeated
161
- ] ;
160
+ const searchLocations = {
161
+ roots : [
162
+ envSL4 . searchLocation ! ,
163
+ doesNotExist ,
164
+ envSL4 . searchLocation ! , // repeated
165
+ ] ,
166
+ } ;
162
167
const query : PythonLocatorQuery = { searchLocations } ;
163
168
164
169
const filter = getQueryFilter ( query ) ;
@@ -169,9 +174,11 @@ suite('Python envs locator utils - getQueryFilter', () => {
169
174
170
175
test ( 'match multiple (one location)' , ( ) => {
171
176
const expected = [ envS3 , envSL2 ] ;
172
- const searchLocations = [
173
- workspaceRoot ,
174
- ] ;
177
+ const searchLocations = {
178
+ roots : [
179
+ workspaceRoot ,
180
+ ] ,
181
+ } ;
175
182
const query : PythonLocatorQuery = { searchLocations } ;
176
183
177
184
const filter = getQueryFilter ( query ) ;
@@ -182,8 +189,10 @@ suite('Python envs locator utils - getQueryFilter', () => {
182
189
183
190
test ( 'match multiple (multiple locations)' , ( ) => {
184
191
const expected = [ envS3 , ...rootedLocatedEnvs ] ;
185
- const searchLocations = rootedLocatedEnvs . map ( ( env ) => env . searchLocation ! ) ;
186
- searchLocations . push ( doesNotExist ) ;
192
+ const searchLocations = {
193
+ roots : rootedLocatedEnvs . map ( ( env ) => env . searchLocation ! ) ,
194
+ } ;
195
+ searchLocations . roots . push ( doesNotExist ) ;
187
196
const query : PythonLocatorQuery = { searchLocations } ;
188
197
189
198
const filter = getQueryFilter ( query ) ;
@@ -194,8 +203,11 @@ suite('Python envs locator utils - getQueryFilter', () => {
194
203
195
204
test ( 'match multiple (include non-searched envs)' , ( ) => {
196
205
const expected = [ ...plainEnvs , ...locatedEnvs , envS3 , ...rootedLocatedEnvs ] ;
197
- const searchLocations = [ null , ...rootedLocatedEnvs . map ( ( env ) => env . searchLocation ! ) ] ;
198
- searchLocations . push ( doesNotExist ) ;
206
+ const searchLocations = {
207
+ roots : rootedLocatedEnvs . map ( ( env ) => env . searchLocation ! ) ,
208
+ includeNonRooted : true ,
209
+ } ;
210
+ searchLocations . roots . push ( doesNotExist ) ;
199
211
const query : PythonLocatorQuery = { searchLocations } ;
200
212
201
213
const filter = getQueryFilter ( query ) ;
@@ -206,7 +218,9 @@ suite('Python envs locator utils - getQueryFilter', () => {
206
218
207
219
test ( 'match all searched' , ( ) => {
208
220
const expected = [ ...rootedEnvs , ...rootedLocatedEnvs ] ;
209
- const searchLocations = expected . map ( ( env ) => env . searchLocation ! ) ;
221
+ const searchLocations = {
222
+ roots : expected . map ( ( env ) => env . searchLocation ! ) ,
223
+ } ;
210
224
const query : PythonLocatorQuery = { searchLocations } ;
211
225
212
226
const filter = getQueryFilter ( query ) ;
@@ -217,7 +231,10 @@ suite('Python envs locator utils - getQueryFilter', () => {
217
231
218
232
test ( 'match all (including non-searched)' , ( ) => {
219
233
const expected = envs ;
220
- const searchLocations = [ null , ...expected . map ( ( env ) => env . searchLocation ! ) ] ;
234
+ const searchLocations = {
235
+ roots : expected . map ( ( env ) => env . searchLocation ! ) ,
236
+ includeNonRooted : true ,
237
+ } ;
221
238
const query : PythonLocatorQuery = { searchLocations } ;
222
239
223
240
const filter = getQueryFilter ( query ) ;
@@ -228,7 +245,9 @@ suite('Python envs locator utils - getQueryFilter', () => {
228
245
229
246
test ( 'match all searched under one root' , ( ) => {
230
247
const expected = [ envS1 , envS2 , envSL1 , envSL3 , envSL5 ] ;
231
- const searchLocations = [ Uri . file ( homeDir ) ] ;
248
+ const searchLocations = {
249
+ roots : [ Uri . file ( homeDir ) ] ,
250
+ } ;
232
251
const query : PythonLocatorQuery = { searchLocations } ;
233
252
234
253
const filter = getQueryFilter ( query ) ;
@@ -237,9 +256,12 @@ suite('Python envs locator utils - getQueryFilter', () => {
237
256
assert . deepEqual ( filtered , expected ) ;
238
257
} ) ;
239
258
240
- test ( 'match only non-searched envs (null location )' , ( ) => {
259
+ test ( 'match only non-searched envs (empty roots )' , ( ) => {
241
260
const expected = [ ...plainEnvs , ...locatedEnvs ] ;
242
- const searchLocations = [ null ] ;
261
+ const searchLocations = {
262
+ roots : [ ] ,
263
+ includeNonRooted : true ,
264
+ } ;
243
265
const query : PythonLocatorQuery = { searchLocations } ;
244
266
245
267
const filter = getQueryFilter ( query ) ;
@@ -250,32 +272,26 @@ suite('Python envs locator utils - getQueryFilter', () => {
250
272
251
273
test ( 'match only non-searched envs (with unmatched location)' , ( ) => {
252
274
const expected = [ ...plainEnvs , ...locatedEnvs ] ;
253
- const searchLocations : ( Uri | null ) [ ] = [ null ] ;
254
- searchLocations . push ( doesNotExist ) ;
275
+ const searchLocations = {
276
+ roots : [ doesNotExist ] ,
277
+ includeNonRooted : true ,
278
+ } ;
255
279
const query : PythonLocatorQuery = { searchLocations } ;
256
280
257
281
const filter = getQueryFilter ( query ) ;
258
282
const filtered = envs . filter ( filter ) ;
259
283
260
284
assert . deepEqual ( filtered , expected ) ;
261
285
} ) ;
262
-
263
- test ( 'match only non-searched envs (explicit null)' , ( ) => {
264
- const expected = [ ...plainEnvs , ...locatedEnvs ] ;
265
- const query : PythonLocatorQuery = { searchLocations : null } ;
266
-
267
- const filter = getQueryFilter ( query ) ;
268
- const filtered = envs . filter ( filter ) ;
269
-
270
- assert . deepEqual ( filtered , expected ) ;
271
- } ) ;
272
286
} ) ;
273
287
274
288
suite ( 'mixed query' , ( ) => {
275
289
test ( 'match none' , ( ) => {
276
290
const query : PythonLocatorQuery = {
277
291
kinds : [ PythonEnvKind . OtherGlobal ] ,
278
- searchLocations : [ doesNotExist ] ,
292
+ searchLocations : {
293
+ roots : [ doesNotExist ] ,
294
+ } ,
279
295
} ;
280
296
281
297
const filter = getQueryFilter ( query ) ;
@@ -287,8 +303,10 @@ suite('Python envs locator utils - getQueryFilter', () => {
287
303
test ( 'match some' , ( ) => {
288
304
const expected = [ envSL1 , envSL4 , envSL5 ] ;
289
305
const kinds = [ PythonEnvKind . Venv , PythonEnvKind . Custom ] ;
290
- const searchLocations = rootedLocatedEnvs . map ( ( env ) => env . searchLocation ! ) ;
291
- searchLocations . push ( doesNotExist ) ;
306
+ const searchLocations = {
307
+ roots : rootedLocatedEnvs . map ( ( env ) => env . searchLocation ! ) ,
308
+ } ;
309
+ searchLocations . roots . push ( doesNotExist ) ;
292
310
const query : PythonLocatorQuery = { kinds, searchLocations } ;
293
311
294
312
const filter = getQueryFilter ( query ) ;
@@ -300,7 +318,9 @@ suite('Python envs locator utils - getQueryFilter', () => {
300
318
test ( 'match all' , ( ) => {
301
319
const expected = [ ...rootedEnvs , ...rootedLocatedEnvs ] ;
302
320
const kinds : PythonEnvKind [ ] = getEnumValues ( PythonEnvKind ) ;
303
- const searchLocations = expected . map ( ( env ) => env . searchLocation ! ) ;
321
+ const searchLocations = {
322
+ roots : expected . map ( ( env ) => env . searchLocation ! ) ,
323
+ } ;
304
324
const query : PythonLocatorQuery = { kinds, searchLocations } ;
305
325
306
326
const filter = getQueryFilter ( query ) ;
0 commit comments