Skip to content

test(integration): Add "Ctrl + C" to exit integration test#9272

Merged
davideast merged 3 commits into
google-gemini:mainfrom
davideast:confidence/ctrl-c-to-exit
Sep 23, 2025
Merged

test(integration): Add "Ctrl + C" to exit integration test#9272
davideast merged 3 commits into
google-gemini:mainfrom
davideast:confidence/ctrl-c-to-exit

Conversation

@davideast

Copy link
Copy Markdown
Member

TLDR

Adds a new integration test to verify that the Gemini CLI exits gracefully when a user presses "Ctrl + C" twice. The test simulates a user's actions in a pseudo-terminal to capture the application's behavior.

Dive Deeper

The primary concern for this this test is simulating an interactive terminal capable of handling control signals like "Ctrl + C".

This change adds a runInteractive method to the TestRig class in integration-tests/test-helper.ts. This method uses @lydell/node-pty to create a pseudo-terminal for testing interactive features.

The new test file, integration-tests/ctrl-c-exit.test.ts, performs the following:

  1. Spawns the CLI process within a pseudo-terminal.
  2. Waits for the application to initialize.
  3. Sends the first Ctrl+C signal and asserts that the "Press Ctrl+C again to exit" prompt is displayed.
  4. Sends the second Ctrl+C signal and confirms that the application exits gracefully with the correct message.

Reviewer Test Plan

To validate the changes, please follow these steps:

  1. Pull this branch.
  2. Run npm install to ensure all dependencies are correctly installed.
  3. Execute the integration test suite with the following command:
    npm run test:integration:sandbox:none
  4. Confirm that the new test, ctrl-c-exit.test.ts, passes along with the rest of the test suite. No manual testing is required as the automated test fully covers the intended functionality.

Testing Matrix

🍏 🪟 🐧
npm run
npx
Docker
Podman - -
Seatbelt - -

Linked issues / bugs

#9127

Introduces an integration test to verify the 'Ctrl+C' exit behavior.
@davideast davideast requested a review from a team as a code owner September 23, 2025 22:26
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @davideast, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the testing suite by introducing a new integration test focused on the graceful exit behavior of the Gemini CLI when subjected to 'Ctrl + C' signals. It achieves this by adding capabilities to simulate interactive terminal environments within the existing test infrastructure, ensuring robust handling of user interruption commands.

Highlights

  • New Integration Test: A new integration test (ctrl-c-exit.test.ts) has been added to verify that the Gemini CLI exits gracefully when a user presses 'Ctrl + C' twice.
  • Interactive Terminal Simulation: The TestRig class in test-helper.ts now includes a runInteractive method, utilizing @lydell/node-pty to create a pseudo-terminal for simulating interactive CLI behavior during tests.
  • Graceful Exit Verification: The new test simulates sending two 'Ctrl + C' signals, asserting that the 'Press Ctrl+C again to exit' prompt appears after the first signal and that the application exits gracefully with a zero exit code and the correct 'Agent powering down. Goodbye!' message after the second.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an integration test to ensure the CLI exits gracefully upon receiving two Ctrl+C signals. This is achieved by adding a new runInteractive method to the TestRig helper, which utilizes node-pty to simulate an interactive terminal. The new test is well-structured. However, I found a critical issue in integration-tests/test-helper.ts where JSON.parse was incorrectly changed to JSON.Parse. This will cause a TypeError at runtime, breaking any tests that rely on the readLastApiRequest method.

Comment thread integration-tests/test-helper.ts Outdated
@galz10 galz10 self-assigned this Sep 23, 2025
@davideast davideast added this pull request to the merge queue Sep 23, 2025
Merged via the queue into google-gemini:main with commit 38e053b Sep 23, 2025
18 checks passed
@davideast davideast deleted the confidence/ctrl-c-to-exit branch September 23, 2025 22:45
vick08 pushed a commit to vick08/gemini-cli that referenced this pull request Sep 24, 2025
thacio added a commit to thacio/auditaria that referenced this pull request Oct 4, 2025
giraffe-tree pushed a commit to giraffe-tree/gemini-cli that referenced this pull request Oct 10, 2025
@sripasg sripasg added the size/m A medium sized PR label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m A medium sized PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants