testVscodeRegistersNoServerCommands
the VS Code extension registers none of the commands the server offers (its client registers those)
import { plainEnv, tcmBin, withChildren } from "#codebase/tcmts/cli/test/e2e/harness"; import { client } from "#codebase/tcmts/cli/test/e2e/lsp"; import assert from "node:assert/strict"; import { spawnSync } from "node:child_process"; import fs from "node:fs"; import path from "node:path"; export const testVscodeRegistersNoServerCommands = () => withChildren(async (keep) => { const c = client(keep); const init = await c.request("initialize", { processId: null, rootUri: null, capabilities: {}, clientInfo: { name: "Visual Studio Code" }, }); const offered: string[] = init.capabilities.executeCommandProvider.commands; // (its code, from the codebase this runs in: its view, which any tcm reads, even across a change of hash format) const view = path.join( process.cwd(), ".tcm", "src", "tcmts", "vscode", "extension", "activate.ts", ); const extension = fs.existsSync(view) ? fs.readFileSync(view, "utf8") : spawnSync(process.execPath, [tcmBin(), "view", "tcmts.vscode.extension.activate"], { cwd: process.cwd(), env: plainEnv(), encoding: "utf8", }).stdout; const registered = [...extension.matchAll(/registerCommand\("([^"]+)"/g)].map((m) => m[1]); assert.ok(registered.length > 10); assert.deepEqual( registered.filter((r) => offered.includes(r)), [], "both registering one fails the client's start: 'command already exists'", ); await c.request("shutdown", null); })