import * as path from 'path' ; import { runTests } from 'vscode-test' ; import { URI } from 'vscode-uri' ; import { utils } from 'pddl-workspace' ; import * as tmp from 'tmp-promise' ; import { TestOptions } from 'vscode-test/out/runTest' ; async function main ( ) { try { const extensionDevelopmentPath = path . resolve ( __dirname , '../../' ) ; const extensionTestsPath = path . resolve ( __dirname , './suite/index' ) ; const vsCodeVersions = [ 'stable' ] ; const options = { extensionDevelopmentPath : extensionDevelopmentPath , extensionTestsPath : extensionTestsPath } ; for ( const version of vsCodeVersions ) { await runTestsInEmptyWorkspaceFolder ( options , version , [ "--disable-extensions" ] ) ; } } catch ( err ) { const error = err as Error ; console . error ( 'Failed to run tests:' + ( error . message ?? err ) ) ; process . exit ( 1 ) ; } } async function runTestsInEmptyWorkspaceFolder ( options , version , launchArgs ) { options . version = version ; const workspaceFolderName = `pddl-test-workspace-folder_${ version }_` ; console . log ( `Creating temp workspace folder: ${ workspaceFolderName }` ) ; const workspaceFolder = await tmp . dir ( { prefix : workspaceFolderName } ) ; const userProfileFolderName = `vscode-user-settings_${ version }_` ; console . log ( `Creating temp user profile folder: ${ userProfileFolderName }` ) ; const userDataDir = await tmp . dir ( { prefix : userProfileFolderName } ) ; console . log ( `Creating the 'User' sub-folder: ${ path . join ( userDataDir . path , 'User' ) }` ) ; await utils . afs . mkdirIfDoesNotExist ( path . join ( userDataDir . path , 'User' ) , { recursive : true } ) ; console . log ( `Created 'User' sub-folder` ) ; options . launchArgs = launchArgs . concat ( [ "--folder-uri=" + URI . file ( workspaceFolder . path ) , "--user-data-dir=" + userDataDir . path ] ) ; console . log ( `Calling vscode-test ${ version } with arguments: ` ) ; console . dir ( options ) ; return await runTests ( options ) ; } main ( ) ;