From c2a17ae257fe1f4bb2d95ce505ecaee72182ba7e Mon Sep 17 00:00:00 2001 From: Spencer Date: Fri, 10 Apr 2026 05:08:54 +0000 Subject: [PATCH] test: revert to scanning tmpdir because readToolLogs does not expose tool result metadata --- .../run_shell_command_file_stream.test.ts | 74 +++++++++++++++---- 1 file changed, 60 insertions(+), 14 deletions(-) diff --git a/integration-tests/run_shell_command_file_stream.test.ts b/integration-tests/run_shell_command_file_stream.test.ts index 66e47d2b5e..4e2c15b8f2 100644 --- a/integration-tests/run_shell_command_file_stream.test.ts +++ b/integration-tests/run_shell_command_file_stream.test.ts @@ -48,16 +48,39 @@ describe('run_shell_command streaming to file regression', () => { await rig.run({ args: prompt }); let savedFilePath = ''; - const toolLogs = rig.readToolLogs(); - const shellCall = toolLogs.find( - (log) => log.toolRequest.name === 'run_shell_command', - ); - expect(shellCall).toBeTruthy(); - savedFilePath = shellCall?.toolResponse?.result?.outputFile; + const tmpdir = path.join(rig.homeDir!, '.gemini', 'tmp'); + if (fs.existsSync(tmpdir)) { + const findFiles = (dir: string): string[] => { + let results: string[] = []; + const list = fs.readdirSync(dir, { withFileTypes: true }); + for (const file of list) { + const fullPath = path.join(dir, file.name); + if (file.isDirectory()) { + results = results.concat(findFiles(fullPath)); + } else if (file.isFile() && file.name.endsWith('.txt')) { + results.push(fullPath); + } else if (file.isFile() && file.name.endsWith('.log')) { + results.push(fullPath); + } + } + return results; + }; + + const files = findFiles(tmpdir); + files.sort((a, b) => fs.statSync(b).mtimeMs - fs.statSync(a).mtimeMs); + + for (const p of files) { + const stat = fs.statSync(p); + if (stat.size >= 20000000) { + savedFilePath = p; + break; + } + } + } expect( savedFilePath, - `Expected the tool response to contain an outputFile`, + `Expected to find a saved output file >= 20MB in ${tmpdir}`, ).toBeTruthy(); const savedContent = fs.readFileSync(savedFilePath, 'utf8'); @@ -99,16 +122,39 @@ describe('run_shell_command streaming to file regression', () => { await rig.run({ args: prompt }); let savedFilePath = ''; - const toolLogs = rig.readToolLogs(); - const shellCall = toolLogs.find( - (log) => log.toolRequest.name === 'run_shell_command', - ); - expect(shellCall).toBeTruthy(); - savedFilePath = shellCall?.toolResponse?.result?.outputFile; + const tmpdir = path.join(rig.homeDir!, '.gemini', 'tmp'); + if (fs.existsSync(tmpdir)) { + const findFiles = (dir: string): string[] => { + let results: string[] = []; + const list = fs.readdirSync(dir, { withFileTypes: true }); + for (const file of list) { + const fullPath = path.join(dir, file.name); + if (file.isDirectory()) { + results = results.concat(findFiles(fullPath)); + } else if (file.isFile() && file.name.endsWith('.txt')) { + results.push(fullPath); + } else if (file.isFile() && file.name.endsWith('.log')) { + results.push(fullPath); + } + } + return results; + }; + + const files = findFiles(tmpdir); + files.sort((a, b) => fs.statSync(b).mtimeMs - fs.statSync(a).mtimeMs); + + for (const p of files) { + const stat = fs.statSync(p); + if (stat.size >= 20000000) { + savedFilePath = p; + break; + } + } + } expect( savedFilePath, - `Expected the tool response to contain an outputFile`, + `Expected to find a saved output file >= 20MB in ${tmpdir}`, ).toBeTruthy(); const savedContent = fs.readFileSync(savedFilePath, 'utf8');