Skip to content

Move VS Code test isolates to the user cache - #14646

Merged
Sean McManus (sean-mcmanus) merged 4 commits into
mainfrom
seanmcm/devbox2-wsl/agent23/disk-backed-vscode-test-cache
Aug 7, 2026
Merged

Move VS Code test isolates to the user cache#14646
Sean McManus (sean-mcmanus) merged 4 commits into
mainfrom
seanmcm/devbox2-wsl/agent23/disk-backed-vscode-test-cache

Conversation

@sean-mcmanus

@sean-mcmanus Sean McManus (sean-mcmanus) commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

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_ROOT override, and documents cleanup of isolates created at the old location.

Linux memory impact

On Linux systems where /tmp is backed by tmpfs, 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 in tmpfs.

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.

This PR was investigated and created by Copilot with GPT-5.6 Sol (in VS Code). Any message starting with ✨Copilot: was sent by Copilot.

Validation

  • Compiled the TypeScript project.
  • Ran the focused VS Code test-isolate path suite (8 passing).
  • Ran ESLint on the touched TypeScript files.
  • Ran git diff --check.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread Extension/.scripts/vscodeTestPath.ts
Comment thread Extension/readme.developer.md Outdated
Comment thread Extension/readme.developer.md Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 .scripts directory path (__dirname from Extension/.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.

Comment thread Extension/.scripts/vscodeTestPath.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-root or /test-root, which makes the effective location depend on the process’s current drive. Since this path is later passed to rimraf() via isolated, it’s safer to require a fully-qualified drive/UNC root for CPPTOOLS_VSCODE_TEST_ROOT (and likewise for LOCALAPPDATA) 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;

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@sean-mcmanus
Sean McManus (sean-mcmanus) merged commit 9152b01 into main Aug 7, 2026
7 checks passed
@sean-mcmanus
Sean McManus (sean-mcmanus) deleted the seanmcm/devbox2-wsl/agent23/disk-backed-vscode-test-cache branch August 7, 2026 03:24
@github-project-automation github-project-automation Bot moved this from Pull Request to Done in cpptools Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants