Skip to content

Isolate the VS Code test harness from the user's extension install - #218

Open
Chiara Mooney (chiaramooney) wants to merge 1 commit into
mainfrom
chiaramooney-vsce-testing-isolated-extensions-dir
Open

Isolate the VS Code test harness from the user's extension install#218
Chiara Mooney (chiaramooney) wants to merge 1 commit into
mainfrom
chiaramooney-vsce-testing-isolated-extensions-dir

Conversation

@chiaramooney

Copy link
Copy Markdown
Collaborator

Why

The vsce-testing harness installed the locally built VSIX into the developer's real VS Code extensions directory and then launched VS Code against that same directory. Because VS Code keeps an extension metadata cache there, stale metadata could survive between runs — so the harness could silently drive a different build than the one it had just built. Any run that hit that case produced results that looked fine but were untrustworthy.

What changed

  • Both scripts/install-extension.ps1 and scripts/drive-extension.ps1 now pin --extensions-dir to the harness-local .drive-extensions directory, so the harness never touches the developer's own VS Code install.
  • install-extension.ps1 uninstalls the registered microsoft-winappcli.winapp extension before reinstalling, so VS Code cannot reuse stale metadata.
  • The post-install check now asserts that the version VS Code reports back equals the version of the VSIX that was just built.

Behaviour change worth reviewing

The post-install check now throws where it previously warned — both when the extension is missing from code --list-extensions and when the reported version disagrees with the built VSIX. This is a deliberate fail-fast: a silent version mismatch invalidates every result the harness produces, so it should stop the run rather than scroll by. A previously noisy-but-passing run can now hard-fail.

Consistency note

.drive-extensions was not a new concept: it was already gitignored, already documented in the skill's README.md and AGENTS.md, and scripts/vscode-drive.psm1:184 already auto-added the flag. This just brings the two remaining scripts in line with what the rest of the harness already assumed.

Also included

queryDiagnostics in the driver extension now returns the diagnostic code, normalized from VS Code's { value, target } object form down to a scalar. Scripted steps can now assert on diagnostic codes instead of pattern-matching message text.

Note

Extracted from #50, where these three files landed by accident alongside the WinUI XAML language-service work. Diff is exactly 3 files, +31/-4.

The harness installed the locally built VSIX into the developer's real
VS Code extensions directory and launched VS Code against it. That let a
stale extension metadata cache survive between runs, so the harness could
silently drive a different build than the one it had just built.

Pin both the install and the launch to the harness-local
.drive-extensions directory, which the skill's .gitignore, README, and
AGENTS.md already describe and which vscode-drive.psm1 already prefers.
Uninstall the registered extension before reinstalling so VS Code cannot
reuse stale metadata, and assert that the version it reports back matches
the VSIX just built -- failing loudly instead of warning, since a silent
version mismatch invalidates every result the harness produces.

Also surface the diagnostic code from queryDiagnostics, normalizing the
{value, target} object form to a scalar, so scripted steps can assert on
diagnostic codes rather than matching message text.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 0a32116a-78ec-415a-aa5e-f98a06c74e9d
@chiaramooney

Copy link
Copy Markdown
Collaborator Author

Extracted from #50, which no longer touches .github/skills/. These three files are independent of that PR's XAML language service work: nothing under src/ references the harness, and no workflow in .github/workflows invokes these scripts, so they can merge in either order.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

VSIX Build

Artifact Baseline Current Delta
VS Code Extension (VSIX) 27.88 MB 27.88 MB 📉 -0.0 KB (-0.00%)

Updated 2026-09-02 17:20:08 UTC · commit 0752870 · workflow run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant