@@ -17,7 +17,7 @@ describe('windows toolchain installation verification', () => {
1717 download : 'swift-5.8-RELEASE-windows10.exe' ,
1818 download_signature : 'swift-5.8-RELEASE-windows10.exe.sig' ,
1919 dir : 'swift-5.8-RELEASE' ,
20- platform : 'ubuntu2204 ' ,
20+ platform : 'windows10 ' ,
2121 branch : 'swift-5.8-release' ,
2222 windows : true
2323 }
@@ -48,7 +48,7 @@ describe('windows toolchain installation verification', () => {
4848 const installer = new WindowsToolchainInstaller ( toolchain )
4949 expect ( installer [ 'version' ] ) . toStrictEqual ( parseSemVer ( '5.8' ) )
5050 expect ( installer [ 'baseUrl' ] ) . toBe (
51- 'https://download.swift.org/swift-5.8-release/ubuntu2204 /swift-5.8-RELEASE'
51+ 'https://download.swift.org/swift-5.8-release/windows10 /swift-5.8-RELEASE'
5252 )
5353
5454 const download = path . resolve ( 'tool' , 'download' , 'path' )
@@ -67,15 +67,14 @@ describe('windows toolchain installation verification', () => {
6767 jest . spyOn ( toolCache , 'downloadTool' ) . mockResolvedValue ( download )
6868 jest . spyOn ( exec , 'exec' ) . mockResolvedValue ( 0 )
6969 await expect ( installer [ 'download' ] ( ) ) . resolves . toBe ( `${ download } .exe` )
70- expect ( installer [ 'visualStudio' ] ) . toStrictEqual ( visualStudio )
7170 expect ( cacheSpy ) . toHaveBeenCalled ( )
7271 } )
7372
7473 it ( 'tests download without caching' , async ( ) => {
7574 const installer = new WindowsToolchainInstaller ( toolchain )
7675 expect ( installer [ 'version' ] ) . toStrictEqual ( parseSemVer ( '5.8' ) )
7776 expect ( installer [ 'baseUrl' ] ) . toBe (
78- 'https://download.swift.org/swift-5.8-release/ubuntu2204 /swift-5.8-RELEASE'
77+ 'https://download.swift.org/swift-5.8-release/windows10 /swift-5.8-RELEASE'
7978 )
8079
8180 const download = path . resolve ( 'tool' , 'download' , 'path' )
@@ -94,7 +93,6 @@ describe('windows toolchain installation verification', () => {
9493 jest . spyOn ( toolCache , 'downloadTool' ) . mockResolvedValue ( download )
9594 jest . spyOn ( exec , 'exec' ) . mockResolvedValue ( 0 )
9695 await expect ( installer [ 'download' ] ( ) ) . resolves . toBe ( `${ download } .exe` )
97- expect ( installer [ 'visualStudio' ] ) . toStrictEqual ( visualStudio )
9896 expect ( cacheSpy ) . not . toHaveBeenCalled ( )
9997 } )
10098
@@ -131,8 +129,8 @@ describe('windows toolchain installation verification', () => {
131129
132130 it ( 'tests add to PATH' , async ( ) => {
133131 const installer = new WindowsToolchainInstaller ( toolchain )
134- installer [ 'visualStudio' ] = visualStudio
135132 const installation = path . resolve ( 'tool' , 'installed' , 'path' )
133+ jest . spyOn ( vs , 'setupVisualStudioTools' ) . mockResolvedValue ( visualStudio )
136134 jest . spyOn ( fs , 'access' ) . mockRejectedValue ( new Error ( ) )
137135 jest . spyOn ( fs , 'copyFile' ) . mockResolvedValue ( )
138136 jest . spyOn ( exec , 'exec' ) . mockResolvedValue ( 0 )
@@ -166,6 +164,47 @@ describe('windows toolchain installation verification', () => {
166164 expect ( process . env . SDKROOT ) . toBe ( sdkroot )
167165 } )
168166
167+ it ( 'tests installation with cache' , async ( ) => {
168+ const installer = new WindowsToolchainInstaller ( toolchain )
169+ const cached = path . resolve ( 'tool' , 'cached' , 'path' )
170+ const toolPath = path . join (
171+ cached ,
172+ 'Developer' ,
173+ 'Toolchains' ,
174+ 'unknown-Asserts-development.xctoolchain'
175+ )
176+ const sdkroot = path . join (
177+ cached ,
178+ 'Developer' ,
179+ 'Platforms' ,
180+ 'Windows.platform' ,
181+ 'Developer' ,
182+ 'SDKs' ,
183+ 'Windows.sdk'
184+ )
185+ const swiftPath = path . join ( toolPath , 'usr' , 'bin' )
186+ const swiftDev = path . join ( cached , 'Swift-development' , 'bin' )
187+ const icu67 = path . join ( cached , 'icu-67' , 'usr' , 'bin' )
188+ const setupSpy = jest
189+ . spyOn ( vs , 'setupVisualStudioTools' )
190+ . mockResolvedValue ( visualStudio )
191+ jest . spyOn ( fs , 'access' ) . mockRejectedValue ( new Error ( ) )
192+ jest . spyOn ( fs , 'copyFile' ) . mockResolvedValue ( )
193+ jest . spyOn ( toolCache , 'find' ) . mockReturnValue ( cached )
194+ jest . spyOn ( exec , 'exec' ) . mockResolvedValue ( 0 )
195+ jest . spyOn ( exec , 'getExecOutput' ) . mockResolvedValue ( {
196+ exitCode : 0 ,
197+ stdout : vsEnvs . join ( os . EOL ) ,
198+ stderr : ''
199+ } )
200+ await installer . install ( )
201+ expect ( setupSpy ) . toHaveBeenCalled ( )
202+ expect ( process . env . PATH ?. includes ( swiftPath ) ) . toBeTruthy ( )
203+ expect ( process . env . PATH ?. includes ( swiftDev ) ) . toBeTruthy ( )
204+ expect ( process . env . PATH ?. includes ( icu67 ) ) . toBeTruthy ( )
205+ expect ( process . env . SDKROOT ) . toBe ( sdkroot )
206+ } )
207+
169208 it ( 'tests installed swift version detection' , async ( ) => {
170209 const installer = new WindowsToolchainInstaller ( toolchain )
171210 jest . spyOn ( exec , 'getExecOutput' ) . mockResolvedValue ( {
0 commit comments