test(integration): fix windows integration issues for hook tests#18449
test(integration): fix windows integration issues for hook tests#18449abhipatel12 wants to merge 5 commits intomainfrom
Conversation
Fixes several issues preventing integration tests from passing on Windows: - Replaces brittle inline 'node -e' commands with script files to avoid shell quoting issues in PowerShell. - Normalizes paths to forward slashes to prevent escape sequence misinterpretation in generated scripts. - Ensures rig.setup() is called before accessing rig.testDir to properly initialize test environment. - Corrects hooks settings structure (enabled moved to hooksConfig) to match schema validation.
Summary of ChangesHello @abhipatel12, 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 significantly improves the reliability of integration tests, particularly on Windows environments. It tackles fundamental issues related to how shell commands and file paths are interpreted across different operating systems. By externalizing inline scripts and standardizing path formats, the changes ensure consistent test execution and prevent platform-specific failures, making the test suite more robust and maintainable. Highlights
Changelog
Activity
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
|
|
Size Change: -2 B (0%) Total Size: 23.8 MB ℹ️ View Unchanged
|
There was a problem hiding this comment.
Code Review
This pull request effectively addresses Windows compatibility issues in the integration tests by normalizing paths and replacing inline shell commands with external scripts. The AI model's suggestion to refactor the rig.setup() pattern for better clarity and maintainability is valid and has been retained, as it aligns with general best practices for robust test suites and does not conflict with any provided rules.
…in TestRig - Refactor TestRig.setup to handle only directory creation by default. - Add TestRig.configure to apply settings and fake responses. - Update hook integration tests to use the new setup/configure pattern, avoiding brittle double setup calls.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request makes important changes to improve the reliability of integration tests on Windows. Replacing inline node -e commands with external scripts is a great move to avoid shell-specific quoting issues. The refactoring of TestRig to separate setup and configure also correctly addresses race conditions during test initialization.
However, I've found several instances in hooks-system.test.ts where the script path normalization (converting backslashes to forward slashes) is missing. This is inconsistent with other parts of the change and will likely cause the tests to fail on Windows, which undermines the goal of this PR. I've left specific comments on where to add the normalization. Addressing these is critical for the PR to be effective.
…ization - Refactor all remaining rig.setup calls to use the new setup/configure pattern. - Consistently normalize all script paths to forward slashes for Windows compatibility. - Ensure proper ordering of rig.setup and rig.configure in all tests.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request effectively addresses Windows integration test failures by replacing inline node -e commands with external script files to prevent shell quoting issues, normalizing paths for cross-platform compatibility, and refactoring the test setup to avoid race conditions. The changes are solid. I have one suggestion to improve maintainability and security by abstracting the repeated logic for creating and normalizing script paths into a helper method, which would reduce code duplication, inconsistency, and enhance path validation for file system operations across the test files.
- Ensure all hook tests use rig.createHookScript for consistent path normalization. - Remove unused writeFileSync and readFileSync imports from integration tests. - Fix assertions in 'input override' test to match new .cjs extension and be more robust.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request effectively addresses integration test failures on Windows by refactoring how hook scripts are created and executed. The introduction of the createHookScript helper and the separation of setup and configure in the TestRig are solid improvements that enhance robustness and maintainability. The changes correctly replace brittle inline node -e commands with external script files, resolving shell quoting issues.
I've found one minor issue regarding redundant path normalization that should be addressed for consistency. Otherwise, the changes are well-implemented and align with the goal of improving cross-platform test stability.
Removes unnecessary .replace(/\\/g, '/') calls in hooks-system.test.ts since the createHookScript helper now handles path normalization internally.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request effectively addresses integration test failures on Windows by refactoring the test setup and hook execution logic. The introduction of the TestRig.configure method and its separation from setup correctly resolves initialization race conditions. Replacing brittle inline node -e commands with external script files, created via the new createHookScript helper, is a robust solution for cross-platform shell quoting and path escaping issues. The changes are consistently applied across all relevant tests, and the correction to the hooks settings schema is also a welcome fix. The overall code quality is high, and the changes successfully achieve the goal of improving test reliability on Windows.
Summary
Fixes integration tests (
hooks-agent-flow.test.tsandhooks-system.test.ts) that were failing on Windows due to platform-specific path and shell handling differences.Details
The fixes address the following root causes:
node -ecommands with external.cjsscript files to avoid PowerShell quoting issues that caused hangs and timeouts.,) by Node.js.rig.setup()is called before accessingrig.testDiror performing file operations to correctly initialize the test directory.hookssettings structure by moving theenabledflag tohooksConfig.Related Issues
Related to #123
How to Validate
Run the integration tests in a Windows environment (or macOS/Linux to ensure no regressions):
Pre-Merge Checklist