@@ -7,59 +7,61 @@ import * as path from 'path';
77import * as fs from "fs" ;
88import {
99 downloadAndUnzipVSCode ,
10- resolveCliPathFromVSCodeExecutablePath ,
10+ resolveCliArgsFromVSCodeExecutablePath ,
1111 runTests
12- } from 'vscode- test' ;
12+ } from '@ vscode/ test-electron ' ;
1313
14- async function main ( ) {
15- try {
16- const extensionDevelopmentPath = path . resolve ( __dirname , '../../../' ) ;
17- const extensionTestsPath = path . resolve ( __dirname , './suite/index' ) ;
18- const vscodeExecutablePath = await downloadAndUnzipVSCode ( 'stable' ) ;
19- const cliPath = resolveCliPathFromVSCodeExecutablePath ( vscodeExecutablePath ) ;
14+ const extensionDevelopmentPath = path . resolve ( __dirname , '../../' ) ;
15+ const extensionTestsPath = path . resolve ( __dirname , './suite/index.js' ) ;
2016
21- const extensions = [
22- "xsro.vscode-dosbox"
23- ] ;
17+ async function test ( version :string ) {
18+ const vscodeExecutablePath = await downloadAndUnzipVSCode ( version ) ;
19+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
20+ const [ cli , ...args ] = resolveCliArgsFromVSCodeExecutablePath ( vscodeExecutablePath ) ;
2421
25- const vscedosbox = path . resolve ( __dirname , "../.." , ".." , "vscode-dosbox" ) ;
26- if ( fs . existsSync ( vscedosbox ) ) {
27- const dirs = await fs . promises . readdir ( vscedosbox ) ;
28- const dir = dirs . find ( val => val . includes ( `vscode-dosbox-${ process . platform } -${ process . arch } ` ) ) ;
29- if ( dir ) {
30- console . log ( "found " + dir ) ;
31- extensions [ 0 ] = path . resolve ( vscedosbox , dir ) ;
32- }
33- }
22+ const extensions = [
23+ "xsro.vscode-dosbox"
24+ ] ;
3425
35- // Use cp.spawn / cp.exec for custom setup
36- const p1 = cp . spawnSync ( cliPath , [ '--install-extension' , ...extensions ] , {
37- encoding : 'utf-8' ,
38- stdio : 'inherit'
39- } ) ;
26+ const vscedosbox = path . resolve ( __dirname , "../.." , ".." , "vscode-dosbox" ) ;
27+ if ( fs . existsSync ( vscedosbox ) ) {
28+ const dirs = await fs . promises . readdir ( vscedosbox ) ;
29+ const dir = dirs . find ( val => val . includes ( `vscode-dosbox-${ process . platform } -${ process . arch } ` ) ) ;
30+ if ( dir ) {
31+ console . log ( "found " + dir ) ;
32+ extensions [ 0 ] = path . resolve ( vscedosbox , dir ) ;
33+ }
34+ }
4035
41- // Use cp.spawn / cp.exec for custom setup
42- const p2 = cp . spawnSync ( cliPath , [ "--list-extensions" , "--show-versions" ] , {
43- encoding : 'utf-8' ,
44- stdio : 'inherit'
45- } ) ;
36+ // Use cp.spawn / cp.exec for custom setup
37+ cp . spawnSync ( cli , [ ... args , '--install-extension' , ... extensions ] , {
38+ encoding : 'utf-8' ,
39+ stdio : 'inherit'
40+ } ) ;
4641
47- console . log ( p1 , p2 ) ;
42+ const sampleFolder = path . resolve ( __dirname , '../../samples' ) ;
43+ const launchArgs : string [ ] = [
44+ "--disable-workspace-trust" ,
45+ sampleFolder
46+ ] ;
4847
49- const sampleFolder = path . resolve ( __dirname , '../../samples' ) ;
50- const launchArgs : string [ ] = [
51- "--disable-workspace-trust" ,
52- sampleFolder
53- ] ;
48+ // Run the extension test
49+ await runTests ( {
50+ // Use the specified `code` executable
51+ vscodeExecutablePath,
52+ extensionDevelopmentPath,
53+ extensionTestsPath,
54+ launchArgs
55+ } ) ;
56+ }
5457
55- // Run the extension test
56- await runTests ( {
57- // Use the specified `code` executable
58- vscodeExecutablePath,
59- extensionDevelopmentPath,
60- extensionTestsPath,
61- launchArgs
62- } ) ;
58+ async function main ( ) {
59+ try {
60+ await test ( 'stable' ) ;
61+ const pack = fs . readFileSync ( path . resolve ( extensionDevelopmentPath , "package.json" ) , "utf-8" )
62+ const least = JSON . parse ( pack ) . engines . vscode . replace ( "^" , "" ) ;
63+ await test ( least ) ;
64+
6365 } catch ( err ) {
6466 console . error ( 'Failed to run tests' ) ;
6567 process . exit ( 1 ) ;
0 commit comments