// SPDX-License-Identifier: AGPL-3.0-only 'use strict'; const fs = require('node:fs'); const os = require('node:os'); const path = require('node:path'); const {downloadAndUnzipVSCode, runTests} = require('@vscode/test-electron'); (async () => { const extensionDevelopmentPath = path.resolve(__dirname, '..', '..'); const sourceWorkspace = path.join(extensionDevelopmentPath, 'test', 'workspace'); // macOS exposes its temporary tree through /var, which is a symlink to // /private/var. Hime-san intentionally rejects user-supplied workspace roots // reached through symlinks, so make this test-owned path physical before it // crosses the LSP boundary. const temporaryRoot = process.platform === 'darwin' ? '/private/tmp' : fs.realpathSync(os.tmpdir()); const temporary = fs.realpathSync(fs.mkdtempSync(path.join(temporaryRoot, 'himesan-vscode-integration-'))); const workspace = path.join(temporary, 'project [safe]'); const userData = path.join(temporary, 'user-data'); fs.cpSync(sourceWorkspace, workspace, {recursive: true}); try { const vscodeExecutablePath = await downloadAndUnzipVSCode('1.96.4'); await runTests({ vscodeExecutablePath, extensionDevelopmentPath, extensionTestsPath: path.join(__dirname, 'suite', 'index.js'), launchArgs: [workspace, `--user-data-dir=${userData}`, '--disable-extensions', '--disable-gpu', '--skip-welcome', '--skip-release-notes'], extensionTestsEnv: {HIMESAN_TEST_BINARY: process.env.HIMESAN_TEST_BINARY || ''}, }); } finally { fs.rmSync(temporary, {recursive: true, force: true}); } })().catch((error) => { console.error(error); process.exitCode = 1; });