import * as path from 'path' ; import { runTests , downloadAndUnzipVSCode } from 'vscode-test' ; import { randomBytes } from 'crypto' ; const extensionDevelopmentPath = path . resolve ( __dirname , '../../../../.dist' ) ; console . info ( `Loading extension from '${ extensionDevelopmentPath }'` ) ; interface TestCase { workspace ? : string ; testRunner : string ; } ( async ( ) : Promise < void > => { const testCases = [ { testRunner : './contexts/no_workspace_no_ruleset/configuration' , workspace : undefined , } , ] ; try { const vscodeExecutablePath = await downloadAndUnzipVSCode ( '1.48.0' ) ; for ( const tc of testCases ) { console . info ( `Using VSCode from '${ vscodeExecutablePath }'` ) ; tc . testRunner = path . resolve ( __dirname , tc . testRunner ) ; console . info ( `Using test runner from '${ tc . testRunner }'` ) ; const launchArgs = [ ] ; if ( tc . workspace !== undefined ) { tc . workspace = path . resolve ( __dirname , tc . workspace ) ; } else { tc . workspace = `blank_${ randomBytes ( 8 ) . toString ( 'hex' ) }` ; } launchArgs . push ( tc . workspace ) ; console . info ( `Using workspace '${ tc . workspace }'` ) ; launchArgs . push ( '--disable-extensions' ) ; console . info ( `Using launchArgs: ${ JSON . stringify ( launchArgs ) }` ) ; await runTests ( { vscodeExecutablePath , extensionDevelopmentPath , extensionTestsPath : tc . testRunner , launchArgs , } ) ; } } catch ( err ) { console . error ( 'Failed to run tests:' , err ) ; process . exit ( 1 ) ; } } ) ( ) ;