gemini-cli
gemini-cli copied to clipboard
Isolate home and working directories in TestRig
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:
TestRignow generates a uniquetestDirusing 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) andhomeDir(for user-specific configuration) within the unique test path. - Environment Variable Overrides:
TestRignow automatically overridesHOME,USERPROFILE, andGEMINI_CONFIG_DIRto point to the isolatedhomeDir. - Config Redirection: The
.geminisettings directory is now correctly placed inside the isolatedhomeDirrather than theworkDir. - Test Migration: Updated all existing integration tests to utilize
rig.workDirand 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
- [x] MacOS