Skip to content

Commit 3ee3afd

Browse files
authored
chore: Update test framework to @vscode/test-electron (#659)
1 parent c041250 commit 3ee3afd

File tree

3 files changed

+52
-48
lines changed

3 files changed

+52
-48
lines changed

package-lock.json

Lines changed: 37 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,14 +649,14 @@
649649
"@types/node": "^14.18.21",
650650
"@types/semver": "^7.3.10",
651651
"@types/vscode": "1.66.0",
652+
"@vscode/test-electron": "^2.1.5",
652653
"copy-webpack-plugin": "^9.1.0",
653654
"glob": "^7.2.3",
654655
"mocha": "^9.2.2",
655656
"ts-loader": "^9.3.1",
656657
"tslint": "^6.1.3",
657658
"typescript": "^4.7.4",
658659
"vscode-extension-tester": "^4.3.0",
659-
"vscode-test": "^1.6.1",
660660
"webpack": "^5.73.0",
661661
"webpack-cli": "^4.10.0"
662662
},

test/index.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,23 @@
22
// Licensed under the MIT license.
33

44
import * as cp from "child_process";
5+
import * as fs from "fs";
56
import * as os from "os";
67
import * as path from "path";
7-
import { downloadAndUnzipVSCode, resolveCliPathFromVSCodeExecutablePath, runTests } from "vscode-test";
8+
import { downloadAndUnzipVSCode, resolveCliArgsFromVSCodeExecutablePath, runTests } from "@vscode/test-electron";
89

910
async function main(): Promise<void> {
1011
try {
12+
// test fails in macOS since the limitation of path length
13+
// See: https://github.com/microsoft/vscode/issues/86382#issuecomment-593765388
14+
const userDir = fs.mkdtempSync(path.join(os.tmpdir(), "vscode-user"));
1115
const vscodeExecutablePath = await downloadAndUnzipVSCode();
12-
const cliPath = resolveCliPathFromVSCodeExecutablePath(vscodeExecutablePath);
1316

1417
// Resolve redhat.java dependency
15-
cp.spawnSync(cliPath, ["--install-extension", "redhat.java"], {
16-
encoding: "utf-8",
17-
stdio: "inherit",
18+
const [cli, ...args] = resolveCliArgsFromVSCodeExecutablePath(vscodeExecutablePath);
19+
cp.spawnSync(cli, [...args, '--install-extension', 'redhat.java'], {
20+
encoding: 'utf-8',
21+
stdio: 'inherit'
1822
});
1923

2024
// The folder containing the Extension Manifest package.json
@@ -30,7 +34,7 @@ async function main(): Promise<void> {
3034
extensionTestsPath: path.resolve(__dirname, "./suite"),
3135
launchArgs: [
3236
path.join(__dirname, "..", "..", "test", "java9"),
33-
"--disable-workspace-trust",
37+
`--user-data-dir=${userDir}`,
3438
],
3539
});
3640

@@ -41,7 +45,7 @@ async function main(): Promise<void> {
4145
extensionTestsPath: path.resolve(__dirname, "./simple-suite"),
4246
launchArgs: [
4347
path.join(__dirname, "..", "..", "test", "simple"),
44-
"--disable-workspace-trust",
48+
`--user-data-dir=${userDir}`,
4549
],
4650
});
4751

@@ -52,7 +56,7 @@ async function main(): Promise<void> {
5256
extensionTestsPath: path.resolve(__dirname, "./maven-suite"),
5357
launchArgs: [
5458
path.join(__dirname, "..", "..", "test", "maven"),
55-
"--disable-workspace-trust",
59+
`--user-data-dir=${userDir}`,
5660
],
5761
});
5862

@@ -63,7 +67,7 @@ async function main(): Promise<void> {
6367
extensionTestsPath: path.resolve(__dirname, "./gradle-suite"),
6468
launchArgs: [
6569
path.join(__dirname, "..", "..", "test", "gradle"),
66-
"--disable-workspace-trust",
70+
`--user-data-dir=${userDir}`,
6771
],
6872
});
6973

@@ -74,7 +78,7 @@ async function main(): Promise<void> {
7478
extensionTestsPath: path.resolve(__dirname, "./invisible-suite"),
7579
launchArgs: [
7680
path.join(__dirname, "..", "..", "test", "invisible"),
77-
"--disable-workspace-trust",
81+
`--user-data-dir=${userDir}`,
7882
],
7983
});
8084

0 commit comments

Comments
 (0)