@@ -216,7 +216,7 @@ suite('Terminal Environment Variable Collection Service', () => {
216
216
assert . deepEqual ( opts , { applyAtProcessCreation : false , applyAtShellIntegration : true } ) ;
217
217
} ) ;
218
218
219
- test ( 'Prepend PATH instead of replacing it, where possible ' , async ( ) => {
219
+ test ( 'Prepend only "prepend portion of PATH" where applicable ' , async ( ) => {
220
220
const processEnv = { PATH : 'hello/1/2/3' } ;
221
221
reset ( environmentActivationService ) ;
222
222
when ( environmentActivationService . getProcessEnvironmentVariables ( anything ( ) , anything ( ) ) ) . thenResolve (
@@ -248,6 +248,38 @@ suite('Terminal Environment Variable Collection Service', () => {
248
248
assert . deepEqual ( opts , { applyAtProcessCreation : true , applyAtShellIntegration : true } ) ;
249
249
} ) ;
250
250
251
+ test ( 'Prepend full PATH otherwise' , async ( ) => {
252
+ const processEnv = { PATH : 'hello/1/2/3' } ;
253
+ reset ( environmentActivationService ) ;
254
+ when ( environmentActivationService . getProcessEnvironmentVariables ( anything ( ) , anything ( ) ) ) . thenResolve (
255
+ processEnv ,
256
+ ) ;
257
+ const finalPath = 'hello/3/2/1' ;
258
+ const envVars : NodeJS . ProcessEnv = { PATH : finalPath } ;
259
+ when (
260
+ environmentActivationService . getActivatedEnvironmentVariables (
261
+ anything ( ) ,
262
+ undefined ,
263
+ undefined ,
264
+ customShell ,
265
+ ) ,
266
+ ) . thenResolve ( envVars ) ;
267
+
268
+ when ( collection . replace ( anything ( ) , anything ( ) , anything ( ) ) ) . thenResolve ( ) ;
269
+ when ( collection . delete ( anything ( ) ) ) . thenResolve ( ) ;
270
+ let opts : EnvironmentVariableMutatorOptions | undefined ;
271
+ when ( collection . prepend ( 'PATH' , anything ( ) , anything ( ) ) ) . thenCall ( ( _ , _v , o ) => {
272
+ opts = o ;
273
+ } ) ;
274
+
275
+ await terminalEnvVarCollectionService . _applyCollection ( undefined , customShell ) ;
276
+
277
+ verify ( collection . clear ( ) ) . once ( ) ;
278
+ verify ( collection . prepend ( 'PATH' , finalPath , anything ( ) ) ) . once ( ) ;
279
+ verify ( collection . replace ( 'PATH' , anything ( ) , anything ( ) ) ) . never ( ) ;
280
+ assert . deepEqual ( opts , { applyAtProcessCreation : true , applyAtShellIntegration : true } ) ;
281
+ } ) ;
282
+
251
283
test ( 'Verify envs are not applied if env activation is disabled' , async ( ) => {
252
284
const envVars : NodeJS . ProcessEnv = { CONDA_PREFIX : 'prefix/to/conda' , ...process . env } ;
253
285
when (
0 commit comments