@@ -12,6 +12,12 @@ suite('Smoke Test: Run Smart Selection and Advance Cursor', async () => {
1212 return this . skip ( ) ;
1313 }
1414 await initialize ( ) ;
15+ // Ensure the environments extension is not used for this test
16+ // execSelectionInTerminal was not updated to use the envs extension API
17+ // when execInTerminal was updated in commit e78934859
18+ await vscode . workspace
19+ . getConfiguration ( 'python' )
20+ . update ( 'useEnvironmentsExtension' , false , vscode . ConfigurationTarget . Global ) ;
1521 return undefined ;
1622 } ) ;
1723
@@ -68,7 +74,7 @@ suite('Smoke Test: Run Smart Selection and Advance Cursor', async () => {
6874 vscode . window . activeTextEditor . selection ,
6975 ) ;
7076 console . log (
71- `[smartSend.smoke] Selected entire file (${ selectedText . split ( '\\ n' ) . length } lines, ${
77+ `[smartSend.smoke] Selected entire file (${ selectedText . split ( '\n' ) . length } lines, ${
7278 selectedText . length
7379 } chars)`,
7480 ) ;
@@ -81,6 +87,15 @@ suite('Smoke Test: Run Smart Selection and Advance Cursor', async () => {
8187 const terminalsBefore = vscode . window . terminals . length ;
8288 console . log ( `[smartSend.smoke] Number of terminals before execution: ${ terminalsBefore } ` ) ;
8389
90+ // On Windows, if terminals exist from previous tests, they may not be ready for new commands
91+ // Give them time to fully initialize before sending commands
92+ if ( terminalsBefore > 0 && process . platform === 'win32' ) {
93+ console . log (
94+ `[smartSend.smoke] Windows detected with ${ terminalsBefore } existing terminals, waiting 3s for terminal readiness...` ,
95+ ) ;
96+ await new Promise ( ( resolve ) => setTimeout ( resolve , 3000 ) ) ;
97+ }
98+
8499 // Verify the active editor is correct before executing command
85100 if ( vscode . window . activeTextEditor ) {
86101 console . log (
@@ -97,12 +112,14 @@ suite('Smoke Test: Run Smart Selection and Advance Cursor', async () => {
97112 console . log (
98113 `[smartSend.smoke] Executing first 'python.execSelectionInTerminal' command at ${ new Date ( ) . toISOString ( ) } ` ,
99114 ) ;
100- console . log ( `[smartSend.smoke] NOTE: Passing no arguments to allow smart selection to work on active editor ` ) ;
115+ console . log ( `[smartSend.smoke] Passing document URI to execSelectionInTerminal: ${ textDocument . uri . fsPath } ` ) ;
101116
102- await vscode . commands . executeCommand < void > ( 'python.execSelectionInTerminal' ) . then ( undefined , ( err ) => {
103- console . error ( `[smartSend.smoke] First command failed: ${ err } ` ) ;
104- assert . fail ( `Something went wrong running the Python file in the terminal: ${ err } ` ) ;
105- } ) ;
117+ await vscode . commands
118+ . executeCommand < void > ( 'python.execSelectionInTerminal' , textDocument . uri )
119+ . then ( undefined , ( err ) => {
120+ console . error ( `[smartSend.smoke] First command failed: ${ err } ` ) ;
121+ assert . fail ( `Something went wrong running the Python file in the terminal: ${ err } ` ) ;
122+ } ) ;
106123 const firstCmdTime = Date . now ( ) ;
107124 console . log ( `[smartSend.smoke] First command completed in ${ firstCmdTime - startTime } ms` ) ;
108125
@@ -192,17 +209,21 @@ suite('Smoke Test: Run Smart Selection and Advance Cursor', async () => {
192209 }
193210
194211 console . log ( `[smartSend.smoke] Executing second 'python.execSelectionInTerminal' command` ) ;
195- await vscode . commands . executeCommand < void > ( 'python.execSelectionInTerminal' ) . then ( undefined , ( err ) => {
196- console . error ( `[smartSend.smoke] Second command failed: ${ err } ` ) ;
197- assert . fail ( `Something went wrong running the Python file in the terminal: ${ err } ` ) ;
198- } ) ;
212+ await vscode . commands
213+ . executeCommand < void > ( 'python.execSelectionInTerminal' , textDocument . uri )
214+ . then ( undefined , ( err ) => {
215+ console . error ( `[smartSend.smoke] Second command failed: ${ err } ` ) ;
216+ assert . fail ( `Something went wrong running the Python file in the terminal: ${ err } ` ) ;
217+ } ) ;
199218 console . log ( `[smartSend.smoke] Second command completed` ) ;
200219
201220 console . log ( `[smartSend.smoke] Executing third 'python.execSelectionInTerminal' command` ) ;
202- await vscode . commands . executeCommand < void > ( 'python.execSelectionInTerminal' ) . then ( undefined , ( err ) => {
203- console . error ( `[smartSend.smoke] Third command failed: ${ err } ` ) ;
204- assert . fail ( `Something went wrong running the Python file in the terminal: ${ err } ` ) ;
205- } ) ;
221+ await vscode . commands
222+ . executeCommand < void > ( 'python.execSelectionInTerminal' , textDocument . uri )
223+ . then ( undefined , ( err ) => {
224+ console . error ( `[smartSend.smoke] Third command failed: ${ err } ` ) ;
225+ assert . fail ( `Something went wrong running the Python file in the terminal: ${ err } ` ) ;
226+ } ) ;
206227 console . log ( `[smartSend.smoke] Third command completed` ) ;
207228
208229 async function wait ( ) {
0 commit comments