@@ -6217,4 +6217,159 @@ final class BuildPlanTests: XCTestCase {
6217
6217
let dylibs = Array ( buildProduct. dylibs. map ( { $0. product. name} ) ) . sorted ( )
6218
6218
XCTAssertEqual ( dylibs, [ " BarLogging " , " FooLogging " ] )
6219
6219
}
6220
+
6221
+ func testSwiftPackageWithProvidedLibraries( ) throws {
6222
+ let fs = InMemoryFileSystem (
6223
+ emptyFiles:
6224
+ " /A/Sources/ATarget/main.swift " ,
6225
+ " /Libraries/B/BTarget.swiftmodule " ,
6226
+ " /Libraries/C/CTarget.swiftmodule "
6227
+ )
6228
+
6229
+ let observability = ObservabilitySystem . makeForTesting ( )
6230
+ let graph = try loadModulesGraph (
6231
+ fileSystem: fs,
6232
+ manifests: [
6233
+ Manifest . createRootManifest (
6234
+ displayName: " A " ,
6235
+ path: " /A " ,
6236
+ dependencies: [
6237
+ . localSourceControl( path: " /B " , requirement: . upToNextMajor( from: " 1.0.0 " ) ) ,
6238
+ . localSourceControl( path: " /C " , requirement: . upToNextMajor( from: " 1.0.0 " ) ) ,
6239
+ ] ,
6240
+ products: [
6241
+ ProductDescription (
6242
+ name: " A " ,
6243
+ type: . executable,
6244
+ targets: [ " ATarget " ]
6245
+ )
6246
+ ] ,
6247
+ targets: [
6248
+ TargetDescription ( name: " ATarget " , dependencies: [ " BLibrary " , " CLibrary " ] )
6249
+ ]
6250
+ ) ,
6251
+ Manifest . createFileSystemManifest (
6252
+ displayName: " B " ,
6253
+ path: " /B " ,
6254
+ products: [
6255
+ ProductDescription ( name: " BLibrary " , type: . library( . automatic) , targets: [ " BTarget " ] ) ,
6256
+ ] ,
6257
+ targets: [
6258
+ TargetDescription (
6259
+ name: " BTarget " ,
6260
+ path: " /Libraries/B " ,
6261
+ type: . providedLibrary
6262
+ )
6263
+ ]
6264
+ ) ,
6265
+ Manifest . createFileSystemManifest (
6266
+ displayName: " C " ,
6267
+ path: " /C " ,
6268
+ products: [
6269
+ ProductDescription ( name: " CLibrary " , type: . library( . automatic) , targets: [ " CTarget " ] ) ,
6270
+ ] ,
6271
+ targets: [
6272
+ TargetDescription (
6273
+ name: " CTarget " ,
6274
+ path: " /Libraries/C " ,
6275
+ type: . providedLibrary
6276
+ )
6277
+ ]
6278
+ ) ,
6279
+ ] ,
6280
+ observabilityScope: observability. topScope
6281
+ )
6282
+
6283
+ XCTAssertNoDiagnostics ( observability. diagnostics)
6284
+
6285
+ let plan = try BuildPlan (
6286
+ buildParameters: mockBuildParameters ( ) ,
6287
+ graph: graph,
6288
+ fileSystem: fs,
6289
+ observabilityScope: observability. topScope
6290
+ )
6291
+ let result = try BuildPlanResult ( plan: plan)
6292
+
6293
+ result. checkProductsCount ( 1 )
6294
+ result. checkTargetsCount ( 1 )
6295
+
6296
+ XCTAssertMatch (
6297
+ try result. target ( for: " ATarget " ) . swiftTarget ( ) . compileArguments ( ) ,
6298
+ [
6299
+ . anySequence,
6300
+ " -I " , " /Libraries/C " ,
6301
+ " -I " , " /Libraries/B " ,
6302
+ . anySequence
6303
+ ]
6304
+ )
6305
+
6306
+ let linkerArgs = try result. buildProduct ( for: " A " ) . linkArguments ( )
6307
+
6308
+ XCTAssertMatch (
6309
+ linkerArgs,
6310
+ [
6311
+ . anySequence,
6312
+ " -L " , " /Libraries/B " ,
6313
+ " -l " , " BTarget " ,
6314
+ . anySequence
6315
+ ]
6316
+ )
6317
+
6318
+ XCTAssertMatch (
6319
+ linkerArgs,
6320
+ [
6321
+ . anySequence,
6322
+ " -L " , " /Libraries/C " ,
6323
+ " -l " , " CTarget " ,
6324
+ . anySequence
6325
+ ]
6326
+ )
6327
+ }
6328
+
6329
+ func testDefaultVersions( ) throws {
6330
+ let fs = InMemoryFileSystem ( emptyFiles:
6331
+ " /Pkg/Sources/foo/foo.swift "
6332
+ )
6333
+
6334
+ let expectedVersions = [
6335
+ ToolsVersion . v4: " 4 " ,
6336
+ ToolsVersion . v4_2: " 4.2 " ,
6337
+ ToolsVersion . v5: " 5 " ,
6338
+ ToolsVersion . v6_0: " 6 " ,
6339
+ ToolsVersion . vNext: " 6 "
6340
+ ]
6341
+ for (toolsVersion, expectedVersionString) in expectedVersions {
6342
+ let observability = ObservabilitySystem . makeForTesting ( )
6343
+ let graph = try loadModulesGraph (
6344
+ fileSystem: fs,
6345
+ manifests: [
6346
+ Manifest . createRootManifest (
6347
+ displayName: " Pkg " ,
6348
+ path: " /Pkg " ,
6349
+ toolsVersion: toolsVersion,
6350
+ targets: [
6351
+ TargetDescription (
6352
+ name: " foo "
6353
+ ) ,
6354
+ ]
6355
+ ) ,
6356
+ ] ,
6357
+ observabilityScope: observability. topScope
6358
+ )
6359
+
6360
+ let result = try BuildPlanResult ( plan: BuildPlan (
6361
+ buildParameters: mockBuildParameters ( ) ,
6362
+ graph: graph,
6363
+ fileSystem: fs,
6364
+ observabilityScope: observability. topScope
6365
+ ) )
6366
+
6367
+ XCTAssertMatch (
6368
+ try result. target ( for: " foo " ) . swiftTarget ( ) . compileArguments ( ) ,
6369
+ [
6370
+ " -swift-version " , . equal( expectedVersionString)
6371
+ ]
6372
+ )
6373
+ }
6374
+ }
6220
6375
}
0 commit comments