11import { Shell , SpawnStatus , VerbosityLevel } from 'codify-plugin-lib' ;
2- import { testSpawn } from 'codify-plugin-test' ;
2+ import { testSpawn , TestUtils } from 'codify-plugin-test' ;
33import { Command } from 'commander' ;
44import { spawn } from 'node:child_process' ;
55import * as inspector from 'node:inspector' ;
@@ -27,7 +27,7 @@ async function main(argument: string, args: { operatingSystem: string; persisten
2727 }
2828
2929 if ( args . launchPersistent ) {
30- await launchPersistentVm ( ) ;
30+ await launchPersistentVm ( args . operatingSystem ) ;
3131 return process . exit ( 0 ) ;
3232 }
3333
@@ -69,7 +69,9 @@ async function launchSingleTest(test: string, debug: boolean, operatingSystem: s
6969}
7070
7171async function launchPersistentTest ( test : string , debug : boolean , operatingSystem : string ) {
72- if ( operatingSystem === 'darwin' ) {
72+ const shell = operatingSystem === 'darwin' ? 'zsh' : 'bash' ;
73+
74+ // if (operatingSystem === 'darwin') {
7375 const { data : vmList } = await codifySpawn ( 'tart list --format json' ) ;
7476 console . log ( vmList ) ;
7577
@@ -80,7 +82,8 @@ async function launchPersistentTest(test: string, debug: boolean, operatingSyste
8082 }
8183
8284 const vmName = runningVm . Name ;
83- const dir = '/Users/admin/codify-homebrew-plugin' ;
85+ const dir = '~/codify-homebrew-plugin' ;
86+ // const dir = '/Volumes/My\\ Shared\\ Files/plugin'
8487
8588 const debugFlag = debug ? ' -e DEBUG="--inspect-brk=9229"' : ''
8689
@@ -93,15 +96,18 @@ async function launchPersistentTest(test: string, debug: boolean, operatingSyste
9396
9497 console . log ( 'Done refreshing files on VM. Starting tests...' ) ;
9598 VerbosityLevel . set ( 3 ) ;
96- await codifySpawn ( `tart exec -i ${ vmName } zsh -i - c "cd ${ dir } && FORCE_COLOR=true npm run test -- ${ test } --disable-console-intercept ${ debugFlag } --no-file-parallelism"` ) ;
97- }
99+ await codifySpawn ( `tart exec ${ vmName } ${ shell } - c "cd ${ dir } && FORCE_COLOR=true npm run test -- ${ test } --disable-console-intercept ${ debugFlag } --no-file-parallelism"` , { throws : false } ) ;
100+ // }
98101}
99102
100- async function launchPersistentVm ( ) {
103+ async function launchPersistentVm ( operatingSystem : string ) {
101104 const newVmName = `codify-test-vm-${ Date . now ( ) } ` ;
105+ const shell = operatingSystem === 'darwin' ? 'zsh' : 'bash' ;
106+
102107 console . log ( `Cloning new VM... ${ newVmName } ` ) ;
103108
104- await testSpawn ( `tart clone codify-test-vm ${ newVmName } ` ) ;
109+ const image = ( operatingSystem === 'darwin' ) ? 'codify-test-vm' : 'codify-test-vm-linux' ;
110+ await testSpawn ( `tart clone ${ image } ${ newVmName } ` ) ;
105111 testSpawn ( `tart run ${ newVmName } ` )
106112 . then ( cleanupVm )
107113
@@ -115,7 +121,7 @@ async function launchPersistentVm() {
115121
116122 const { data : ipAddr } = await testSpawn ( `tart ip ${ newVmName } ` ) ;
117123 await testSpawn ( `sshpass -p "admin" rsync -avz -e 'ssh -o PubkeyAuthentication=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' --exclude 'node_modules' --exclude '.git' --exclude 'dist' --exclude '.fleet' ${ process . cwd ( ) } admin@${ ipAddr } :~` ) ;
118- await testSpawn ( `tart exec ${ newVmName } zsh -i -c "cd ~/codify-homebrew-plugin && npm ci"` ) ;
124+ await testSpawn ( `tart exec ${ newVmName } ${ shell } -i -c "cd ~/codify-homebrew-plugin && npm ci"` ) ;
119125 console . log ( 'Finished installing dependencies. Start tests in a new terminal window.' ) ;
120126
121127 await sleep ( 1_000_000_000 ) ;
0 commit comments