@@ -20,6 +20,7 @@ final class LinuxRecipeTests: XCTestCase {
20
20
21
21
func createRecipe(
22
22
hostTriple: Triple = Triple ( " x86_64-unknown-linux-gnu " ) ,
23
+ linuxDistribution: LinuxDistribution ,
23
24
swiftVersion: String = " 6.0 " ,
24
25
withDocker: Bool = false ,
25
26
fromContainerImage: String ? = nil ,
@@ -30,7 +31,7 @@ final class LinuxRecipeTests: XCTestCase {
30
31
try LinuxRecipe (
31
32
targetTriple: Triple ( " aarch64-unknown-linux-gnu " ) ,
32
33
hostTriple: hostTriple,
33
- linuxDistribution: . init ( name : . ubuntu , version : " 22.04 " ) ,
34
+ linuxDistribution: linuxDistribution ,
34
35
swiftVersion: swiftVersion,
35
36
swiftBranch: nil , lldVersion: " " ,
36
37
withDocker: withDocker, fromContainerImage: fromContainerImage,
@@ -73,8 +74,10 @@ final class LinuxRecipeTests: XCTestCase {
73
74
) ,
74
75
]
75
76
77
+ let linuxDistribution = try LinuxDistribution ( name: . ubuntu, version: " 22.04 " )
76
78
for testCase in testCases {
77
- let recipe = try self . createRecipe ( swiftVersion: testCase. swiftVersion)
79
+ let recipe = try self . createRecipe (
80
+ linuxDistribution: linuxDistribution, swiftVersion: testCase. swiftVersion)
78
81
var toolset = Toolset ( rootPath: nil )
79
82
recipe. applyPlatformOptions (
80
83
toolset: & toolset, targetTriple: testCase. targetTriple
@@ -87,7 +90,9 @@ final class LinuxRecipeTests: XCTestCase {
87
90
}
88
91
89
92
func testToolOptionsForPreinstalledSdk( ) throws {
90
- let recipe = try self . createRecipe ( includeHostToolchain: false )
93
+ let linuxDistribution = try LinuxDistribution ( name: . ubuntu, version: " 22.04 " )
94
+ let recipe = try self . createRecipe (
95
+ linuxDistribution: linuxDistribution, includeHostToolchain: false )
91
96
var toolset = Toolset ( rootPath: " swift.xctoolchain " )
92
97
recipe. applyPlatformOptions (
93
98
toolset: & toolset, targetTriple: Triple ( " x86_64-unknown-linux-gnu " )
@@ -137,29 +142,33 @@ final class LinuxRecipeTests: XCTestCase {
137
142
138
143
func testItemsToDownloadForMacOSHost( ) throws {
139
144
let hostTriple = Triple ( " x86_64-apple-macos " )
145
+ let linuxDistribution = try LinuxDistribution ( name: . ubuntu, version: " 22.04 " )
140
146
let testCases :
141
147
[ (
142
148
recipe: LinuxRecipe , includesHostLLVM: Bool , includesTargetSwift: Bool ,
143
149
includesHostSwift: Bool
144
150
) ] = [
145
151
(
146
152
// Remote tarballs on Swift < 6.0
147
- recipe: try createRecipe ( hostTriple: hostTriple, swiftVersion: " 5.10 " ) ,
153
+ recipe: try createRecipe (
154
+ hostTriple: hostTriple, linuxDistribution: linuxDistribution, swiftVersion: " 5.10 " ) ,
148
155
includesHostLLVM: true ,
149
156
includesTargetSwift: true ,
150
157
includesHostSwift: true
151
158
) ,
152
159
(
153
160
// Remote tarballs on Swift >= 6.0
154
- recipe: try createRecipe ( hostTriple: hostTriple, swiftVersion: " 6.0 " ) ,
161
+ recipe: try createRecipe (
162
+ hostTriple: hostTriple, linuxDistribution: linuxDistribution, swiftVersion: " 6.0 " ) ,
155
163
includesHostLLVM: false ,
156
164
includesTargetSwift: true ,
157
165
includesHostSwift: true
158
166
) ,
159
167
(
160
168
// Remote target tarball with preinstalled toolchain
161
169
recipe: try createRecipe (
162
- hostTriple: hostTriple, swiftVersion: " 5.9 " , includeHostToolchain: false ) ,
170
+ hostTriple: hostTriple, linuxDistribution: linuxDistribution, swiftVersion: " 5.9 " ,
171
+ includeHostToolchain: false ) ,
163
172
includesHostLLVM: false ,
164
173
includesTargetSwift: true ,
165
174
includesHostSwift: false
@@ -168,6 +177,7 @@ final class LinuxRecipeTests: XCTestCase {
168
177
// Local packages with Swift < 6.0
169
178
recipe: try createRecipe (
170
179
hostTriple: hostTriple,
180
+ linuxDistribution: linuxDistribution,
171
181
swiftVersion: " 5.10 " ,
172
182
hostSwiftPackagePath: " /path/to/host/swift " ,
173
183
targetSwiftPackagePath: " /path/to/target/swift "
@@ -180,6 +190,7 @@ final class LinuxRecipeTests: XCTestCase {
180
190
// Local packages with Swift >= 6.0
181
191
recipe: try createRecipe (
182
192
hostTriple: hostTriple,
193
+ linuxDistribution: linuxDistribution,
183
194
swiftVersion: " 6.0 " ,
184
195
hostSwiftPackagePath: " /path/to/host/swift " ,
185
196
targetSwiftPackagePath: " /path/to/target/swift "
@@ -202,30 +213,35 @@ final class LinuxRecipeTests: XCTestCase {
202
213
203
214
func testItemsToDownloadForLinuxHost( ) throws {
204
215
let hostTriple = Triple ( " x86_64-unknown-linux-gnu " )
216
+ let linuxDistribution = try LinuxDistribution ( name: . ubuntu, version: " 22.04 " )
205
217
let testCases = [
206
218
(
207
219
// Remote tarballs on Swift < 6.0
208
- recipe: try createRecipe ( hostTriple: hostTriple, swiftVersion: " 5.10 " ) ,
220
+ recipe: try createRecipe (
221
+ hostTriple: hostTriple, linuxDistribution: linuxDistribution, swiftVersion: " 5.10 " ) ,
209
222
includesTargetSwift: true ,
210
223
includesHostSwift: true
211
224
) ,
212
225
(
213
226
// Remote tarballs on Swift >= 6.0
214
- recipe: try createRecipe ( hostTriple: hostTriple, swiftVersion: " 6.0 " ) ,
227
+ recipe: try createRecipe (
228
+ hostTriple: hostTriple, linuxDistribution: linuxDistribution, swiftVersion: " 6.0 " ) ,
215
229
includesTargetSwift: true ,
216
230
includesHostSwift: true
217
231
) ,
218
232
(
219
233
// Remote target tarball with preinstalled toolchain
220
234
recipe: try createRecipe (
221
- hostTriple: hostTriple, swiftVersion: " 5.9 " , includeHostToolchain: false ) ,
235
+ hostTriple: hostTriple, linuxDistribution: linuxDistribution, swiftVersion: " 5.9 " ,
236
+ includeHostToolchain: false ) ,
222
237
includesTargetSwift: true ,
223
238
includesHostSwift: false
224
239
) ,
225
240
(
226
241
// Local packages with Swift < 6.0
227
242
recipe: try createRecipe (
228
243
hostTriple: hostTriple,
244
+ linuxDistribution: linuxDistribution,
229
245
swiftVersion: " 5.10 " ,
230
246
hostSwiftPackagePath: " /path/to/host/swift " ,
231
247
targetSwiftPackagePath: " /path/to/target/swift "
@@ -237,6 +253,7 @@ final class LinuxRecipeTests: XCTestCase {
237
253
// Local packages with Swift >= 6.0
238
254
recipe: try createRecipe (
239
255
hostTriple: hostTriple,
256
+ linuxDistribution: linuxDistribution,
240
257
swiftVersion: " 6.0 " ,
241
258
hostSwiftPackagePath: " /path/to/host/swift " ,
242
259
targetSwiftPackagePath: " /path/to/target/swift "
@@ -256,6 +273,89 @@ final class LinuxRecipeTests: XCTestCase {
256
273
}
257
274
}
258
275
276
+ // Ubuntu toolchains will be selected for Debian 11 and 12 depending on the Swift version
277
+ func testItemsToDownloadForDebianTargets( ) throws {
278
+ let hostTriple = Triple ( " x86_64-unknown-linux-gnu " )
279
+ let testCases = [
280
+ (
281
+ // Debian 11 -> ubuntu20.04
282
+ recipe: try createRecipe (
283
+ hostTriple: hostTriple,
284
+ linuxDistribution: try LinuxDistribution ( name: . debian, version: " 11 " ) ,
285
+ swiftVersion: " 5.9 "
286
+ ) ,
287
+ expectedTargetSwift: " ubuntu20.04 "
288
+ ) ,
289
+ (
290
+ // Debian 12 with Swift 5.9 -> ubuntu22.04
291
+ recipe: try createRecipe (
292
+ hostTriple: hostTriple,
293
+ linuxDistribution: try LinuxDistribution ( name: . debian, version: " 12 " ) ,
294
+ swiftVersion: " 5.9 "
295
+ ) ,
296
+ expectedTargetSwift: " ubuntu22.04 "
297
+ ) ,
298
+ (
299
+ // Debian 12 with Swift 5.10 -> ubuntu22.04
300
+ recipe: try createRecipe (
301
+ hostTriple: hostTriple,
302
+ linuxDistribution: try LinuxDistribution ( name: . debian, version: " 12 " ) ,
303
+ swiftVersion: " 5.10 "
304
+ ) ,
305
+ expectedTargetSwift: " ubuntu22.04 "
306
+ ) ,
307
+ (
308
+ // Debian 11 with Swift 6.0 -> ubuntu20.04
309
+ recipe: try createRecipe (
310
+ hostTriple: hostTriple,
311
+ linuxDistribution: try LinuxDistribution ( name: . debian, version: " 11 " ) ,
312
+ swiftVersion: " 6.0 "
313
+ ) ,
314
+ expectedTargetSwift: " ubuntu20.04 "
315
+ ) ,
316
+ (
317
+ // Debian 12 with Swift 5.10.1 -> debian12
318
+ recipe: try createRecipe (
319
+ hostTriple: hostTriple,
320
+ linuxDistribution: try LinuxDistribution ( name: . debian, version: " 12 " ) ,
321
+ swiftVersion: " 5.10.1 "
322
+ ) ,
323
+ expectedTargetSwift: " debian12 "
324
+ ) ,
325
+ (
326
+ // Debian 12 with Swift 6.0 -> debian12
327
+ recipe: try createRecipe (
328
+ hostTriple: hostTriple,
329
+ linuxDistribution: try LinuxDistribution ( name: . debian, version: " 12 " ) ,
330
+ swiftVersion: " 6.0 "
331
+ ) ,
332
+ expectedTargetSwift: " debian12 "
333
+ ) ,
334
+ ]
335
+
336
+ for testCase in testCases {
337
+
338
+ let pathsConfiguration = PathsConfiguration (
339
+ sourceRoot: " . " ,
340
+ artifactID: " my-sdk " ,
341
+ targetTriple: testCase. recipe. mainTargetTriple
342
+ )
343
+ let downloadableArtifacts = try DownloadableArtifacts (
344
+ hostTriple: testCase. recipe. mainHostTriple,
345
+ targetTriple: testCase. recipe. mainTargetTriple,
346
+ testCase. recipe. versionsConfiguration,
347
+ pathsConfiguration
348
+ )
349
+ let itemsToDownload = testCase. recipe. itemsToDownload ( from: downloadableArtifacts)
350
+ let targetSwiftRemoteURL = itemsToDownload. first ( where: {
351
+ $0. remoteURL == downloadableArtifacts. targetSwift. remoteURL
352
+ } ) ? . remoteURL. absoluteString
353
+
354
+ // If this is a Linux host, we do not download LLVM
355
+ XCTAssert ( targetSwiftRemoteURL!. contains ( testCase. expectedTargetSwift) )
356
+ }
357
+ }
358
+
259
359
func testHostTriples( ) throws {
260
360
let allHostTriples = [
261
361
Triple ( " x86_64-unknown-linux-gnu " ) ,
@@ -273,8 +373,10 @@ final class LinuxRecipeTests: XCTestCase {
273
373
) ,
274
374
]
275
375
376
+ let linuxDistribution = try LinuxDistribution ( name: . ubuntu, version: " 22.04 " )
276
377
for testCase in testCases {
277
378
let recipe = try createRecipe (
379
+ linuxDistribution: linuxDistribution,
278
380
swiftVersion: testCase. swiftVersion,
279
381
includeHostToolchain: testCase. includeHostToolchain
280
382
)
0 commit comments