1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1
2
// Copyright (c) Microsoft Corporation. All rights reserved.
2
3
// Licensed under the MIT License.
3
4
@@ -10,11 +11,14 @@ import { CondaEnvironmentLocator } from '../../../../../client/pythonEnvironment
10
11
import { sleep } from '../../../../core' ;
11
12
import { createDeferred , Deferred } from '../../../../../client/common/utils/async' ;
12
13
import { PythonEnvsChangedEvent } from '../../../../../client/pythonEnvironments/base/watcher' ;
13
- import { TEST_TIMEOUT } from '../../../../constants' ;
14
+ import { EXTENSION_ROOT_DIR_FOR_TESTS , TEST_TIMEOUT } from '../../../../constants' ;
14
15
import { traceWarn } from '../../../../../client/logging' ;
15
16
import { TEST_LAYOUT_ROOT } from '../../../common/commonTestConstants' ;
16
17
import { getEnvs } from '../../common' ;
17
18
import { assertBasicEnvsEqual } from '../envTestUtils' ;
19
+ import { PYTHON_VIRTUAL_ENVS_LOCATION } from '../../../../ciConstants' ;
20
+ import { isCI } from '../../../../../client/common/constants' ;
21
+ import * as externalDependencies from '../../../../../client/pythonEnvironments/common/externalDependencies' ;
18
22
19
23
class CondaEnvs {
20
24
private readonly condaEnvironmentsTxt ;
@@ -55,6 +59,10 @@ class CondaEnvs {
55
59
suite ( 'Conda Env Locator' , async ( ) => {
56
60
let locator : CondaEnvironmentLocator ;
57
61
let condaEnvsTxt : CondaEnvs ;
62
+ const envsLocation =
63
+ PYTHON_VIRTUAL_ENVS_LOCATION !== undefined
64
+ ? path . join ( EXTENSION_ROOT_DIR_FOR_TESTS , PYTHON_VIRTUAL_ENVS_LOCATION )
65
+ : path . join ( EXTENSION_ROOT_DIR_FOR_TESTS , 'src' , 'tmp' , 'envPaths.json' ) ;
58
66
59
67
async function waitForChangeToBeDetected ( deferred : Deferred < void > ) {
60
68
const timeout = setTimeout ( ( ) => {
@@ -63,11 +71,23 @@ suite('Conda Env Locator', async () => {
63
71
} , TEST_TIMEOUT ) ;
64
72
await deferred . promise ;
65
73
}
74
+ let envPaths : any ;
75
+
76
+ suiteSetup ( async ( ) => {
77
+ if ( isCI ) {
78
+ envPaths = await fs . readJson ( envsLocation ) ;
79
+ }
80
+ } ) ;
66
81
67
82
setup ( async ( ) => {
68
83
sinon . stub ( platformUtils , 'getUserHomeDir' ) . returns ( TEST_LAYOUT_ROOT ) ;
69
84
condaEnvsTxt = new CondaEnvs ( ) ;
70
85
await condaEnvsTxt . cleanUp ( ) ;
86
+ if ( isCI ) {
87
+ console . log ( 'I am in CI' ) ;
88
+ console . log ( JSON . stringify ( envPaths ) ) ;
89
+ sinon . stub ( externalDependencies , 'getPythonSetting' ) . returns ( envPaths . condaExecPath ) ;
90
+ }
71
91
} ) ;
72
92
73
93
async function setupLocator ( onChanged : ( e : PythonEnvsChangedEvent ) => Promise < void > ) {
0 commit comments