gemini-cli - ✅(Solved) Fix test(sea): sea-launch runtime permissions test fails on Windows runners due to missing platform mock [2 pull requests, 2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#24965Fetched 2026-04-09 08:16:44
View on GitHub
Comments
2
Participants
2
Timeline
8
Reactions
0
Timeline (top)
commented ×2cross-referenced ×2labeled ×2mentioned ×1

The test "recreates runtime if existing has wrong permissions" inside sea/sea-launch.test.js unexpectedly fails when executed on native Windows environments (like windows-latest CI runners). Root Cause: In sea-launch.cjs, the isSecure function intentionally bypasses POSIX mode permission checks ((stat.mode & 0o777) !== 0o700) when process.platform === 'win32'. However, the test file neglects to mock process.platform to a non-win32 system (like linux) for this specific scenario. Thus, when the test runs natively on a Windows machine, isSecure skips the POSIX check and returns true. Consequently, prepareRuntime uses the "existing" runtime instead of recreating it, causing the assertion expect(deps.fs.rmSync).toHaveBeenCalledWith(...) to fail with 0 calls.

Root Cause

Description

The test "recreates runtime if existing has wrong permissions" inside sea/sea-launch.test.js unexpectedly fails when executed on native Windows environments (like windows-latest CI runners). Root Cause: In sea-launch.cjs, the isSecure function intentionally bypasses POSIX mode permission checks ((stat.mode & 0o777) !== 0o700) when process.platform === 'win32'. However, the test file neglects to mock process.platform to a non-win32 system (like linux) for this specific scenario. Thus, when the test runs natively on a Windows machine, isSecure skips the POSIX check and returns true. Consequently, prepareRuntime uses the "existing" runtime instead of recreating it, causing the assertion expect(deps.fs.rmSync).toHaveBeenCalledWith(...) to fail with 0 calls.

Expected Behavior

Tests that specifically evaluate POSIX-permission validations (mode: 0o777 vs 0o700) must explicitly mock process.platform to a non-Windows OS (e.g., linux) to prevent environmental differences from breaking the test suite on Windows machines.

Proposed Solution

I am opening a PR momentarily to inject the missing Object.defineProperty(process, 'platform', { value: 'linux' }) mock into the related sea-launch tests.

Fix Action

Fixed

PR fix notes

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

Description (problem / solution / changelog)

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

Changed files

  • packages/cli/src/ui/components/SettingsDialog.test.tsx (modified, +1/-1)
  • packages/cli/src/ui/components/shared/BaseSettingsDialog.test.tsx (modified, +1/-1)
  • packages/cli/src/ui/contexts/KeypressContext.test.tsx (modified, +85/-1)
  • packages/cli/src/ui/contexts/KeypressContext.tsx (modified, +14/-2)
  • sea/sea-launch.test.js (modified, +11/-0)

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

Description (problem / solution / changelog)

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

Changed files

  • sea/sea-launch.test.js (modified, +67/-49)
RAW_BUFFERClick to expand / collapse

Description

The test "recreates runtime if existing has wrong permissions" inside sea/sea-launch.test.js unexpectedly fails when executed on native Windows environments (like windows-latest CI runners). Root Cause: In sea-launch.cjs, the isSecure function intentionally bypasses POSIX mode permission checks ((stat.mode & 0o777) !== 0o700) when process.platform === 'win32'. However, the test file neglects to mock process.platform to a non-win32 system (like linux) for this specific scenario. Thus, when the test runs natively on a Windows machine, isSecure skips the POSIX check and returns true. Consequently, prepareRuntime uses the "existing" runtime instead of recreating it, causing the assertion expect(deps.fs.rmSync).toHaveBeenCalledWith(...) to fail with 0 calls.

Expected Behavior

Tests that specifically evaluate POSIX-permission validations (mode: 0o777 vs 0o700) must explicitly mock process.platform to a non-Windows OS (e.g., linux) to prevent environmental differences from breaking the test suite on Windows machines.

Proposed Solution

I am opening a PR momentarily to inject the missing Object.defineProperty(process, 'platform', { value: 'linux' }) mock into the related sea-launch tests.

extent analysis

TL;DR

Mocking process.platform to a non-Windows OS, such as 'linux', is likely to fix the test failure on Windows environments.

Guidance

  • To resolve the issue, inject a mock for process.platform in the sea-launch tests to simulate a non-Windows environment, allowing POSIX permission checks to be properly evaluated.
  • Verify the fix by running the test on a Windows machine or CI runner after applying the mock, ensuring the expect(deps.fs.rmSync).toHaveBeenCalledWith(...) assertion passes.
  • Consider adding similar mocks for other tests that rely on POSIX permission validations to prevent future test failures on Windows.
  • Review the proposed solution PR to ensure the Object.defineProperty(process, 'platform', { value: 'linux' }) mock is correctly implemented and does not introduce unintended side effects.

Example

// Example of mocking process.platform in a test
Object.defineProperty(process, 'platform', { value: 'linux' });

Notes

This solution assumes that mocking process.platform is sufficient to address the test failure and does not account for potential differences in behavior between Windows and non-Windows environments.

Recommendation

Apply the workaround by mocking process.platform to a non-Windows OS, as this directly addresses the identified root cause of the test failure.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING