@@ -79,7 +79,7 @@ describe('When adding tool to cache', () => {
79
79
. get ( '/cmake-win32-x86_64.zip' )
80
80
. replyWithFile ( 200 , path . join ( dataPath , 'empty.zip' ) ) ;
81
81
82
- await setup . addCMakeToToolCache ( required_version ) ;
82
+ await setup . addCMakeToToolCache ( required_version , [ 'x86_64' ] ) ;
83
83
expect ( darwin_nock . isDone ( ) ) . toBe ( darwin ) ;
84
84
expect ( linux_nock . isDone ( ) ) . toBe ( linux ) ;
85
85
expect ( windows_nock . isDone ( ) ) . toBe ( windows ) ;
@@ -147,7 +147,7 @@ describe('When using version 3.19.2 on macos', () => {
147
147
const archive_nock = nock ( 'https://fakeaddress.com' )
148
148
. get ( '/cmake-3.19.2-macos-universal.tar.gz' )
149
149
. replyWithFile ( 200 , path . join ( dataPath , 'empty.tar.gz' ) ) ;
150
- await setup . addCMakeToToolCache ( macos_version ) ;
150
+ await setup . addCMakeToToolCache ( macos_version , [ 'x86_64' ] ) ;
151
151
expect ( package_nock . isDone ( ) ) . toBe ( false ) ;
152
152
expect ( archive_nock . isDone ( ) ) . toBe ( true ) ;
153
153
Object . defineProperty ( process , 'platform' , {
@@ -213,7 +213,7 @@ describe('When using version 2.8', () => {
213
213
const darwin64_nock = nock ( 'https://fakeaddress.com' )
214
214
. get ( '/cmake-2.8.12.2-Darwin64-universal.tar.gz' )
215
215
. replyWithFile ( 200 , path . join ( dataPath , 'empty.tar.gz' ) ) ;
216
- await setup . addCMakeToToolCache ( version ) ;
216
+ await setup . addCMakeToToolCache ( version , [ 'x86_64' , 'x86' ] ) ;
217
217
expect ( darwin_nock . isDone ( ) ) . toBe ( false ) ;
218
218
expect ( darwin64_nock . isDone ( ) ) . toBe ( true ) ;
219
219
Object . defineProperty ( process , 'platform' , {
@@ -231,7 +231,7 @@ describe('When using version 2.8', () => {
231
231
. get ( '/cmake-2.8.12.2-Linux-i386.tar.gz' )
232
232
. replyWithFile ( 200 , path . join ( dataPath , 'empty.tar.gz' ) ) ;
233
233
234
- await setup . addCMakeToToolCache ( version ) ;
234
+ await setup . addCMakeToToolCache ( version , [ 'x86_64' , 'x86' ] ) ;
235
235
expect ( linux_nock . isDone ( ) ) . toBe ( true ) ;
236
236
Object . defineProperty ( process , 'platform' , {
237
237
value : orig_platform ,
@@ -300,7 +300,7 @@ describe('Using version 3.19.3', () => {
300
300
const aarch64_nock = nock ( 'https://fakeaddress.com' )
301
301
. get ( '/cmake-3.19.3-Linux-aarch64.tar.gz' )
302
302
. replyWithFile ( 200 , path . join ( dataPath , 'empty.tar.gz' ) ) ;
303
- await setup . addCMakeToToolCache ( version ) ;
303
+ await setup . addCMakeToToolCache ( version , [ 'x86_64' ] ) ;
304
304
expect ( x86_nock . isDone ( ) ) . toBe ( true ) ;
305
305
expect ( aarch64_nock . isDone ( ) ) . toBe ( false ) ;
306
306
Object . defineProperty ( process , 'platform' , {
@@ -320,11 +320,107 @@ describe('Using version 3.19.3', () => {
320
320
const second_nock = nock ( 'https://fakeaddress.com' )
321
321
. get ( '/cmake-3.19.3-macos10.10-universal.tar.gz' )
322
322
. replyWithFile ( 200 , path . join ( dataPath , 'empty.tar.gz' ) ) ;
323
- await setup . addCMakeToToolCache ( version ) ;
323
+ await setup . addCMakeToToolCache ( version , [ 'x86_64' ] ) ;
324
324
expect ( first_nock . isDone ( ) ) . toBe ( true ) ;
325
325
expect ( second_nock . isDone ( ) ) . toBe ( false ) ;
326
326
Object . defineProperty ( process , 'platform' , {
327
327
value : orig_platform ,
328
328
} ) ;
329
329
} ) ;
330
330
} ) ;
331
+
332
+ describe ( 'Using a version with both x86_64 and x86 binaries' , ( ) => {
333
+ const version : vi . VersionInfo = {
334
+ name : '3.20.2' ,
335
+ assets : [
336
+ {
337
+ name : 'cmake-3.20.2-windows-i386.msi' ,
338
+ platform : 'win32' ,
339
+ arch : 'x86' ,
340
+ filetype : 'package' ,
341
+ url : 'https://url.test/cmake-3.20.2-windows-i386.msi' ,
342
+ } ,
343
+ {
344
+ name : 'cmake-3.20.2-windows-i386.zip' ,
345
+ platform : 'win32' ,
346
+ arch : 'x86' ,
347
+ filetype : 'archive' ,
348
+ url : 'https://url.test/cmake-3.20.2-windows-i386.zip' ,
349
+ } ,
350
+ {
351
+ name : 'cmake-3.20.2-windows-x86_64.msi' ,
352
+ platform : 'win32' ,
353
+ arch : 'x86_64' ,
354
+ filetype : 'package' ,
355
+ url : 'https://url.test/cmake-3.20.2-windows-x86_64.msi' ,
356
+ } ,
357
+ {
358
+ name : 'cmake-3.20.2-windows-x86_64.zip' ,
359
+ platform : 'win32' ,
360
+ arch : 'x86_64' ,
361
+ filetype : 'archive' ,
362
+ url : 'https://url.test/cmake-3.20.2-windows-x86_64.zip' ,
363
+ } ,
364
+ ] ,
365
+ url : '' ,
366
+ draft : false ,
367
+ prerelease : false ,
368
+ } ;
369
+
370
+ beforeEach ( ( ) => {
371
+ nock . disableNetConnect ( ) ;
372
+ } ) ;
373
+
374
+ afterEach ( ( ) => {
375
+ nock . cleanAll ( ) ;
376
+ nock . enableNetConnect ( ) ;
377
+ } ) ;
378
+
379
+ it ( 'downloads the 32 bit package when requested' , async ( ) => {
380
+ const orig_platform : string = process . platform ;
381
+ Object . defineProperty ( process , 'platform' , {
382
+ value : 'win32' ,
383
+ } ) ;
384
+ expect ( process . platform ) . toBe ( 'win32' ) ;
385
+ const x86_nock = nock ( 'https://url.test' )
386
+ . get ( '/cmake-3.20.2-windows-i386.zip' )
387
+ . replyWithFile ( 200 , path . join ( dataPath , 'empty.zip' ) ) ;
388
+ await setup . addCMakeToToolCache ( version , [ 'x86' ] ) ;
389
+ expect ( x86_nock . isDone ( ) ) . toBe ( true ) ;
390
+ Object . defineProperty ( process , 'platform' , {
391
+ value : orig_platform ,
392
+ } ) ;
393
+ } ) ;
394
+
395
+ it ( 'downloads the 64 bit package when requested' , async ( ) => {
396
+ const orig_platform : string = process . platform ;
397
+ Object . defineProperty ( process , 'platform' , {
398
+ value : 'win32' ,
399
+ } ) ;
400
+ expect ( process . platform ) . toBe ( 'win32' ) ;
401
+ const x86_nock = nock ( 'https://url.test' )
402
+ . get ( '/cmake-3.20.2-windows-x86_64.zip' )
403
+ . replyWithFile ( 200 , path . join ( dataPath , 'empty.zip' ) ) ;
404
+ await setup . addCMakeToToolCache ( version , [ 'x86_64' ] ) ;
405
+ expect ( x86_nock . isDone ( ) ) . toBe ( true ) ;
406
+ Object . defineProperty ( process , 'platform' , {
407
+ value : orig_platform ,
408
+ } ) ;
409
+ } ) ;
410
+
411
+ it ( 'falls back to 64 bit package when both requested' , async ( ) => {
412
+ const orig_platform : string = process . platform ;
413
+ Object . defineProperty ( process , 'platform' , {
414
+ value : 'win32' ,
415
+ } ) ;
416
+ expect ( process . platform ) . toBe ( 'win32' ) ;
417
+ const x86_nock = nock ( 'https://url.test' )
418
+ . get ( '/cmake-3.20.2-windows-x86_64.zip' )
419
+ . replyWithFile ( 200 , path . join ( dataPath , 'empty.zip' ) ) ;
420
+ await setup . addCMakeToToolCache ( version , [ 'x86_64' , 'x86' ] ) ;
421
+ expect ( x86_nock . isDone ( ) ) . toBe ( true ) ;
422
+ Object . defineProperty ( process , 'platform' , {
423
+ value : orig_platform ,
424
+ } ) ;
425
+ } ) ;
426
+ } ) ;
0 commit comments