Move VS Code test isolates to the user cache - #14646
Conversation
There was a problem hiding this comment.
Pull request overview
This PR moves the retained VS Code test isolate directory from the system temp location to a disk-backed, per-user cache location (with a CPPTOOLS_VSCODE_TEST_ROOT override), and adds unit coverage + developer documentation for the new behavior.
Changes:
- Introduce
getVSCodeTestIsolate()to compute a stable, per-worktree isolate root under platform user cache locations (or an override). - Update the VS Code test harness script to use the new isolate path helper.
- Add unit tests for platform-specific path selection and update developer docs (including guidance about old temp-based isolates).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| Extension/test/unit/vscodeTestPath.test.ts | Adds unit tests covering isolate root selection across Linux/macOS/Windows and override behavior. |
| Extension/readme.developer.md | Documents new per-user cache locations, override, and old temp isolate cleanup guidance. |
| Extension/.scripts/vscodeTestPath.ts | Adds the isolate path computation helper used by scripts and tests. |
| Extension/.scripts/vscode.ts | Switches isolate root computation from temp-based pathing to getVSCodeTestIsolate(__dirname). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Suppressed comments (4)
Extension/test/unit/vscodeTestPath.test.ts:42
- Similarly, add a test for the case where LOCALAPPDATA is present but not absolute. This prevents the isolate root from being computed relative to the current working directory on Windows.
it('uses LOCALAPPDATA on Windows', () => {
assert.strictEqual(
getVSCodeTestIsolate(windowsScriptDirectory, 'win32', { LOCALAPPDATA: 'D:\\LocalAppData' }, 'C:\\Users\\developer'),
win32.resolve('D:\\LocalAppData', 'Microsoft', 'vscode-cpptools', 'vscode-test', getWorktreeHash(windowsScriptDirectory)));
});
Extension/test/unit/vscodeTestPath.test.ts:30
- Add coverage for the behavior when XDG_CACHE_HOME is set but not an absolute path. With the current logic, a relative value would resolve relative to CWD; tests should lock in the safer fallback to ~/.cache.
This issue also appears on line 38 of the same file.
it('uses XDG_CACHE_HOME on Linux', () => {
assert.strictEqual(
getVSCodeTestIsolate(posixScriptDirectory, 'linux', { XDG_CACHE_HOME: '/cache' }, '/home/developer'),
posix.resolve('/cache', 'vscode-cpptools', 'vscode-test', getWorktreeHash(posixScriptDirectory)));
});
Extension/readme.developer.md:87
- The Windows cache-path examples mix forward slashes and backslashes. Since the implementation uses win32 path resolution, keep the documentation consistent and use Windows separators for the %LOCALAPPDATA% example as well.
* Windows: `%LOCALAPPDATA%/Microsoft/vscode-cpptools/vscode-test/<UID>` (or
`%USERPROFILE%\AppData\Local\Microsoft\vscode-cpptools\vscode-test\<UID>` if `%LOCALAPPDATA%` is unavailable)
Extension/readme.developer.md:95
- The docs say the hash is calculated from the "extension folder", but the implementation hashes the
.scriptsdirectory path (__dirnamefromExtension/.scripts). Either adjust the docs to match, or change the hash input if the extension root is intended.
`<UID>` is a six-character hash calculated from the extension folder. This permits multiple
checkouts of the source repository, with each checkout retaining its own isolated `cache`,
`extensions`, and `user-data` folders across runs. Set `CPPTOOLS_VSCODE_TEST_ROOT` to an absolute
directory to override the platform-specific `vscode-test` root; the checkout-specific `<UID>` is
still appended to the override.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (1)
Extension/.scripts/vscodeTestPath.ts:31
- On Windows,
path.win32.isAbsolute()returns true for root-relative paths like\\test-rootor/test-root, which makes the effective location depend on the process’s current drive. Since this path is later passed torimraf()viaisolated, it’s safer to require a fully-qualified drive/UNC root forCPPTOOLS_VSCODE_TEST_ROOT(and likewise forLOCALAPPDATA) rather than accepting drive-ambiguous roots.
if (override) {
if (!path.isAbsolute(override)) {
throw new Error('CPPTOOLS_VSCODE_TEST_ROOT must be an absolute path.');
}
root = override;
Summary
Move retained isolated VS Code test environments from the system temporary directory to each platform's disk-backed per-user cache. This preserves stable per-worktree isolation, adds a
CPPTOOLS_VSCODE_TEST_ROOToverride, and documents cleanup of isolates created at the old location.Linux memory impact
On Linux systems where
/tmpis backed bytmpfs, the retained test environment consumes RAM for as long as its files remain there. A complete isolate is approximately 1.5 GiB, including the downloaded VS Code build, installed extension, and user-data profile. Because every worktree intentionally has its own isolate, eight active worktrees can retain roughly 12 GiB intmpfs.This usage is retained filesystem data rather than a large Node.js heap. Moving the isolates to an ordinary per-user cache filesystem allows the operating system to reclaim cached pages under memory pressure while preserving the existing reuse behavior.
Validation
git diff --check.