Files
vscode-cowriting-plugin/test/e2e/runTest.ts
T
BenStullsBets 930b4ab056 test(e2e): pin --user-data-dir to a short /tmp path (fix macOS socket-length EINVAL)
The default .vscode-test/user-data socket path exceeds macOS's ~103-char UNIX
socket limit when the repo lives at a long path (e.g. a git worktree), so the
host-E2E harness failed to launch (listen EINVAL). Point --user-data-dir at a
short /tmp root so the IPC socket stays under the limit.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 06:22:36 -07:00

50 lines
2.1 KiB
TypeScript

import * as path from "path";
import * as os from "os";
import * as fs from "fs";
import { runTests } from "@vscode/test-electron";
async function main(): Promise<void> {
const projectRoot = path.resolve(__dirname, "../../../");
const extensionDevelopmentPath = projectRoot;
const extensionTestsPath = path.resolve(__dirname, "./suite/index");
// Copy the fixture workspace to a temp dir so test writes are throwaway.
const fixture = path.resolve(projectRoot, "test/e2e/fixtures/workspace");
const workspace = fs.mkdtempSync(path.join(os.tmpdir(), "cowriting-e2e-"));
fs.cpSync(fixture, workspace, { recursive: true });
// VS Code derives its IPC socket path from --user-data-dir. The default
// (`<projectRoot>/.vscode-test/user-data`) plus `/<version>-main.sock` can blow
// past macOS's ~103-char UNIX-socket limit (`listen EINVAL`) when the project
// lives at a long path (e.g. a git worktree). Pin the user-data dir to a SHORT
// root under /tmp so the socket path stays well under the limit. (os.tmpdir() on
// macOS is itself a long /var/folders/… path, so we use /tmp directly.)
const userDataRoot = process.platform === "win32" ? os.tmpdir() : "/tmp";
const userDataDir = fs.mkdtempSync(path.join(userDataRoot, "cwud-"));
try {
await runTests({
extensionDevelopmentPath,
extensionTestsPath,
launchArgs: [workspace, "--disable-extensions", "--user-data-dir", userDataDir],
extensionTestsEnv: { E2E_WORKSPACE: workspace },
});
// Second pass — NO workspace folder (regression for #8): commands must
// exist as warning stubs instead of erroring "command not found".
await runTests({
extensionDevelopmentPath,
extensionTestsPath: path.resolve(__dirname, "./suite-no-workspace/index"),
launchArgs: ["--disable-extensions", "--user-data-dir", userDataDir],
});
} finally {
fs.rmSync(workspace, { recursive: true, force: true });
fs.rmSync(userDataDir, { recursive: true, force: true });
}
}
main().catch((err) => {
console.error("E2E run failed:", err);
process.exit(1);
});