@@ -9,7 +9,8 @@ import { windowsExceptionGenerateConfig } from '../../../managers/conda/condaUti
99 *
1010 * Key behavior tested:
1111 * - Git Bash uses conda.sh (initialization script) + conda activate when condaShPath is available
12- * - Git Bash falls back to source <activate-script> <env> when condaShPath is not available
12+ * - Git Bash skips activation when condaShPath is not available and sourceInitPath is .bat
13+ * - Git Bash falls back to source <activate-script> <env> when condaShPath is not available and source is not .bat
1314 * - PowerShell uses ps1 hook + conda activate
1415 * - CMD uses activate.bat + conda activate
1516 */
@@ -51,8 +52,8 @@ suite('Conda Utils - windowsExceptionGenerateConfig', () => {
5152 assert . deepStrictEqual ( gitBashActivation [ 1 ] . args , [ 'activate' , 'myenv' ] ) ;
5253 } ) ;
5354
54- test ( 'Falls back to single source command when condaShPath is undefined' , async ( ) => {
55- // Arrange
55+ test ( 'Skips Git Bash activation when condaShPath is undefined and sourceInitPath is .bat ' , async ( ) => {
56+ // Arrange: sourceInitPath is a .bat file which Git Bash cannot source
5657 getCondaHookPs1PathStub . resolves ( undefined ) ;
5758 const sourceInitPath = 'C:\\conda\\Scripts\\activate.bat' ;
5859 const prefix = 'myenv' ;
@@ -62,14 +63,35 @@ suite('Conda Utils - windowsExceptionGenerateConfig', () => {
6263 // Act
6364 const result = await windowsExceptionGenerateConfig ( sourceInitPath , prefix , condaFolder , condaShPath ) ;
6465
66+ // Assert: Git Bash activation should be empty since .bat cannot be sourced
67+ const gitBashActivation = result . shellActivation . get ( ShellConstants . GITBASH ) ;
68+ assert . ok ( gitBashActivation , 'Git Bash activation should be defined' ) ;
69+ assert . strictEqual (
70+ gitBashActivation . length ,
71+ 0 ,
72+ 'Git Bash activation should be empty when sourceInitPath is .bat' ,
73+ ) ;
74+ } ) ;
75+
76+ test ( 'Falls back to single source command when condaShPath is undefined and source is not .bat' , async ( ) => {
77+ // Arrange: sourceInitPath is a bash-compatible script (no .bat extension)
78+ getCondaHookPs1PathStub . resolves ( undefined ) ;
79+ const sourceInitPath = 'C:\\conda\\Scripts\\activate' ; // No .bat extension
80+ const prefix = 'myenv' ;
81+ const condaFolder = 'C:\\conda' ;
82+ const condaShPath = undefined ; // Not available
83+
84+ // Act
85+ const result = await windowsExceptionGenerateConfig ( sourceInitPath , prefix , condaFolder , condaShPath ) ;
86+
6587 // Assert
6688 const gitBashActivation = result . shellActivation . get ( ShellConstants . GITBASH ) ;
6789 assert . ok ( gitBashActivation , 'Git Bash activation should be defined' ) ;
68- assert . strictEqual ( gitBashActivation . length , 1 , 'Should have 1 command when condaShPath not available ' ) ;
90+ assert . strictEqual ( gitBashActivation . length , 1 , 'Should have 1 command when source is bash-compatible ' ) ;
6991
7092 // Single command: source <activate-script> <env>
7193 assert . strictEqual ( gitBashActivation [ 0 ] . executable , 'source' ) ;
72- assert . deepStrictEqual ( gitBashActivation [ 0 ] . args , [ 'C:/conda/Scripts/activate.bat ' , 'myenv' ] ) ;
94+ assert . deepStrictEqual ( gitBashActivation [ 0 ] . args , [ 'C:/conda/Scripts/activate' , 'myenv' ] ) ;
7395 } ) ;
7496
7597 test ( 'Converts Windows backslashes to forward slashes for bash' , async ( ) => {
0 commit comments