test(integration): Add "Ctrl + C" to exit integration test#9272
Conversation
Introduces an integration test to verify the 'Ctrl+C' exit behavior.
Summary of ChangesHello @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
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
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
runInteractivemethod to theTestRigclass inintegration-tests/test-helper.ts. This method uses@lydell/node-ptyto create a pseudo-terminal for testing interactive features.The new test file,
integration-tests/ctrl-c-exit.test.ts, performs the following:Ctrl+Csignal and asserts that the "Press Ctrl+C again to exit" prompt is displayed.Ctrl+Csignal and confirms that the application exits gracefully with the correct message.Reviewer Test Plan
To validate the changes, please follow these steps:
npm installto ensure all dependencies are correctly installed.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
Linked issues / bugs
#9127