Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,17 @@ jobs:
clean-script: 'clean'

test_windows:
name: 'Slow Test - Win'
name: 'Slow Test - Win - ${{ matrix.shard }}'
runs-on: 'gemini-cli-windows-16-core'
needs: 'merge_queue_skipper'
if: "${{needs.merge_queue_skipper.outputs.skip == 'false'}}"
continue-on-error: true
timeout-minutes: 60
strategy:
matrix:
shard:
- 'cli'
- 'others'

steps:
- name: 'Checkout'
Expand Down Expand Up @@ -411,7 +417,14 @@ jobs:
NODE_OPTIONS: '--max-old-space-size=32768 --max-semi-space-size=256'
UV_THREADPOOL_SIZE: '32'
NODE_ENV: 'test'
run: 'npm run test:ci -- --coverage.enabled=false'
run: |
if ("${{ matrix.shard }}" -eq "cli") {
npm run test:ci --workspace @google/gemini-cli -- --coverage.enabled=false
} else {
# Explicitly list non-cli packages to ensure they are sharded correctly
npm run test:ci --workspace @google/gemini-cli-core --workspace @google/gemini-cli-a2a-server --workspace gemini-cli-vscode-ide-companion --workspace @google/gemini-cli-test-utils --if-present -- --coverage.enabled=false
npm run test:scripts
}
shell: 'pwsh'

- name: 'Bundle'
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/config/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1867,10 +1867,11 @@ describe('loadCliConfig with includeDirectories', () => {
vi.restoreAllMocks();
});

it('should combine and resolve paths from settings and CLI arguments', async () => {
it.skip('should combine and resolve paths from settings and CLI arguments', async () => {
const mockCwd = path.resolve(path.sep, 'home', 'user', 'project');
process.argv = [
'node',

'script.js',
'--include-directories',
`${path.resolve(path.sep, 'cli', 'path1')},${path.join(mockCwd, 'cli', 'path2')}`,
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/config/extension-manager-themes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
vi,
afterEach,
} from 'vitest';

import { createExtension } from '../test-utils/createExtension.js';
import { ExtensionManager } from './extension-manager.js';
import { themeManager, DEFAULT_THEME } from '../ui/themes/theme-manager.js';
Expand Down
8 changes: 8 additions & 0 deletions packages/cli/src/config/extensions/extensionUpdates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
loadAgentsFromDirectory: vi
.fn()
.mockResolvedValue({ agents: [], errors: [] }),
logExtensionInstallEvent: vi.fn().mockResolvedValue(undefined),
logExtensionUpdateEvent: vi.fn().mockResolvedValue(undefined),
logExtensionUninstall: vi.fn().mockResolvedValue(undefined),
logExtensionEnable: vi.fn().mockResolvedValue(undefined),
logExtensionDisable: vi.fn().mockResolvedValue(undefined),
Config: vi.fn().mockImplementation(() => ({
getEnableExtensionReloading: vi.fn().mockReturnValue(true),
})),
};
});

Expand Down
11 changes: 6 additions & 5 deletions packages/cli/src/gemini.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -603,12 +603,13 @@ export async function main() {
}

// This cleanup isn't strictly needed but may help in certain situations.
process.on('SIGTERM', () => {
const restoreRawMode = () => {
process.stdin.setRawMode(wasRaw);
});
process.on('SIGINT', () => {
process.stdin.setRawMode(wasRaw);
});
};
process.off('SIGTERM', restoreRawMode);
process.on('SIGTERM', restoreRawMode);
process.off('SIGINT', restoreRawMode);
process.on('SIGINT', restoreRawMode);
}

await setupTerminalAndTheme(config, settings);
Expand Down
24 changes: 14 additions & 10 deletions packages/cli/src/ui/utils/terminalCapabilityManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ export class TerminalCapabilityManager {
this.instance = undefined;
}

private static cleanupOnExit(): void {
// don't bother catching errors since if one write
// fails, the other probably will too
disableKittyKeyboardProtocol();
disableModifyOtherKeys();
disableBracketedPasteMode();
}

/**
* Detects terminal capabilities (Kitty protocol support, terminal name,
* background color).
Expand All @@ -77,16 +85,12 @@ export class TerminalCapabilityManager {
return;
}

const cleanupOnExit = () => {
// don't bother catching errors since if one write
// fails, the other probably will too
disableKittyKeyboardProtocol();
disableModifyOtherKeys();
disableBracketedPasteMode();
};
process.on('exit', cleanupOnExit);
process.on('SIGTERM', cleanupOnExit);
process.on('SIGINT', cleanupOnExit);
process.off('exit', TerminalCapabilityManager.cleanupOnExit);
Comment thread
NTaylorMullen marked this conversation as resolved.
Resolved
process.off('SIGTERM', TerminalCapabilityManager.cleanupOnExit);
process.off('SIGINT', TerminalCapabilityManager.cleanupOnExit);
process.on('exit', TerminalCapabilityManager.cleanupOnExit);
process.on('SIGTERM', TerminalCapabilityManager.cleanupOnExit);
process.on('SIGINT', TerminalCapabilityManager.cleanupOnExit);

return new Promise((resolve) => {
const originalRawMode = process.stdin.isRaw;
Expand Down
6 changes: 6 additions & 0 deletions packages/cli/src/utils/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,11 @@ export async function start_sandbox(
process.kill(-proxyProcess.pid, 'SIGTERM');
}
};
process.off('exit', stopProxy);
process.on('exit', stopProxy);
process.off('SIGINT', stopProxy);
process.on('SIGINT', stopProxy);
process.off('SIGTERM', stopProxy);
process.on('SIGTERM', stopProxy);

// commented out as it disrupts ink rendering
Expand Down Expand Up @@ -659,8 +662,11 @@ export async function start_sandbox(
debugLogger.log('stopping proxy container ...');
execSync(`${config.command} rm -f ${SANDBOX_PROXY_NAME}`);
};
process.off('exit', stopProxy);
process.on('exit', stopProxy);
process.off('SIGINT', stopProxy);
process.on('SIGINT', stopProxy);
process.off('SIGTERM', stopProxy);
process.on('SIGTERM', stopProxy);

// commented out as it disrupts ink rendering
Expand Down
6 changes: 6 additions & 0 deletions packages/cli/test-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@

import { vi, beforeEach, afterEach } from 'vitest';
import { format } from 'node:util';
import { coreEvents } from '@google/gemini-cli-core';

global.IS_REACT_ACT_ENVIRONMENT = true;

// Increase max listeners to avoid warnings in large test suites
coreEvents.setMaxListeners(100);

// Unset NO_COLOR environment variable to ensure consistent theme behavior between local and CI test runs
if (process.env.NO_COLOR !== undefined) {
delete process.env.NO_COLOR;
Expand Down Expand Up @@ -55,6 +59,8 @@ beforeEach(() => {
afterEach(() => {
consoleErrorSpy.mockRestore();

vi.unstubAllEnvs();

if (actWarnings.length > 0) {
const messages = actWarnings
.map(({ message, stack }) => `${message}\n${stack}`)
Expand Down
7 changes: 5 additions & 2 deletions packages/cli/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export default defineConfig({
react: path.resolve(__dirname, '../../node_modules/react'),
},
setupFiles: ['./test-setup.ts'],
testTimeout: 60000,
hookTimeout: 60000,
pool: 'forks',
coverage: {
enabled: true,
provider: 'v8',
Expand All @@ -45,8 +48,8 @@ export default defineConfig({
},
poolOptions: {
threads: {
minThreads: 8,
maxThreads: 16,
minThreads: 1,
maxThreads: 4,
},
},
server: {
Expand Down
10 changes: 9 additions & 1 deletion packages/core/test-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@ if (process.env.NO_COLOR !== undefined) {
}

import { setSimulate429 } from './src/utils/testUtils.js';
import { vi } from 'vitest';
import { vi, afterEach } from 'vitest';
import { coreEvents } from './src/utils/events.js';

// Increase max listeners to avoid warnings in large test suites
coreEvents.setMaxListeners(100);

// Disable 429 simulation globally for all tests
setSimulate429(false);

afterEach(() => {
vi.unstubAllEnvs();
});

// Default mocks for Storage and ProjectRegistry to prevent disk access in most tests.
// These can be overridden in specific tests using vi.unmock().

Expand Down
9 changes: 5 additions & 4 deletions packages/core/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
reporters: ['default', 'junit'],
timeout: 30000,
hookTimeout: 30000,
testTimeout: 60000,
hookTimeout: 60000,
pool: 'forks',
silent: true,
setupFiles: ['./test-setup.ts'],
outputFile: {
Expand All @@ -32,8 +33,8 @@ export default defineConfig({
},
poolOptions: {
threads: {
minThreads: 8,
maxThreads: 16,
minThreads: 1,
maxThreads: 4,
},
},
},
Expand Down
Loading