5
5
6
6
import { expect } from 'chai' ;
7
7
import * as path from 'path' ;
8
+ import { parse } from 'semver' ;
8
9
import * as TypeMoq from 'typemoq' ;
9
10
import { Disposable } from 'vscode' ;
10
11
import '../../../client/common/extensions' ;
@@ -105,15 +106,19 @@ suite('Terminal Environment Activation conda', () => {
105
106
test ( 'Conda activation on bash uses "source" before 4.4.0' , async ( ) => {
106
107
const envName = 'EnvA' ;
107
108
const pythonPath = 'python3' ;
109
+ const condaPath = path . join ( 'a' , 'b' , 'c' , 'conda' ) ;
108
110
platformService . setup ( p => p . isWindows ) . returns ( ( ) => false ) ;
111
+ condaService . reset ( ) ;
109
112
condaService . setup ( c => c . getCondaEnvironment ( TypeMoq . It . isAny ( ) ) )
110
113
. returns ( ( ) => Promise . resolve ( {
111
114
name : envName ,
112
115
path : path . dirname ( pythonPath )
113
116
} ) ) ;
117
+ condaService . setup ( c => c . getCondaFile ( ) )
118
+ . returns ( ( ) => Promise . resolve ( condaPath ) ) ;
114
119
condaService . setup ( c => c . getCondaVersion ( ) )
115
- . returns ( ( ) => Promise . resolve ( '4.3.1' ) ) ;
116
- const expected = [ ' source activate EnvA' ] ;
120
+ . returns ( ( ) => Promise . resolve ( parse ( '4.3.1' , true ) ! ) ) ;
121
+ const expected = [ ` source ${ path . join ( path . dirname ( condaPath ) , ' activate' ) . fileToCommandArgument ( ) } EnvA` ] ;
117
122
118
123
const provider = new CondaActivationCommandProvider ( serviceContainer . object ) ;
119
124
const activationCommands = await provider . getActivationCommands ( undefined , TerminalShellType . bash ) ;
@@ -124,15 +129,19 @@ suite('Terminal Environment Activation conda', () => {
124
129
test ( 'Conda activation on bash uses "conda" after 4.4.0' , async ( ) => {
125
130
const envName = 'EnvA' ;
126
131
const pythonPath = 'python3' ;
132
+ const condaPath = path . join ( 'a' , 'b' , 'c' , 'conda' ) ;
127
133
platformService . setup ( p => p . isWindows ) . returns ( ( ) => false ) ;
134
+ condaService . reset ( ) ;
128
135
condaService . setup ( c => c . getCondaEnvironment ( TypeMoq . It . isAny ( ) ) )
129
136
. returns ( ( ) => Promise . resolve ( {
130
137
name : envName ,
131
138
path : path . dirname ( pythonPath )
132
139
} ) ) ;
140
+ condaService . setup ( c => c . getCondaFile ( ) )
141
+ . returns ( ( ) => Promise . resolve ( condaPath ) ) ;
133
142
condaService . setup ( c => c . getCondaVersion ( ) )
134
- . returns ( ( ) => Promise . resolve ( '4.4.0' ) ) ;
135
- const expected = [ `${ conda } activate EnvA` ] ;
143
+ . returns ( ( ) => Promise . resolve ( parse ( '4.4.0' , true ) ! ) ) ;
144
+ const expected = [ `source ${ path . join ( path . dirname ( condaPath ) , ' activate' ) . fileToCommandArgument ( ) } EnvA` ] ;
136
145
137
146
const provider = new CondaActivationCommandProvider ( serviceContainer . object ) ;
138
147
const activationCommands = await provider . getActivationCommands ( undefined , TerminalShellType . bash ) ;
0 commit comments