@@ -6260,4 +6260,112 @@ final class BuildPlanTests: XCTestCase {
6260
6260
let dylibs = Array ( buildProduct. dylibs. map ( { $0. product. name} ) ) . sorted ( )
6261
6261
XCTAssertEqual ( dylibs, [ " BarLogging " , " FooLogging " ] )
6262
6262
}
6263
+
6264
+ func testSwiftPackageWithProvidedLibraries( ) throws {
6265
+ let fs = InMemoryFileSystem (
6266
+ emptyFiles:
6267
+ " /A/Sources/ATarget/main.swift " ,
6268
+ " /Libraries/B/BTarget.swiftmodule " ,
6269
+ " /Libraries/C/CTarget.swiftmodule "
6270
+ )
6271
+
6272
+ let observability = ObservabilitySystem . makeForTesting ( )
6273
+ let graph = try loadModulesGraph (
6274
+ fileSystem: fs,
6275
+ manifests: [
6276
+ Manifest . createRootManifest (
6277
+ displayName: " A " ,
6278
+ path: " /A " ,
6279
+ dependencies: [
6280
+ . localSourceControl( path: " /B " , requirement: . upToNextMajor( from: " 1.0.0 " ) ) ,
6281
+ . localSourceControl( path: " /C " , requirement: . upToNextMajor( from: " 1.0.0 " ) ) ,
6282
+ ] ,
6283
+ products: [
6284
+ ProductDescription (
6285
+ name: " A " ,
6286
+ type: . executable,
6287
+ targets: [ " ATarget " ]
6288
+ )
6289
+ ] ,
6290
+ targets: [
6291
+ TargetDescription ( name: " ATarget " , dependencies: [ " BLibrary " , " CLibrary " ] )
6292
+ ]
6293
+ ) ,
6294
+ Manifest . createFileSystemManifest (
6295
+ displayName: " B " ,
6296
+ path: " /B " ,
6297
+ products: [
6298
+ ProductDescription ( name: " BLibrary " , type: . library( . automatic) , targets: [ " BTarget " ] ) ,
6299
+ ] ,
6300
+ targets: [
6301
+ TargetDescription (
6302
+ name: " BTarget " ,
6303
+ path: " /Libraries/B " ,
6304
+ type: . providedLibrary
6305
+ )
6306
+ ]
6307
+ ) ,
6308
+ Manifest . createFileSystemManifest (
6309
+ displayName: " C " ,
6310
+ path: " /C " ,
6311
+ products: [
6312
+ ProductDescription ( name: " CLibrary " , type: . library( . automatic) , targets: [ " CTarget " ] ) ,
6313
+ ] ,
6314
+ targets: [
6315
+ TargetDescription (
6316
+ name: " CTarget " ,
6317
+ path: " /Libraries/C " ,
6318
+ type: . providedLibrary
6319
+ )
6320
+ ]
6321
+ ) ,
6322
+ ] ,
6323
+ observabilityScope: observability. topScope
6324
+ )
6325
+
6326
+ XCTAssertNoDiagnostics ( observability. diagnostics)
6327
+
6328
+ let plan = try BuildPlan (
6329
+ buildParameters: mockBuildParameters ( ) ,
6330
+ graph: graph,
6331
+ fileSystem: fs,
6332
+ observabilityScope: observability. topScope
6333
+ )
6334
+ let result = try BuildPlanResult ( plan: plan)
6335
+
6336
+ result. checkProductsCount ( 1 )
6337
+ result. checkTargetsCount ( 1 )
6338
+
6339
+ XCTAssertMatch (
6340
+ try result. target ( for: " ATarget " ) . swiftTarget ( ) . compileArguments ( ) ,
6341
+ [
6342
+ . anySequence,
6343
+ " -I " , " /Libraries/C " ,
6344
+ " -I " , " /Libraries/B " ,
6345
+ . anySequence
6346
+ ]
6347
+ )
6348
+
6349
+ let linkerArgs = try result. buildProduct ( for: " A " ) . linkArguments ( )
6350
+
6351
+ XCTAssertMatch (
6352
+ linkerArgs,
6353
+ [
6354
+ . anySequence,
6355
+ " -L " , " /Libraries/B " ,
6356
+ " -l " , " BTarget " ,
6357
+ . anySequence
6358
+ ]
6359
+ )
6360
+
6361
+ XCTAssertMatch (
6362
+ linkerArgs,
6363
+ [
6364
+ . anySequence,
6365
+ " -L " , " /Libraries/C " ,
6366
+ " -l " , " CTarget " ,
6367
+ . anySequence
6368
+ ]
6369
+ )
6370
+ }
6263
6371
}
0 commit comments