gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

Isolate home and working directories in TestRig

Open scidomino opened this issue 1 month ago • 3 comments

Summary

Isolates the environment for integration tests by providing each test run with a unique working directory and a dedicated temporary home directory. This prevents test interference and eliminates dependencies on the host system's global configuration.

Details

  • Environment Isolation: TestRig now generates a unique testDir using a random UUID suffix for every setup call, preventing collisions between parallel or repeated test runs.
  • Directory Separation: Introduced workDir (the CWD for test execution) and homeDir (for user-specific configuration) within the unique test path.
  • Environment Variable Overrides: TestRig now automatically overrides HOME, USERPROFILE, and GEMINI_CONFIG_DIR to point to the isolated homeDir.
  • Config Redirection: The .gemini settings directory is now correctly placed inside the isolated homeDir rather than the workDir.
  • Test Migration: Updated all existing integration tests to utilize rig.workDir and benefit from the new isolation model.
  • Cleanup Improvements: Standardized setup/teardown in several test files (e.g., extensions-reload.test.ts) using Vitest hooks to ensure reliable cleanup.

Related Issues

Related to #14527 related to #14531

How to Validate

Run the integration test suite to ensure all tests pass in the new isolated environment:

npm test --workspace packages/cli -- integration-tests/

Verify that .gemini directories and telemetry logs are now created within unique paths under .integration-tests/ instead of potentially clobbering each other.

Pre-Merge Checklist

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

scidomino avatar Dec 11 '25 20:12 scidomino

Summary of Changes

Hello @scidomino, I'm Gemini Code Assist[^1]! 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 enhances the robustness and isolation of the integration test suite. By introducing unique home and working directories for each TestRig instance, it eliminates potential side effects and state leakage between tests, leading to more reliable and reproducible test results. The changes involve refactoring the TestRig class to manage these new directories and updating existing tests to utilize the new directory structure and centralized setup/teardown mechanisms.

Highlights

  • Enhanced Test Isolation: Each TestRig instance now operates within a unique and isolated home directory and working directory, preventing test interference and ensuring a clean state for every integration test run.
  • Test Rig Refactoring: The TestRig class has been refactored to manage distinct workDir and homeDir properties. Environment variables like HOME, USERPROFILE, and GEMINI_CONFIG_DIR are now overridden to point to these unique directories, ensuring proper isolation of configuration and user-specific files.
  • Centralized Test Setup/Teardown: Integration tests now utilize vitest's beforeEach and afterEach hooks to centralize the initialization and cleanup of the TestRig, simplifying individual test logic and improving consistency.
  • Path Updates Across Tests: Numerous file path constructions within integration tests have been updated to correctly reference the new workDir or homeDir properties of the TestRig, aligning with the new isolated directory structure.
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 :thumbsup: and :thumbsdown: 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.

[^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-code-assist[bot] avatar Dec 11 '25 20:12 gemini-code-assist[bot]

Size Change: -2 B (0%)

Total Size: 21.6 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 21.6 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

github-actions[bot] avatar Dec 11 '25 20:12 github-actions[bot]

/gemini review

scidomino avatar Dec 11 '25 20:12 scidomino