1- import { DMD , SETTINGS } from '../src/d'
1+ import { DMD } from '../src/d'
22import * as gpg from '../src/gpg'
33import * as utils from '../src/utils'
44import * as testUtils from './test-helpers.test'
55import * as tc from '@actions/tool-cache'
66import fs from 'fs'
77
8+ import SETTINGS from '../src/settings'
9+
810testUtils . hideConsoleLogs ( )
911testUtils . saveProcessRestorePoint ( )
1012testUtils . disableNetwork ( )
@@ -442,10 +444,10 @@ test('dmd fails on unsupported platforms', async () => {
442444describe ( 'Test makeAvailable' , ( ) => {
443445 const root = '/tmp/cache'
444446 const origEnv = process . env
447+ const origSep = SETTINGS . sep
448+ const origExeExt = SETTINGS . exeExt
445449
446- // These values are cached so they match the hosts
447- const sep = ( process . platform == 'win32' ? '\\' : '/' )
448- const exeExt = ( process . platform == 'win32' ? '.exe' : '' )
450+ // This value is cached so it matches the host's
449451 const pathSep = ( process . platform == 'win32' ? ';' : ':' )
450452
451453 beforeEach ( ( ) => {
@@ -455,30 +457,40 @@ describe('Test makeAvailable', () => {
455457 process . env [ 'PATH' ] = '/bin'
456458 process . env [ 'LD_LIBRARY_PATH' ] = ''
457459 } )
458- afterEach ( ( ) => process . env = origEnv )
460+ afterEach ( ( ) => {
461+ process . env = origEnv
462+ SETTINGS . sep = origSep
463+ SETTINGS . exeExt = origExeExt
464+ } )
459465
460466 test ( 'linux' , async ( ) => {
461467 Object . defineProperty ( process , 'platform' , { value : 'linux' } )
468+ SETTINGS . sep = '/'
469+ SETTINGS . exeExt = ''
462470 const dmd = await init ( 'dmd-2.109.1' )
463471 await dmd . makeAvailable ( )
464472 expect ( process . env [ 'PATH' ] ) . toBe ( root + '/dmd2/linux/bin64' + pathSep + '/bin' )
465473 expect ( process . env [ 'LD_LIBRARY_PATH' ] ) . toBe ( root + '/dmd2/linux/lib64' )
466- expect ( process . env [ 'DC' ] ) . toBe ( root + ` /dmd2/linux/bin64${ sep } dmd${ exeExt } ` )
467- expect ( process . env [ 'DMD' ] ) . toBe ( root + ` /dmd2/linux/bin64${ sep } dmd${ exeExt } ` )
474+ expect ( process . env [ 'DC' ] ) . toBe ( root + ' /dmd2/linux/bin64/ dmd' )
475+ expect ( process . env [ 'DMD' ] ) . toBe ( root + ' /dmd2/linux/bin64/ dmd' )
468476 } )
469477
470478 test ( 'osx' , async ( ) => {
471479 Object . defineProperty ( process , 'platform' , { value : 'darwin' } )
480+ SETTINGS . sep = '/'
481+ SETTINGS . exeExt = ''
472482 const dmd = await init ( 'dmd-2.109.1' )
473483 await dmd . makeAvailable ( )
474484 expect ( process . env [ 'PATH' ] ) . toBe ( root + '/dmd2/osx/bin' + pathSep + '/bin' )
475485 expect ( process . env [ 'LD_LIBRARY_PATH' ] ) . toBe ( root + '/dmd2/osx/lib' )
476- expect ( process . env [ 'DC' ] ) . toBe ( root + ` /dmd2/osx/bin${ sep } dmd${ exeExt } ` )
477- expect ( process . env [ 'DMD' ] ) . toBe ( root + ` /dmd2/osx/bin${ sep } dmd${ exeExt } ` )
486+ expect ( process . env [ 'DC' ] ) . toBe ( root + ' /dmd2/osx/bin/ dmd' )
487+ expect ( process . env [ 'DMD' ] ) . toBe ( root + ' /dmd2/osx/bin/ dmd' )
478488 } )
479489
480490 test ( 'windows' , async ( ) => {
481491 Object . defineProperty ( process , 'platform' , { value : 'win32' } )
492+ SETTINGS . sep = '\\'
493+ SETTINGS . exeExt = '.exe'
482494 const dmd = await init ( 'dmd-2.109.1' )
483495 await dmd . makeAvailable ( )
484496
@@ -493,12 +505,12 @@ describe('Test makeAvailable', () => {
493505 // Check that the 64bit folder appears before the 32bit one
494506 expect ( found64 ) . toBeLessThan ( found32 )
495507
496- expect ( process . env [ 'DC' ] ) . toBe ( root + `\\dmd2\\windows\\bin64${ sep } dmd${ exeExt } ` )
497- expect ( process . env [ 'DMD' ] ) . toBe ( root + `\\dmd2\\windows\\bin64${ sep } dmd${ exeExt } ` )
508+ expect ( process . env [ 'DC' ] ) . toBe ( root + `\\dmd2\\windows\\bin64\\ dmd.exe ` )
509+ expect ( process . env [ 'DMD' ] ) . toBe ( root + `\\dmd2\\windows\\bin64\\ dmd.exe ` )
498510 } )
499511
500512 describe ( 'Check that verify_sig is respected' , ( ) => {
501- const save = SETTINGS . verify_sig
513+ const save = SETTINGS . verifySig
502514 const gpgSpy = jest . spyOn ( gpg , 'verify' ) . mockResolvedValue ( undefined )
503515
504516 beforeEach ( ( ) => {
@@ -507,17 +519,17 @@ describe('Test makeAvailable', () => {
507519 jest . spyOn ( utils , 'extract' ) . mockResolvedValue ( '/tmp/p2' )
508520 jest . spyOn ( tc , 'cacheDir' ) . mockResolvedValue ( '/tmp/p3' )
509521 } )
510- afterEach ( ( ) => SETTINGS . verify_sig = save )
522+ afterEach ( ( ) => SETTINGS . verifySig = save )
511523
512524 test ( 'verify_sig === false' , async ( ) => {
513- SETTINGS . verify_sig = false
525+ SETTINGS . verifySig = false
514526 const dmd = await init ( 'dmd-2.109.1' )
515527 await dmd . makeAvailable ( )
516528 expect ( gpgSpy ) . not . toHaveBeenCalled ( )
517529 } )
518530
519531 test ( 'verify_sig === true' , async ( ) => {
520- SETTINGS . verify_sig = true
532+ SETTINGS . verifySig = true
521533 const dmd = await init ( 'dmd-2.109.1' )
522534 await dmd . makeAvailable ( )
523535 expect ( gpgSpy ) . toHaveBeenCalled ( )
0 commit comments