Clean up processes in integration tests (#15102)

This commit is contained in:
Tommaso Sciortino
2025-12-15 11:11:08 -08:00
committed by GitHub
parent 217e2b0eb4
commit ec665ef405
19 changed files with 184 additions and 92 deletions

View File

@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { writeFileSync, readFileSync } from 'node:fs';
import { join, resolve } from 'node:path';
import { TestRig } from './test-helper.js';
@@ -47,28 +47,24 @@ const utf32BE = (s: string) => {
return Buffer.concat([bom, payload]);
};
let rig: TestRig;
let dir: string;
describe('BOM end-to-end integraion', () => {
beforeAll(async () => {
let rig: TestRig;
beforeEach(async () => {
rig = new TestRig();
await rig.setup('bom-integration', {
settings: { tools: { core: ['read_file'] } },
});
dir = rig.testDir!;
});
afterAll(async () => {
await rig.cleanup();
});
afterEach(async () => await rig.cleanup());
async function runAndAssert(
filename: string,
content: Buffer,
expectedText: string | null,
) {
writeFileSync(join(dir, filename), content);
writeFileSync(join(rig.testDir!, filename), content);
const prompt = `read the file ${filename} and output its exact contents`;
const output = await rig.run(prompt);
await rig.waitForToolCall('read_file');
@@ -128,7 +124,7 @@ describe('BOM end-to-end integraion', () => {
);
const imageContent = readFileSync(imagePath);
const filename = 'gemini-screenshot.png';
writeFileSync(join(dir, filename), imageContent);
writeFileSync(join(rig.testDir!, filename), imageContent);
const prompt = `What is shown in the image ${filename}?`;
const output = await rig.run(prompt);
await rig.waitForToolCall('read_file');