@@ -3,6 +3,7 @@ import os from 'os';
33
44import { runTests } from '@vscode/test-electron' ;
55import { TestOptions } from '@vscode/test-electron/out/runTest' ;
6+ import { mkdtemp } from 'fs' ;
67
78async function main ( ) {
89 // The folder containing the Extension Manifest package.json
@@ -28,37 +29,52 @@ async function main() {
2829 `test/workspaces/${ testsuite } `
2930 ) ;
3031
31- const testOptions : TestOptions = {
32- extensionDevelopmentPath,
33- extensionTestsPath,
34- // --user-data-dir is set to the OS default directory for temporary files to avoid
35- // warnings related to longs paths in IPC sockets created by VSCode.
36- launchArgs : [ '--user-data-dir' , `${ os . tmpdir ( ) } ` , testWorkspace ] ,
37- } ;
38- if ( process . env . VSCODE ) {
39- // If specified, use the VSCode executable provided externally. This
40- // can be use to test with an externally installed VS Code version
41- // such as in a CI environment for example.
42- //
43- // The expected value is the path to <install-dir>/code and not
44- // <install-dir>/bin/code.
45- testOptions . vscodeExecutablePath = process . env . VSCODE ;
46- } else {
47- // Otherwise download the latest stable version and test using that.
48- testOptions . version = 'stable' ;
49- }
32+ await new Promise < void > ( ( resolve ) => {
33+ mkdtemp ( `${ os . tmpdir ( ) } /vsc-ada-test-` , ( err , folder ) => {
34+ if ( err ) throw err ;
35+
36+ const testOptions : TestOptions = {
37+ extensionDevelopmentPath : extensionDevelopmentPath ,
38+ extensionTestsPath : extensionTestsPath ,
39+ // --user-data-dir is set to a unique dirctory under the OS
40+ // default tmp directory for temporary files to avoid
41+ // warnings related to longs paths in IPC sockets created by
42+ // VSCode. The directory is made unique to avoid
43+ // interference between successive runs.
44+ launchArgs : [ '--user-data-dir' , folder , testWorkspace ] ,
45+ } ;
46+ if ( process . env . VSCODE ) {
47+ // If specified, use the VSCode executable provided externally. This
48+ // can be use to test with an externally installed VS Code version
49+ // such as in a CI environment for example.
50+ //
51+ // The expected value is the path to <install-dir>/code and not
52+ // <install-dir>/bin/code.
53+ testOptions . vscodeExecutablePath = process . env . VSCODE ;
54+ } else {
55+ // Otherwise download the latest stable version and test using that.
56+ testOptions . version = 'stable' ;
57+ }
5058
51- // Catch any errors running this testsuite, but continue running the remaining ones.
52- try {
53- // Download and unzip VS Code (if it has not been done before), and run this testsuite.
54- await runTests ( testOptions ) ;
55- } catch ( err ) {
56- console . error ( err ) ;
57- console . error ( `Failed to run ${ testsuite } testsuite` ) ;
58- // If this testsuite failed, flag it so that we can exit with a non zero error code
59- // later.
60- someTestsuiteFailed = true ;
61- }
59+ console . info ( 'Calling runTests with: ' + JSON . stringify ( testOptions , undefined , 2 ) ) ;
60+ // Download and unzip VS Code (if it has not been done before),
61+ // and run this testsuite.
62+ runTests ( testOptions )
63+ . then ( ( ) => {
64+ resolve ( ) ;
65+ } )
66+ . catch ( ( err ) => {
67+ // Catch any errors running this testsuite, to continue
68+ // running the remaining testsuites.
69+ console . error ( err ) ;
70+ console . error ( `Failed to run ${ testsuite } testsuite` ) ;
71+ // If this testsuite failed, flag it so that we can exit
72+ // with a non zero error code later.
73+ someTestsuiteFailed = true ;
74+ resolve ( ) ;
75+ } ) ;
76+ } ) ;
77+ } ) ;
6278 }
6379
6480 if ( someTestsuiteFailed ) {
0 commit comments