22// Licensed under the MIT license.
33
44import * as cp from "child_process" ;
5+ import * as fs from "fs" ;
56import * as os from "os" ;
67import * as path from "path" ;
7- import { downloadAndUnzipVSCode , resolveCliPathFromVSCodeExecutablePath , runTests } from "vscode- test" ;
8+ import { downloadAndUnzipVSCode , resolveCliArgsFromVSCodeExecutablePath , runTests } from "@ vscode/ test-electron " ;
89
910async 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