@@ -15,7 +15,10 @@ import {
1515} from './helpers/smoke-test/build-info' ;
1616import { createSandbox } from './helpers/smoke-test/directories' ;
1717import { downloadFile } from './helpers/smoke-test/downloads' ;
18- import { SUPPORTED_PACKAGES } from './helpers/smoke-test/packages' ;
18+ import {
19+ type PackageKind ,
20+ SUPPORTED_PACKAGES ,
21+ } from './helpers/smoke-test/packages' ;
1922import { type SmokeTestsContext } from './helpers/smoke-test/context' ;
2023import { installMacZIP } from './installers/mac-zip' ;
2124
@@ -98,7 +101,14 @@ const argv = yargs(hideBin(process.argv))
98101 description : 'Use the local package instead of downloading' ,
99102 } ) ;
100103
101- type TestSubject = PackageDetails & { filepath : string } ;
104+ type TestSubject = PackageDetails & {
105+ filepath : string ;
106+ /**
107+ * Is the package unsigned?
108+ * In which case we'll expect auto-updating to fail.
109+ */
110+ unsigned ?: boolean ;
111+ } ;
102112
103113/**
104114 * Either finds the local package or downloads the package
@@ -120,6 +130,7 @@ async function getTestSubject(
120130 return {
121131 ...details ,
122132 filepath : path . resolve ( compassDistPath , details . filename ) ,
133+ unsigned : true ,
123134 } ;
124135 } else {
125136 assert (
@@ -137,6 +148,16 @@ async function getTestSubject(
137148 }
138149}
139150
151+ function getInstaller ( kind : PackageKind ) {
152+ if ( kind === 'osx_dmg' ) {
153+ return installMacDMG ;
154+ } else if ( kind === 'osx_zip' ) {
155+ return installMacZIP ;
156+ } else {
157+ throw new Error ( `Installer for '${ kind } ' is not yet implemented` ) ;
158+ }
159+ }
160+
140161async function run ( ) {
141162 const context : SmokeTestsContext = {
142163 ...argv . parseSync ( ) ,
@@ -157,43 +178,26 @@ async function run() {
157178 ] )
158179 ) ;
159180
160- const cleanups : ( ( ) => void | Promise < void > ) [ ] = [
161- ( ) => {
162- console . log ( 'Cleaning up sandbox' ) ;
163- fs . rmSync ( context . sandboxPath , { recursive : true } ) ;
164- } ,
165- ] ;
166181 const { kind, buildInfo, filepath } = await getTestSubject ( context ) ;
182+ const install = getInstaller ( kind ) ;
167183
168184 try {
169185 const appName = buildInfo . productName ;
170- if ( kind === 'osx_dmg' ) {
171- const { appPath, uninstall } = installMacDMG ( {
172- appName,
173- filepath,
174- destinationPath : context . sandboxPath ,
175- } ) ;
176- cleanups . push ( uninstall ) ;
177186
178- runTest ( { appName, appPath } ) ;
179- } else if ( kind === 'osx_zip' ) {
180- const { appPath, uninstall } = installMacZIP ( {
181- appName,
182- filepath,
183- destinationPath : context . sandboxPath ,
184- } ) ;
185- cleanups . push ( uninstall ) ;
187+ const { appPath, uninstall } = install ( {
188+ appName,
189+ filepath,
190+ destinationPath : context . sandboxPath ,
191+ } ) ;
186192
193+ try {
187194 runTest ( { appName, appPath } ) ;
188- } else {
189- throw new Error ( `Testing ' ${ kind } ' packages is not yet implemented` ) ;
195+ } finally {
196+ await uninstall ( ) ;
190197 }
191198 } finally {
192- // Chain the cleanup functions in reverse order
193- await cleanups
194- . slice ( )
195- . reverse ( )
196- . reduce ( ( previous , cleanup ) => previous . then ( cleanup ) , Promise . resolve ( ) ) ;
199+ console . log ( 'Cleaning up sandbox' ) ;
200+ fs . rmSync ( context . sandboxPath , { recursive : true } ) ;
197201 }
198202}
199203
0 commit comments