Skip to content

test(integration): fix windows integration issues for hook tests#18449

Closed
abhipatel12 wants to merge 5 commits intomainfrom
abhi/windows-integration-fix
Closed

test(integration): fix windows integration issues for hook tests#18449
abhipatel12 wants to merge 5 commits intomainfrom
abhi/windows-integration-fix

Conversation

@abhipatel12
Copy link
Copy Markdown
Contributor

Summary

Fixes integration tests (hooks-agent-flow.test.ts and hooks-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:

  • Shell Quoting/Escaping: Replaced brittle inline node -e commands with external .cjs script files to avoid PowerShell quoting issues that caused hangs and timeouts.
  • Path Escaping: Normalized all paths injected into commands/scripts to forward slashes to prevent backslashes from being interpreted as escape characters (e.g., , ) by Node.js.
  • Initialization Race Conditions: Ensured rig.setup() is called before accessing rig.testDir or performing file operations to correctly initialize the test directory.
  • Settings Schema Compliance: Corrected the hooks settings structure by moving the enabled flag to hooksConfig.

Related Issues

Related to #123

How to Validate

Run the integration tests in a Windows environment (or macOS/Linux to ensure no regressions):

npm run bundle
npm run test:e2e hooks-agent-flow.test.ts hooks-system.test.ts

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

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.
@abhipatel12 abhipatel12 requested a review from a team as a code owner February 6, 2026 17:19
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @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

  • Windows Integration Test Fixes: Resolved integration test failures on Windows by addressing platform-specific path and shell handling differences in hooks-agent-flow.test.ts and hooks-system.test.ts.
  • Shell Quoting/Escaping: Replaced brittle inline node -e commands with external .cjs script files to avoid PowerShell quoting issues that caused test hangs and timeouts.
  • Path Escaping Normalization: Normalized all paths injected into commands/scripts to use forward slashes, preventing backslashes from being misinterpreted as escape characters by Node.js on Windows.
  • Initialization Race Conditions: Ensured rig.setup() is consistently called before accessing rig.testDir or performing file operations, correctly initializing the test directory and preventing race conditions.
  • Settings Schema Compliance: Corrected the hooks settings structure by moving the enabled flag into a hooksConfig object for proper schema compliance.
Changelog
  • integration-tests/hooks-agent-flow.test.ts
    • Replaced inline node -e commands with references to dynamically created external .cjs script files for various hook tests.
    • Implemented path normalization using .replace(/\\/g, '/') for all script paths to ensure cross-platform compatibility.
    • Adjusted the hooks settings structure to nest the enabled flag within a hooksConfig property.
    • Ensured rig.setup() is called before accessing rig.testDir to guarantee proper test environment initialization.
  • integration-tests/hooks-system.test.ts
    • Converted numerous inline node -e commands into references to external .cjs script files for various hook test scenarios (e.g., blocking behavior, additional context, sequential execution, error handling, telemetry, session lifecycle, compression).
    • Applied path normalization (.replace(/\\/g, '/')) to all script paths used in command execution.
    • Refactored test setups to ensure rig.setup() is invoked prior to any operations involving rig.testDir.
Activity
  • The author abhipatel12 initiated this pull request to resolve integration test failures on Windows.
  • The pull request description provides a comprehensive breakdown of the issues and their respective solutions.
  • The author has confirmed that relevant documentation and tests have been updated.
  • Validation has been performed on MacOS using npm run.
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-cli gemini-cli bot added the priority/p1 Important and should be addressed in the near term. label Feb 6, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 6, 2026

Size Change: -2 B (0%)

Total Size: 23.8 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 23.8 MB -2 B (0%)
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB 0 B
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B

compressed-size-action

Copy link
Copy Markdown
Contributor

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

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 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.
@abhipatel12
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

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

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 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.
@abhipatel12
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

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

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 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.
@abhipatel12
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

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

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 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.
@abhipatel12
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

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

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 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority/p1 Important and should be addressed in the near term.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant