Skip to content

test(sea): fix permission mock failure on windows runners#24973

Open
dogukanozen wants to merge 1 commit intogoogle-gemini:mainfrom
dogukanozen:fix/sea-launch-windows-tests
Open

test(sea): fix permission mock failure on windows runners#24973
dogukanozen wants to merge 1 commit intogoogle-gemini:mainfrom
dogukanozen:fix/sea-launch-windows-tests

Conversation

@dogukanozen
Copy link
Copy Markdown
Contributor

@dogukanozen dogukanozen commented Apr 8, 2026

Summary

This PR fixes a bug where the sea-launch.test.js file fails on Windows CI runners due to missing POSIX-environment mocks, ensuring robust and platform-agnostic test assertions.

Details

The prepareRuntime test "recreates runtime if existing has wrong permissions" evaluates POSIX mode permissions (0o700 vs 0o777). However, the isSecure function in sea-launch.cjs explicitly bypasses this mode check if process.platform === 'win32'. Because the test failed to mock the platform as linux, native Windows runners evaluated the platform as win32, skipped the POSIX check, and returned true, causing the expected file deletion (rmSync) to never occur and the test to fail.
This fix injects an Object.defineProperty(process, 'platform', { value: 'linux' }) wrapper into the isolated test, ensuring the assertion securely evaluates the permissions check logic regardless of the runner's native host OS.

Related Issues

Closes #24965

How to Validate

  1. Checkout this branch on a Windows machine.
  2. Run npm run test:sea-launch or vitest run sea/sea-launch.test.js.
  3. Verify that the tests pass successfully, specifically recreates runtime if existing has wrong permissions.

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

@dogukanozen dogukanozen requested a review from a team as a code owner April 8, 2026 21:13
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 addresses a test failure occurring on Windows CI environments. By forcing the platform to 'linux' during a specific test case, the code ensures that the runtime permission validation logic is correctly exercised regardless of the host operating system, preventing false negatives.

Highlights

  • Platform Mocking: Added a mock for process.platform to force 'linux' during the runtime permission test.
  • Test Stability: Ensured the test correctly evaluates POSIX permission logic on Windows runners by bypassing the platform-specific check.
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.

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.

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 modifies the sea-launch.test.js file to mock the process.platform property during a test case. The review feedback correctly identifies a risk of test leakage where the global process state might not be restored if an assertion fails. It is recommended to wrap the test logic in a try...finally block to ensure the original platform value is always restored, maintaining test isolation and reliability.

@dogukanozen dogukanozen force-pushed the fix/sea-launch-windows-tests branch from 96472e0 to a485768 Compare April 8, 2026 21:22
@gemini-cli gemini-cli bot added the area/platform Issues related to Build infra, Release mgmt, Testing, Eval infra, Capacity, Quota mgmt label Apr 8, 2026
@dogukanozen
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 updates the sea-launch.test.js file to wrap a permission-related test case in a try...finally block, ensuring that the process.platform global is correctly restored after being mocked as 'linux'. Feedback focuses on improving the robustness of this mock by capturing and restoring the full property descriptor of process.platform rather than just its value, and suggests using path.posix to ensure consistent path behavior across different operating systems during the test.

@dogukanozen dogukanozen force-pushed the fix/sea-launch-windows-tests branch from a485768 to c90952e Compare April 8, 2026 21:34
@dogukanozen
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 updates the sea-launch.test.js file to explicitly mock process.platform as 'linux' within the 'recreates runtime if existing has wrong permissions' test case. The implementation uses Object.defineProperty and a try...finally block to ensure the environment is correctly restored after the test. Additionally, the test dependencies now utilize path.posix for consistent path handling. I have no feedback to provide.

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

Labels

area/platform Issues related to Build infra, Release mgmt, Testing, Eval infra, Capacity, Quota mgmt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(sea): sea-launch runtime permissions test fails on Windows runners due to missing platform mock

1 participant