1
1
import * as path from 'path'
2
- import { promises as fs } from 'fs'
2
+ import { Dirent , promises as fs } from 'fs'
3
3
import * as core from '@actions/core'
4
4
import * as exec from '@actions/exec'
5
5
import * as cache from '@actions/cache'
@@ -57,7 +57,9 @@ describe('windows toolchain installation verification', () => {
57
57
'Microsoft.VisualStudio.Component.VC.ATL;Microsoft.VisualStudio.Component.VC.CMake.Project;Microsoft.VisualStudio.Component.Windows10SDK'
58
58
)
59
59
const installer = new WindowsToolchainInstaller ( toolchain )
60
- expect ( installer [ 'vsRequirement' ] ( 'x86_64' ) . components ) . toStrictEqual ( [
60
+ expect (
61
+ ( await installer [ 'vsRequirement' ] ( 'x86_64' ) ) . components
62
+ ) . toStrictEqual ( [
61
63
'Microsoft.VisualStudio.Component.VC.Tools.x86.x64' ,
62
64
'Microsoft.VisualStudio.Component.VC.ATL' ,
63
65
'Microsoft.VisualStudio.Component.VC.CMake.Project' ,
@@ -69,7 +71,9 @@ describe('windows toolchain installation verification', () => {
69
71
it ( 'tests setting up on Windows 10' , async ( ) => {
70
72
jest . spyOn ( os , 'release' ) . mockReturnValue ( '10.0.17063' )
71
73
const installer = new WindowsToolchainInstaller ( toolchain )
72
- expect ( installer [ 'vsRequirement' ] ( 'x86_64' ) . components ) . toStrictEqual ( [
74
+ expect (
75
+ ( await installer [ 'vsRequirement' ] ( 'x86_64' ) ) . components
76
+ ) . toStrictEqual ( [
73
77
'Microsoft.VisualStudio.Component.VC.Tools.x86.x64' ,
74
78
'Microsoft.VisualStudio.Component.Windows10SDK.17763'
75
79
] )
@@ -78,7 +82,9 @@ describe('windows toolchain installation verification', () => {
78
82
it ( 'tests setting up on ARM64 Windows 10' , async ( ) => {
79
83
jest . spyOn ( os , 'release' ) . mockReturnValue ( '10.0.17063' )
80
84
const installer = new WindowsToolchainInstaller ( toolchain )
81
- expect ( installer [ 'vsRequirement' ] ( 'arm64' ) . components ) . toStrictEqual ( [
85
+ expect (
86
+ ( await installer [ 'vsRequirement' ] ( 'arm64' ) ) . components
87
+ ) . toStrictEqual ( [
82
88
'Microsoft.VisualStudio.Component.VC.Tools.ARM64' ,
83
89
'Microsoft.VisualStudio.Component.Windows10SDK.17763'
84
90
] )
@@ -87,7 +93,9 @@ describe('windows toolchain installation verification', () => {
87
93
it ( 'tests setting up on Windows 11' , async ( ) => {
88
94
jest . spyOn ( os , 'release' ) . mockReturnValue ( '10.0.22621' )
89
95
const installer = new WindowsToolchainInstaller ( toolchain )
90
- expect ( installer [ 'vsRequirement' ] ( 'x86_64' ) . components ) . toStrictEqual ( [
96
+ expect (
97
+ ( await installer [ 'vsRequirement' ] ( 'x86_64' ) ) . components
98
+ ) . toStrictEqual ( [
91
99
'Microsoft.VisualStudio.Component.VC.Tools.x86.x64' ,
92
100
'Microsoft.VisualStudio.Component.Windows11SDK.22621'
93
101
] )
@@ -99,7 +107,9 @@ describe('windows toolchain installation verification', () => {
99
107
. spyOn ( core , 'getInput' )
100
108
. mockReturnValue ( 'Microsoft.VisualStudio.Component.Windows11SDK.22621' )
101
109
const installer = new WindowsToolchainInstaller ( toolchain )
102
- expect ( installer [ 'vsRequirement' ] ( 'x86_64' ) . components ) . toStrictEqual ( [
110
+ expect (
111
+ ( await installer [ 'vsRequirement' ] ( 'x86_64' ) ) . components
112
+ ) . toStrictEqual ( [
103
113
'Microsoft.VisualStudio.Component.VC.Tools.x86.x64' ,
104
114
'Microsoft.VisualStudio.Component.Windows11SDK.22621'
105
115
] )
@@ -118,12 +128,45 @@ describe('windows toolchain installation verification', () => {
118
128
preventCaching : false
119
129
}
120
130
const installer = new WindowsToolchainInstaller ( toolchain )
121
- expect ( installer [ 'vsRequirement' ] ( 'arm64' ) . components ) . toStrictEqual ( [
131
+ expect (
132
+ ( await installer [ 'vsRequirement' ] ( 'arm64' ) ) . components
133
+ ) . toStrictEqual ( [
122
134
'Microsoft.VisualStudio.Component.VC.Tools.ARM64' ,
123
135
'Microsoft.VisualStudio.Component.Windows11SDK.22000'
124
136
] )
125
137
} )
126
138
139
+ it ( 'tests setting up on Windows 10 with Windows 11 SDK with unavailable recommended SDK' , async ( ) => {
140
+ jest . spyOn ( os , 'release' ) . mockReturnValue ( '10.0.17063' )
141
+ jest . spyOn ( fs , 'readdir' ) . mockResolvedValue ( [
142
+ {
143
+ name : 'wdf' ,
144
+ isDirectory : ( ) => true
145
+ } as unknown as Dirent ,
146
+ {
147
+ name : '10.0.22621.0' ,
148
+ isDirectory : ( ) => true
149
+ } as unknown as Dirent
150
+ ] )
151
+ const toolchain = {
152
+ name : 'Windows 10 Swift Development Snapshot' ,
153
+ date : new Date ( '2025-04-03 10:10:00-06:00' ) ,
154
+ download : 'swift-DEVELOPMENT-SNAPSHOT-2025-04-03-a-windows10.exe' ,
155
+ dir : 'swift-DEVELOPMENT-SNAPSHOT-2025-04-03-a' ,
156
+ platform : 'windows10' ,
157
+ branch : 'development' ,
158
+ windows : true ,
159
+ preventCaching : false
160
+ }
161
+ const installer = new WindowsToolchainInstaller ( toolchain )
162
+ expect (
163
+ ( await installer [ 'vsRequirement' ] ( 'arm64' ) ) . components
164
+ ) . toStrictEqual ( [
165
+ 'Microsoft.VisualStudio.Component.VC.Tools.ARM64' ,
166
+ 'Microsoft.VisualStudio.Component.Windows11SDK.22621'
167
+ ] )
168
+ } )
169
+
127
170
it ( 'tests download without caching' , async ( ) => {
128
171
const installer = new WindowsToolchainInstaller ( toolchain )
129
172
expect ( installer [ 'version' ] ) . toStrictEqual ( parseSemVer ( '5.8' ) )
0 commit comments