Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion __tests__/installer/linux.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('linux toolchain installation verification', () => {
jest.spyOn(cache, 'saveCache').mockResolvedValue(1)
jest.spyOn(toolCache, 'downloadTool').mockResolvedValue(download)
jest.spyOn(exec, 'exec').mockResolvedValue(0)
await expect(installer['download']()).resolves.toBe(download)
await expect(installer['download']('x86_64')).resolves.toBe(download)
})

it('tests unpack', async () => {
Expand Down
54 changes: 42 additions & 12 deletions __tests__/installer/windows.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('windows toolchain installation verification', () => {
'Microsoft.VisualStudio.Component.VC.ATL;Microsoft.VisualStudio.Component.VC.CMake.Project;Microsoft.VisualStudio.Component.Windows10SDK'
)
const installer = new WindowsToolchainInstaller(toolchain)
expect(installer['vsRequirement'].components).toStrictEqual([
expect(installer['vsRequirement']('x86_64').components).toStrictEqual([
'Microsoft.VisualStudio.Component.VC.Tools.x86.x64',
'Microsoft.VisualStudio.Component.VC.ATL',
'Microsoft.VisualStudio.Component.VC.CMake.Project',
Expand All @@ -69,16 +69,25 @@ describe('windows toolchain installation verification', () => {
it('tests setting up on Windows 10', async () => {
jest.spyOn(os, 'release').mockReturnValue('10.0.17063')
const installer = new WindowsToolchainInstaller(toolchain)
expect(installer['vsRequirement'].components).toStrictEqual([
expect(installer['vsRequirement']('x86_64').components).toStrictEqual([
'Microsoft.VisualStudio.Component.VC.Tools.x86.x64',
'Microsoft.VisualStudio.Component.Windows10SDK.17763'
])
})

it('tests setting up on ARM64 Windows 10', async () => {
jest.spyOn(os, 'release').mockReturnValue('10.0.17063')
const installer = new WindowsToolchainInstaller(toolchain)
expect(installer['vsRequirement']('aarch64').components).toStrictEqual([
'Microsoft.VisualStudio.Component.VC.Tools.ARM64',
'Microsoft.VisualStudio.Component.Windows10SDK.17763'
])
})

it('tests setting up on Windows 11', async () => {
jest.spyOn(os, 'release').mockReturnValue('10.0.22621')
const installer = new WindowsToolchainInstaller(toolchain)
expect(installer['vsRequirement'].components).toStrictEqual([
expect(installer['vsRequirement']('x86_64').components).toStrictEqual([
'Microsoft.VisualStudio.Component.VC.Tools.x86.x64',
'Microsoft.VisualStudio.Component.Windows11SDK.22621'
])
Expand All @@ -90,12 +99,31 @@ describe('windows toolchain installation verification', () => {
.spyOn(core, 'getInput')
.mockReturnValue('Microsoft.VisualStudio.Component.Windows11SDK.22621')
const installer = new WindowsToolchainInstaller(toolchain)
expect(installer['vsRequirement'].components).toStrictEqual([
expect(installer['vsRequirement']('x86_64').components).toStrictEqual([
'Microsoft.VisualStudio.Component.VC.Tools.x86.x64',
'Microsoft.VisualStudio.Component.Windows11SDK.22621'
])
})

it('tests setting up on Windows 10 with Windows 11 SDK', async () => {
jest.spyOn(os, 'release').mockReturnValue('10.0.17063')
const toolchain = {
name: 'Windows 10 Swift Development Snapshot',
date: new Date('2025-04-03 10:10:00-06:00'),
download: 'swift-DEVELOPMENT-SNAPSHOT-2025-04-03-a-windows10.exe',
dir: 'swift-DEVELOPMENT-SNAPSHOT-2025-04-03-a',
platform: 'windows10',
branch: 'development',
windows: true,
preventCaching: false
}
const installer = new WindowsToolchainInstaller(toolchain)
expect(installer['vsRequirement']('aarch64').components).toStrictEqual([
'Microsoft.VisualStudio.Component.VC.Tools.ARM64',
'Microsoft.VisualStudio.Component.Windows11SDK.22000'
])
})

it('tests download without caching', async () => {
const installer = new WindowsToolchainInstaller(toolchain)
expect(installer['version']).toStrictEqual(parseSemVer('5.8'))
Expand All @@ -118,7 +146,9 @@ describe('windows toolchain installation verification', () => {
const cacheSpy = jest.spyOn(cache, 'saveCache').mockResolvedValue(1)
jest.spyOn(toolCache, 'downloadTool').mockResolvedValue(download)
jest.spyOn(exec, 'exec').mockResolvedValue(0)
await expect(installer['download']()).resolves.toBe(`${download}.exe`)
await expect(installer['download']('x86_64')).resolves.toBe(
`${download}.exe`
)
expect(cacheSpy).not.toHaveBeenCalled()
})

Expand All @@ -138,7 +168,7 @@ describe('windows toolchain installation verification', () => {
jest.spyOn(fs, 'access').mockResolvedValue()
jest.spyOn(fs, 'cp').mockResolvedValue()
const toolPath = path.join(process.env.SystemDrive, 'Library')
await expect(installer['unpack'](exe)).resolves.toBe(toolPath)
await expect(installer['unpack'](exe, 'x86_64')).resolves.toBe(toolPath)
})

it('tests unpack for development snapshots', async () => {
Expand All @@ -160,7 +190,7 @@ describe('windows toolchain installation verification', () => {
'Program Files',
'Swift'
)
await expect(installer['unpack'](exe)).resolves.toBe(toolPath)
await expect(installer['unpack'](exe, 'x86_64')).resolves.toBe(toolPath)
})

it('tests unpack for failed path matching', async () => {
Expand All @@ -186,7 +216,7 @@ describe('windows toolchain installation verification', () => {
jest.spyOn(fs, 'cp').mockRejectedValue(new Error())
const addPathSpy = jest.spyOn(core, 'addPath')
const exportVariableSpy = jest.spyOn(core, 'exportVariable')
await expect(installer['unpack'](exe)).resolves.toBe('')
await expect(installer['unpack'](exe, 'x86_64')).resolves.toBe('')
expect(addPathSpy).toHaveBeenCalledTimes(2)
expect(exportVariableSpy).toHaveBeenCalledTimes(1)
expect(addPathSpy.mock.calls).toStrictEqual([['b'], ['c']])
Expand All @@ -198,7 +228,7 @@ describe('windows toolchain installation verification', () => {
const updateSpy = jest
.spyOn(VisualStudio.prototype, 'update')
.mockResolvedValue()
await installer['add']('')
await installer['add']('', 'x86_64')
expect(setupSpy).toHaveBeenCalled()
expect(updateSpy).toHaveBeenCalledWith('root')
})
Expand Down Expand Up @@ -236,7 +266,7 @@ describe('windows toolchain installation verification', () => {
jest.spyOn(fs, 'cp').mockRejectedValue(new Error())
const addPathSpy = jest.spyOn(core, 'addPath')
const exportVariableSpy = jest.spyOn(core, 'exportVariable')
await expect(installer['unpack'](exe)).resolves.toBe('')
await expect(installer['unpack'](exe, 'x86_64')).resolves.toBe('')
expect(addPathSpy).toHaveBeenCalledTimes(2)
expect(exportVariableSpy).toHaveBeenCalledTimes(1)
expect(addPathSpy.mock.calls).toStrictEqual([['b'], ['c']])
Expand All @@ -248,7 +278,7 @@ describe('windows toolchain installation verification', () => {
const updateSpy = jest
.spyOn(VisualStudio.prototype, 'update')
.mockResolvedValue()
await installer['add']('')
await installer['add']('', 'x86_64')
expect(setupSpy).toHaveBeenCalled()
expect(updateSpy).toHaveBeenCalledWith('root')
})
Expand Down Expand Up @@ -285,7 +315,7 @@ describe('windows toolchain installation verification', () => {
const swiftPath = path.join(toolPath, 'usr', 'bin')
const swiftDev = path.join(installation, 'Swift-development', 'bin')
const icu67 = path.join(installation, 'icu-67', 'usr', 'bin')
await installer['add'](installation)
await installer['add'](installation, 'x86_64')
expect(process.env.PATH?.includes(swiftPath)).toBeTruthy()
expect(process.env.PATH?.includes(swiftDev)).toBeTruthy()
expect(process.env.PATH?.includes(icu67)).toBeTruthy()
Expand Down
8 changes: 5 additions & 3 deletions __tests__/installer/xcode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe('macOS toolchain installation verification', () => {
jest.spyOn(cache, 'saveCache').mockResolvedValue(1)
jest.spyOn(toolCache, 'downloadTool').mockResolvedValue(download)
jest.spyOn(exec, 'exec').mockResolvedValue(0)
await expect(installer['download']()).resolves.toBe(download)
await expect(installer['download']('x86_64')).resolves.toBe(download)
})

it('tests unpack', async () => {
Expand All @@ -123,7 +123,9 @@ describe('macOS toolchain installation verification', () => {
jest.spyOn(toolCache, 'extractXar').mockResolvedValue(extracted)
jest.spyOn(toolCache, 'extractTar').mockResolvedValue(deployed)
jest.spyOn(exec, 'exec').mockResolvedValue(0)
await expect(installer['unpack'](download)).resolves.toBe(deployed)
await expect(installer['unpack'](download, 'x86_64')).resolves.toBe(
deployed
)
})

it('tests add to PATH', async () => {
Expand All @@ -135,7 +137,7 @@ describe('macOS toolchain installation verification', () => {
jest.spyOn(fs, 'readFile').mockResolvedValue('')
jest.spyOn(plist, 'parse').mockReturnValue({CFBundleIdentifier: identifier})
const swiftPath = path.join(deployed, 'usr', 'bin')
await installer['add'](deployed)
await installer['add'](deployed, 'x86_64')
expect(process.env.PATH?.includes(swiftPath)).toBeTruthy()
expect(process.env.TOOLCHAINS).toBe(identifier)
})
Expand Down
Loading
Loading