@@ -23,98 +23,89 @@ export async function testAutoUpdateTo(context: SmokeTestsContext) {
2323 buildInfo : { channel, version } ,
2424 } = subject ;
2525
26- try {
27- // Derive the kind of package needed to install the latest release
28- const latestApp = getTestSubjectDetails ( {
29- ...context ,
30- sandboxPath,
31- package : getLatestReleaseKindByKind ( subject . kind ) ,
32- } ) ;
26+ // Derive the kind of package needed to install the latest release
27+ const latestApp = getTestSubjectDetails ( {
28+ ...context ,
29+ sandboxPath,
30+ package : getLatestReleaseKindByKind ( subject . kind ) ,
31+ } ) ;
3332
34- assert . equal ( latestApp . buildInfo . channel , subject . buildInfo . channel ) ;
33+ assert . equal ( latestApp . buildInfo . channel , subject . buildInfo . channel ) ;
3534
36- const install = getInstaller ( latestApp . kind ) ;
37- const filepath = await getLatestRelease (
38- channel ,
39- context . arch ,
40- latestApp . kind ,
41- context . forceDownload
42- ) ;
35+ const install = getInstaller ( latestApp . kind ) ;
36+ const filepath = await getLatestRelease (
37+ channel ,
38+ context . arch ,
39+ latestApp . kind ,
40+ context . forceDownload
41+ ) ;
4342
44- const { appPath, appName, uninstall } = install ( {
45- ...latestApp ,
46- filepath,
47- filename : subject . filename ,
48- sandboxPath,
49- } ) ;
43+ const { appPath, appName, uninstall } = install ( {
44+ ...latestApp ,
45+ filepath,
46+ filename : subject . filename ,
47+ sandboxPath,
48+ } ) ;
5049
51- try {
52- process . env . PORT = '0' ; // dynamic port
53- process . env . UPDATE_CHECKER_ALLOW_DOWNGRADES = 'true' ;
50+ try {
51+ process . env . PORT = '0' ; // dynamic port
52+ process . env . UPDATE_CHECKER_ALLOW_DOWNGRADES = 'true' ;
5453
55- if ( channel === 'dev' ) {
56- process . env . DEV_RELEASE = JSON . stringify ( {
57- version : version ,
58- bucket_key_prefix : context . bucketKeyPrefix ,
59- } ) ;
60- } else {
61- process . env . PUBLISHED_RELEASES = JSON . stringify ( {
62- name : version ,
63- body : version ,
64- bucket_key_prefix : context . bucketKeyPrefix ,
65- } ) ;
66- }
54+ if ( channel === 'dev' ) {
55+ process . env . DEV_RELEASE = JSON . stringify ( {
56+ version : version ,
57+ bucket_key_prefix : context . bucketKeyPrefix ,
58+ } ) ;
59+ } else {
60+ process . env . PUBLISHED_RELEASES = JSON . stringify ( {
61+ name : version ,
62+ body : version ,
63+ bucket_key_prefix : context . bucketKeyPrefix ,
64+ } ) ;
65+ }
6766
68- const server = await startAutoUpdateServer ( ) ;
67+ const server = await startAutoUpdateServer ( ) ;
6968
70- const address = server . address ( ) ;
71- assert ( typeof address === 'object' && address !== null ) ;
72- const port = address . port ;
73- const HADRON_AUTO_UPDATE_ENDPOINT_OVERRIDE = `http://localhost:${ port } ` ;
69+ const address = server . address ( ) ;
70+ assert ( typeof address === 'object' && address !== null ) ;
71+ const port = address . port ;
72+ const HADRON_AUTO_UPDATE_ENDPOINT_OVERRIDE = `http://localhost:${ port } ` ;
7473
75- try {
76- // must be async because the update server is running in the same process
77- await executeAsync (
78- 'npm' ,
79- [
80- 'run' ,
81- '--unsafe-perm' ,
82- 'test-packaged' ,
83- '--workspace' ,
84- 'compass-e2e-tests' ,
85- '--' ,
86- '--test-filter=auto-update' ,
87- ] ,
88- {
89- // We need to use a shell to get environment variables setup correctly
90- shell : true ,
91- env : {
92- ...process . env ,
93- HADRON_AUTO_UPDATE_ENDPOINT_OVERRIDE ,
94- AUTO_UPDATE_UPDATABLE : ( ! ! subject . autoUpdatable ) . toString ( ) ,
95- TEST_NAME : 'auto-update-to' ,
96- EXPECTED_UPDATE_VERSION : version ,
97- COMPASS_APP_NAME : appName ,
98- COMPASS_APP_PATH : appPath ,
99- } ,
100- }
101- ) ;
102- } finally {
103- debug ( 'Stopping auto-update server' ) ;
104- server . close ( ) ;
105- delete process . env . DEV_RELEASE ;
106- delete process . env . PUBLISHED_RELEASES ;
107- delete process . env . UPDATE_CHECKER_ALLOW_DOWNGRADES ;
108- }
74+ try {
75+ // must be async because the update server is running in the same process
76+ await executeAsync (
77+ 'npm' ,
78+ [
79+ 'run' ,
80+ '--unsafe-perm' ,
81+ 'test-packaged' ,
82+ '--workspace' ,
83+ 'compass-e2e-tests' ,
84+ '--' ,
85+ '--test-filter=auto-update' ,
86+ ] ,
87+ {
88+ // We need to use a shell to get environment variables setup correctly
89+ shell : true ,
90+ env : {
91+ ...process . env ,
92+ HADRON_AUTO_UPDATE_ENDPOINT_OVERRIDE ,
93+ AUTO_UPDATE_UPDATABLE : ( ! ! subject . autoUpdatable ) . toString ( ) ,
94+ TEST_NAME : 'auto-update-to' ,
95+ EXPECTED_UPDATE_VERSION : version ,
96+ COMPASS_APP_NAME : appName ,
97+ COMPASS_APP_PATH : appPath ,
98+ } ,
99+ }
100+ ) ;
109101 } finally {
110- await uninstall ( ) ;
102+ debug ( 'Stopping auto-update server' ) ;
103+ server . close ( ) ;
104+ delete process . env . DEV_RELEASE ;
105+ delete process . env . PUBLISHED_RELEASES ;
106+ delete process . env . UPDATE_CHECKER_ALLOW_DOWNGRADES ;
111107 }
112108 } finally {
113- if ( context . skipCleanup ) {
114- debug ( `Skipped cleaning up sandbox: ${ sandboxPath } ` ) ;
115- } else {
116- debug ( `Cleaning up sandbox: ${ sandboxPath } ` ) ;
117- fs . rmSync ( sandboxPath , { recursive : true } ) ;
118- }
109+ await uninstall ( ) ;
119110 }
120111}
0 commit comments