@@ -35,33 +35,110 @@ suite('Smoke Test: Run Smart Selection and Advance Cursor', async () => {
3535 'smart_send_smoke.txt' ,
3636 ) ;
3737
38+ console . log ( `[smartSend.smoke] Test starting` ) ;
39+ console . log ( `[smartSend.smoke] Python file: ${ file } ` ) ;
40+ console . log ( `[smartSend.smoke] Output file: ${ outputFile } ` ) ;
41+ console . log ( `[smartSend.smoke] Python file exists: ${ await fs . pathExists ( file ) } ` ) ;
42+
43+ const outputFileExistsBefore = await fs . pathExists ( outputFile ) ;
44+ console . log ( `[smartSend.smoke] Output file exists before cleanup: ${ outputFileExistsBefore } ` ) ;
3845 await fs . remove ( outputFile ) ;
46+ console . log ( `[smartSend.smoke] Output file removed` ) ;
3947
4048 const textDocument = await openFile ( file ) ;
49+ console . log ( `[smartSend.smoke] File opened in editor` ) ;
4150
4251 if ( vscode . window . activeTextEditor ) {
4352 const myPos = new vscode . Position ( 0 , 0 ) ;
4453 vscode . window . activeTextEditor ! . selections = [ new vscode . Selection ( myPos , myPos ) ] ;
54+ console . log ( `[smartSend.smoke] Cursor set to position (0, 0)` ) ;
4555 }
56+
57+ const terminalsBefore = vscode . window . terminals . length ;
58+ console . log ( `[smartSend.smoke] Number of terminals before execution: ${ terminalsBefore } ` ) ;
59+
60+ const startTime = Date . now ( ) ;
61+ console . log ( `[smartSend.smoke] Executing first 'python.execSelectionInTerminal' command at ${ new Date ( ) . toISOString ( ) } ` ) ;
62+
4663 await vscode . commands
4764 . executeCommand < void > ( 'python.execSelectionInTerminal' , textDocument . uri )
4865 . then ( undefined , ( err ) => {
66+ console . error ( `[smartSend.smoke] First command failed: ${ err } ` ) ;
4967 assert . fail ( `Something went wrong running the Python file in the terminal: ${ err } ` ) ;
5068 } ) ;
5169
52- const checkIfFileHasBeenCreated = ( ) => fs . pathExists ( outputFile ) ;
53- await waitForCondition ( checkIfFileHasBeenCreated , 20_000 , `"${ outputFile } " file not created` ) ;
70+ const firstCmdTime = Date . now ( ) ;
71+ console . log ( `[smartSend.smoke] First command completed in ${ firstCmdTime - startTime } ms` ) ;
72+
73+ const terminalsAfter = vscode . window . terminals . length ;
74+ console . log ( `[smartSend.smoke] Number of terminals after first execution: ${ terminalsAfter } ` ) ;
75+ if ( vscode . window . activeTerminal ) {
76+ console . log ( `[smartSend.smoke] Active terminal name: ${ vscode . window . activeTerminal . name } ` ) ;
77+ }
78+
79+ // Add additional wait to allow terminal to start processing
80+ // Windows may need more time for terminal to initialize and start executing
81+ const isWindows = process . platform === 'win32' ;
82+ const initialWaitTime = isWindows ? 2000 : 1000 ;
83+ console . log ( `[smartSend.smoke] Waiting ${ initialWaitTime } ms for terminal to start processing (isWindows: ${ isWindows } )...` ) ;
84+ await new Promise ( resolve => setTimeout ( resolve , initialWaitTime ) ) ;
5485
86+ // Verify the working directory matches expected
87+ const expectedDir = path . dirname ( outputFile ) ;
88+ console . log ( `[smartSend.smoke] Expected output directory: ${ expectedDir } ` ) ;
89+ console . log ( `[smartSend.smoke] Directory exists: ${ await fs . pathExists ( expectedDir ) } ` ) ;
90+
91+ let checkCount = 0 ;
92+ const checkIfFileHasBeenCreated = async ( ) => {
93+ checkCount ++ ;
94+ const exists = await fs . pathExists ( outputFile ) ;
95+ if ( checkCount % 100 === 0 ) { // Log every 100 checks (~1 second)
96+ const elapsed = Date . now ( ) - startTime ;
97+ console . log ( `[smartSend.smoke] File creation check #${ checkCount } at ${ elapsed } ms: ${ exists } ` ) ;
98+ }
99+ return exists ;
100+ } ;
101+
102+ try {
103+ await waitForCondition ( checkIfFileHasBeenCreated , 20_000 , `"${ outputFile } " file not created` ) ;
104+ const createTime = Date . now ( ) - startTime ;
105+ console . log ( `[smartSend.smoke] SUCCESS: File created after ${ createTime } ms (${ checkCount } checks)` ) ;
106+ } catch ( error ) {
107+ const totalTime = Date . now ( ) - startTime ;
108+ console . error ( `[smartSend.smoke] FAILURE: File not created after ${ totalTime } ms (${ checkCount } checks)` ) ;
109+ console . error ( `[smartSend.smoke] Output file exists: ${ await fs . pathExists ( outputFile ) } ` ) ;
110+ console . error ( `[smartSend.smoke] Number of terminals: ${ vscode . window . terminals . length } ` ) ;
111+
112+ // List directory contents
113+ const dir = path . dirname ( outputFile ) ;
114+ try {
115+ const fsModule = await import ( 'fs' ) ;
116+ const files = fsModule . readdirSync ( dir ) ;
117+ console . error ( `[smartSend.smoke] Directory contents (${ dir } ):` , files ) ;
118+ } catch ( e ) {
119+ console . error ( `[smartSend.smoke] Failed to list directory: ${ e } ` ) ;
120+ }
121+
122+ throw error ;
123+ }
124+
125+ console . log ( `[smartSend.smoke] Executing second 'python.execSelectionInTerminal' command` ) ;
55126 await vscode . commands
56127 . executeCommand < void > ( 'python.execSelectionInTerminal' , textDocument . uri )
57128 . then ( undefined , ( err ) => {
129+ console . error ( `[smartSend.smoke] Second command failed: ${ err } ` ) ;
58130 assert . fail ( `Something went wrong running the Python file in the terminal: ${ err } ` ) ;
59131 } ) ;
132+ console . log ( `[smartSend.smoke] Second command completed` ) ;
133+
134+ console . log ( `[smartSend.smoke] Executing third 'python.execSelectionInTerminal' command` ) ;
60135 await vscode . commands
61136 . executeCommand < void > ( 'python.execSelectionInTerminal' , textDocument . uri )
62137 . then ( undefined , ( err ) => {
138+ console . error ( `[smartSend.smoke] Third command failed: ${ err } ` ) ;
63139 assert . fail ( `Something went wrong running the Python file in the terminal: ${ err } ` ) ;
64140 } ) ;
141+ console . log ( `[smartSend.smoke] Third command completed` ) ;
65142
66143 async function wait ( ) {
67144 return new Promise < void > ( ( resolve ) => {
@@ -71,12 +148,16 @@ suite('Smoke Test: Run Smart Selection and Advance Cursor', async () => {
71148 } ) ;
72149 }
73150
151+ console . log ( `[smartSend.smoke] Waiting 10s for file deletion to complete...` ) ;
74152 await wait ( ) ;
75153
76154 const deletedFile = ! ( await fs . pathExists ( outputFile ) ) ;
155+ console . log ( `[smartSend.smoke] File exists after deletion commands: ${ ! deletedFile } ` ) ;
77156 if ( deletedFile ) {
157+ console . log ( `[smartSend.smoke] SUCCESS: File has been deleted as expected` ) ;
78158 assert . ok ( true , `"${ outputFile } " file has been deleted` ) ;
79159 } else {
160+ console . error ( `[smartSend.smoke] FAILURE: File still exists` ) ;
80161 assert . fail ( `"${ outputFile } " file still exists` ) ;
81162 }
82163 } ) ;
0 commit comments