fix(ci): fix windows e2e tests (#7749)

This commit is contained in:
Gal Zahavi
2025-09-05 16:54:46 -07:00
committed by GitHub
parent 968e938949
commit dfd622e096
4 changed files with 14 additions and 15 deletions

View File

@@ -31,6 +31,7 @@ jobs:
os: os:
- 'ubuntu-latest' - 'ubuntu-latest'
- 'macos-latest' - 'macos-latest'
- 'gemini-cli-windows-16-core'
sandbox: sandbox:
- 'sandbox:none' - 'sandbox:none'
- 'sandbox:docker' - 'sandbox:docker'
@@ -40,6 +41,8 @@ jobs:
# Docker tests are not supported on macOS or Windows # Docker tests are not supported on macOS or Windows
- os: 'macos-latest' - os: 'macos-latest'
sandbox: 'sandbox:docker' sandbox: 'sandbox:docker'
- os: 'gemini-cli-windows-16-core'
sandbox: 'sandbox:docker'
steps: steps:
- name: 'Checkout (fork)' - name: 'Checkout (fork)'
@@ -57,7 +60,6 @@ jobs:
uses: 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020' # ratchet:actions-node@v4 uses: 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020' # ratchet:actions-node@v4
with: with:
node-version: '${{ matrix.node-version }}' node-version: '${{ matrix.node-version }}'
cache: 'npm'
- name: 'Install dependencies' - name: 'Install dependencies'
run: |- run: |-
@@ -78,5 +80,6 @@ jobs:
KEEP_OUTPUT: 'true' KEEP_OUTPUT: 'true'
SANDBOX: '${{ matrix.sandbox }}' SANDBOX: '${{ matrix.sandbox }}'
VERBOSE: 'true' VERBOSE: 'true'
shell: 'bash'
run: |- run: |-
npm run "test:integration:${SANDBOX}" npm run "test:integration:${SANDBOX}"

View File

@@ -96,8 +96,8 @@ describe('ShellExecutionService programmatic integration tests', () => {
); );
it('should abort a running process', async () => { it('should abort a running process', async () => {
// A command that runs for a bit. 'sleep' on unix, 'timeout' on windows. // A command that runs for a bit.
const command = process.platform === 'win32' ? 'timeout /t 20' : 'sleep 20'; const command = 'node -e "setTimeout(() => {}, 20000)"';
const onOutputEvent = vi.fn(); const onOutputEvent = vi.fn();
const abortController = new AbortController(); const abortController = new AbortController();

View File

@@ -5,7 +5,6 @@
*/ */
import { execSync, spawn } from 'node:child_process'; import { execSync, spawn } from 'node:child_process';
import { parse } from 'shell-quote';
import { mkdirSync, writeFileSync, readFileSync } from 'node:fs'; import { mkdirSync, writeFileSync, readFileSync } from 'node:fs';
import { join, dirname } from 'node:path'; import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url'; import { fileURLToPath } from 'node:url';
@@ -182,7 +181,7 @@ export class TestRig {
| { prompt?: string; stdin?: string; stdinDoesNotEnd?: boolean }, | { prompt?: string; stdin?: string; stdinDoesNotEnd?: boolean },
...args: string[] ...args: string[]
): Promise<string> { ): Promise<string> {
let command = `node ${this.bundlePath} --yolo`; const commandArgs = [this.bundlePath, '--yolo'];
const execOptions: { const execOptions: {
cwd: string; cwd: string;
encoding: 'utf-8'; encoding: 'utf-8';
@@ -193,25 +192,22 @@ export class TestRig {
}; };
if (typeof promptOrOptions === 'string') { if (typeof promptOrOptions === 'string') {
command += ` --prompt ${JSON.stringify(promptOrOptions)}`; commandArgs.push('--prompt', promptOrOptions);
} else if ( } else if (
typeof promptOrOptions === 'object' && typeof promptOrOptions === 'object' &&
promptOrOptions !== null promptOrOptions !== null
) { ) {
if (promptOrOptions.prompt) { if (promptOrOptions.prompt) {
command += ` --prompt ${JSON.stringify(promptOrOptions.prompt)}`; commandArgs.push('--prompt', promptOrOptions.prompt);
} }
if (promptOrOptions.stdin) { if (promptOrOptions.stdin) {
execOptions.input = promptOrOptions.stdin; execOptions.input = promptOrOptions.stdin;
} }
} }
command += ` ${args.join(' ')}`; commandArgs.push(...args);
const commandArgs = parse(command); const child = spawn('node', commandArgs, {
const node = commandArgs.shift() as string;
const child = spawn(node, commandArgs as string[], {
cwd: this.testDir!, cwd: this.testDir!,
stdio: 'pipe', stdio: 'pipe',
}); });

View File

@@ -36,9 +36,9 @@
"test:scripts": "vitest run --config ./scripts/tests/vitest.config.ts", "test:scripts": "vitest run --config ./scripts/tests/vitest.config.ts",
"test:e2e": "cross-env VERBOSE=true KEEP_OUTPUT=true npm run test:integration:sandbox:none", "test:e2e": "cross-env VERBOSE=true KEEP_OUTPUT=true npm run test:integration:sandbox:none",
"test:integration:all": "npm run test:integration:sandbox:none && npm run test:integration:sandbox:docker && npm run test:integration:sandbox:podman", "test:integration:all": "npm run test:integration:sandbox:none && npm run test:integration:sandbox:docker && npm run test:integration:sandbox:podman",
"test:integration:sandbox:none": "GEMINI_SANDBOX=false vitest run --root ./integration-tests", "test:integration:sandbox:none": "cross-env GEMINI_SANDBOX=false vitest run --root ./integration-tests",
"test:integration:sandbox:docker": "GEMINI_SANDBOX=docker npm run build:sandbox && GEMINI_SANDBOX=docker vitest run --root ./integration-tests", "test:integration:sandbox:docker": "cross-env GEMINI_SANDBOX=docker npm run build:sandbox && cross-env GEMINI_SANDBOX=docker vitest run --root ./integration-tests",
"test:integration:sandbox:podman": "GEMINI_SANDBOX=podman vitest run --root ./integration-tests", "test:integration:sandbox:podman": "cross-env GEMINI_SANDBOX=podman vitest run --root ./integration-tests",
"lint": "eslint . --ext .ts,.tsx && eslint integration-tests", "lint": "eslint . --ext .ts,.tsx && eslint integration-tests",
"lint:fix": "eslint . --fix && eslint integration-tests --fix", "lint:fix": "eslint . --fix && eslint integration-tests --fix",
"lint:ci": "eslint . --ext .ts,.tsx --max-warnings 0 && eslint integration-tests --max-warnings 0", "lint:ci": "eslint . --ext .ts,.tsx --max-warnings 0 && eslint integration-tests --max-warnings 0",