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