@@ -38,6 +38,7 @@ describe('macOS toolchain installation verification', () => {
3838    const  installer  =  new  XcodeToolchainInstaller ( toolchain ) 
3939    jest . spyOn ( fs ,  'access' ) . mockResolvedValue ( ) 
4040    jest . spyOn ( exec ,  'exec' ) . mockResolvedValue ( 0 ) 
41+     jest . spyOn ( core ,  'getBooleanInput' ) . mockReturnValue ( false ) 
4142    jest . spyOn ( exec ,  'getExecOutput' ) . mockResolvedValue ( { 
4243      exitCode : 0 , 
4344      stdout : `swift-driver version: 1.75.2 Apple Swift version 5.8.1 (swiftlang-5.8.0.124.5 clang-1403.0.22.11.100)\nTarget: arm64-apple-macosx13.0` , 
@@ -55,6 +56,48 @@ describe('macOS toolchain installation verification', () => {
5556    expect ( process . env . DEVELOPER_DIR ) . toBe ( toolchain . xcodePath ) 
5657  } ) 
5758
59+   it ( 'tests toolchain preinstalled not preferred' ,  async  ( )  =>  { 
60+     const  installer  =  new  XcodeToolchainInstaller ( toolchain ) 
61+     const  identifier  =  'org.swift.581202305171a' 
62+     jest . spyOn ( fs ,  'access' ) . mockResolvedValue ( ) 
63+     jest . spyOn ( exec ,  'exec' ) . mockResolvedValue ( 0 ) 
64+     jest . spyOn ( core ,  'getBooleanInput' ) . mockReturnValue ( true ) 
65+     jest . spyOn ( cache ,  'restoreCache' ) . mockResolvedValue ( undefined ) 
66+     jest . spyOn ( toolCache ,  'find' ) . mockReturnValue ( '' ) 
67+     jest . spyOn ( cache ,  'saveCache' ) . mockResolvedValue ( 1 ) 
68+     jest . spyOn ( fs ,  'access' ) . mockResolvedValue ( ) 
69+     jest . spyOn ( fs ,  'readFile' ) . mockResolvedValue ( '' ) 
70+     jest . spyOn ( fs ,  'cp' ) . mockResolvedValue ( ) 
71+     jest . spyOn ( plist ,  'parse' ) . mockReturnValue ( { CFBundleIdentifier : identifier } ) 
72+     jest . spyOn ( exec ,  'getExecOutput' ) . mockResolvedValue ( { 
73+       exitCode : 0 , 
74+       stdout : `swift-driver version: 1.75.2 Apple Swift version 5.8.1 (swiftlang-5.8.0.124.5 clang-1403.0.22.11.100)\nTarget: arm64-apple-macosx13.0` , 
75+       stderr : '' 
76+     } ) 
77+     const  download  =  path . resolve ( 'tool' ,  'download' ,  'path' ) 
78+     const  extracted  =  path . resolve ( 'tool' ,  'extracted' ,  'path' ) 
79+     const  deployed  =  path . resolve ( 'tool' ,  'deployed' ,  'path' ) 
80+     const  cached  =  path . resolve ( 'tool' ,  'cached' ,  'path' ) 
81+     const  installationNeededSpy  =  jest . spyOn ( installer ,  'isInstallationNeeded' ) 
82+     const  downloadSpy  =  jest 
83+       . spyOn ( toolCache ,  'downloadTool' ) 
84+       . mockResolvedValue ( download ) 
85+     const  extractXarSpy  =  jest 
86+       . spyOn ( toolCache ,  'extractXar' ) 
87+       . mockResolvedValue ( extracted ) 
88+     const  extractTarSpy  =  jest 
89+       . spyOn ( toolCache ,  'extractTar' ) 
90+       . mockResolvedValue ( deployed ) 
91+     const  cacheSpy  =  jest . spyOn ( toolCache ,  'cacheDir' ) . mockResolvedValue ( cached ) 
92+     await  installer . install ( 'x86_64' ) 
93+     await  installer . install ( 'aarch64' ) 
94+     for  ( const  spy  of  [ downloadSpy ,  extractXarSpy ,  extractTarSpy ,  cacheSpy ] )  { 
95+       expect ( spy ) . toHaveBeenCalled ( ) 
96+     } 
97+     expect ( installationNeededSpy ) . toHaveBeenCalled ( ) 
98+     expect ( process . env . DEVELOPER_DIR ) . toBe ( toolchain . xcodePath ) 
99+   } ) 
100+ 
58101  it ( 'tests download' ,  async  ( )  =>  { 
59102    const  installer  =  new  XcodeToolchainInstaller ( toolchain ) 
60103    expect ( installer [ 'version' ] ) . toStrictEqual ( parseSemVer ( '5.8.1' ) ) 
@@ -185,6 +228,7 @@ describe('macOS toolchain installation verification', () => {
185228    jest . spyOn ( toolCache ,  'find' ) . mockReturnValue ( '' ) 
186229    jest . spyOn ( fs ,  'access' ) . mockResolvedValue ( ) 
187230    jest . spyOn ( exec ,  'exec' ) . mockResolvedValue ( 0 ) 
231+     jest . spyOn ( core ,  'getBooleanInput' ) . mockReturnValue ( false ) 
188232    jest . spyOn ( exec ,  'getExecOutput' ) . mockResolvedValue ( { 
189233      exitCode : 0 , 
190234      stdout : `swift-driver version: 1.75.2 Apple Swift version 5.8.1 (swiftlang-5.8.0.124.5 clang-1403.0.22.11.100)\nTarget: arm64-apple-macosx13.0` , 
0 commit comments