@@ -2044,12 +2044,18 @@ final class PubGrubTestsBasicGraphs: XCTestCase {
20442044 ] )
20452045
20462046 let result = resolver. solve ( constraints: dependencies1)
2047- // Available libraries are filtered from the resolver results, so this is expected to be empty.
2048- AssertResult ( result, [ ] )
2047+ print ( try result. get ( ) )
2048+ AssertResult ( result, [
2049+ (
2050+ " foo " ,
2051+ . providedLibrary( . init( " https://example.com/org/foo " ) , . init( " /foo " ) ) ,
2052+ . version( . init( stringLiteral: " 1.0.0 " ) )
2053+ ) ,
2054+ ] )
20492055
20502056 let result2 = resolver. solve ( constraints: dependencies2)
20512057 AssertResult ( result2, [
2052- ( " foo " , . version( . init( stringLiteral: " 1.2.0 " ) ) ) ,
2058+ ( " foo " , fooRef . kind , . version( . init( stringLiteral: " 1.2.0 " ) ) ) ,
20532059 ] )
20542060 }
20552061
@@ -2101,14 +2107,23 @@ final class PubGrubTestsBasicGraphs: XCTestCase {
21012107 " target " : ( . versionSet( . range( . upToNextMajor( from: " 2.0.0 " ) ) ) , . everything) ,
21022108 ] )
21032109
2104- // This behavior requires an explanation - "foo" is elided because 1.1.0 is prebuilt.
2105- // It matches "root" requirements but without prebuilt library the solver would pick
2106- // "1.0.0" because "foo" 1.1.0 dependency version requirements are incompatible with
2107- // "target" 2.0.0.
2110+ // This behavior requires an explanation - "foo" is selected to be 1.1.0 because its
2111+ // prebuilt matches "root" requirements but without prebuilt library the solver would
2112+ // pick "1.0.0" because "foo" 1.1.0 dependency version requirements are incompatible
2113+ // with "target" 2.0.0.
21082114
21092115 let result = resolver. solve ( constraints: dependencies)
21102116 AssertResult ( result, [
2111- ( " target " , . version( . init( stringLiteral: " 2.0.0 " ) ) ) ,
2117+ (
2118+ " foo " ,
2119+ . providedLibrary( . init( " https://example.com/org/foo " ) , . init( " /foo " ) ) ,
2120+ . version( . init( stringLiteral: " 1.1.0 " ) )
2121+ ) ,
2122+ (
2123+ " target " ,
2124+ . localSourceControl( " /target " ) ,
2125+ . version( . init( stringLiteral: " 2.0.0 " ) )
2126+ ) ,
21122127 ] )
21132128 }
21142129
@@ -2152,8 +2167,8 @@ final class PubGrubTestsBasicGraphs: XCTestCase {
21522167
21532168 let result = resolver. solve ( constraints: dependencies)
21542169 AssertResult ( result, [
2155- ( " foo " , . version( . init( stringLiteral: " 1.1.0 " ) ) ) ,
2156- ( " bar " , . version( . init( stringLiteral: " 1.0.0 " ) ) ) ,
2170+ ( " foo " , fooRef . kind , . version( . init( stringLiteral: " 1.1.0 " ) ) ) ,
2171+ ( " bar " , . localSourceControl ( " /bar " ) , . version( . init( stringLiteral: " 1.0.0 " ) ) ) ,
21572172 ] )
21582173 }
21592174}
@@ -3297,6 +3312,22 @@ private func AssertBindings(
32973312 _ packages: [ ( identity: PackageIdentity , version: BoundVersion ) ] ,
32983313 file: StaticString = #file,
32993314 line: UInt = #line
3315+ ) {
3316+ AssertBindings (
3317+ bindings,
3318+ packages. map {
3319+ ( identity: $0, kind: nil , version: $1)
3320+ } ,
3321+ file: file,
3322+ line: line
3323+ )
3324+ }
3325+
3326+ private func AssertBindings(
3327+ _ bindings: [ DependencyResolverBinding ] ,
3328+ _ packages: [ ( identity: PackageIdentity , kind: PackageReference . Kind ? , version: BoundVersion ) ] ,
3329+ file: StaticString = #file,
3330+ line: UInt = #line
33003331) {
33013332 if bindings. count > packages. count {
33023333 let unexpectedBindings = bindings
@@ -3314,7 +3345,17 @@ private func AssertBindings(
33143345 )
33153346 }
33163347 for package in packages {
3317- guard let binding = bindings. first ( where: { $0. package . identity == package . identity } ) else {
3348+ guard let binding = bindings. first ( where: {
3349+ if $0. package . identity != package . identity {
3350+ return false
3351+ }
3352+
3353+ if let kind = package . kind, $0. package . kind != kind {
3354+ return false
3355+ }
3356+
3357+ return true
3358+ } ) else {
33183359 XCTFail ( " No binding found for \( package . identity) . " , file: file, line: line)
33193360 continue
33203361 }
@@ -3335,10 +3376,24 @@ private func AssertResult(
33353376 _ packages: [ ( identifier: String , version: BoundVersion ) ] ,
33363377 file: StaticString = #file,
33373378 line: UInt = #line
3379+ ) {
3380+ AssertResult ( result, packages. map { ( $0, nil , $1) } , file: file, line: line)
3381+ }
3382+
3383+ private func AssertResult(
3384+ _ result: Result < [ DependencyResolverBinding ] , Error > ,
3385+ _ packages: [ ( identifier: String , kind: PackageReference . Kind ? , version: BoundVersion ) ] ,
3386+ file: StaticString = #file,
3387+ line: UInt = #line
33383388) {
33393389 switch result {
33403390 case . success( let bindings) :
3341- AssertBindings ( bindings, packages. map { ( PackageIdentity ( $0. identifier) , $0. version) } , file: file, line: line)
3391+ AssertBindings (
3392+ bindings,
3393+ packages. map { ( PackageIdentity ( $0. identifier) , $0. kind, $0. version) } ,
3394+ file: file,
3395+ line: line
3396+ )
33423397 case . failure( let error) :
33433398 XCTFail ( " Unexpected error: \( error) " , file: file, line: line)
33443399 }
@@ -3544,6 +3599,18 @@ public struct MockProvider: PackageContainerProvider {
35443599 ) -> Void
35453600 ) {
35463601 queue. async {
3602+ if case . providedLibrary( _, _) = package . kind {
3603+ do {
3604+ let container = try ProvidedLibraryPackageContainer (
3605+ package : package ,
3606+ observabilityScope: observabilityScope
3607+ )
3608+ return completion ( . success( container) )
3609+ } catch {
3610+ return completion ( . failure( error) )
3611+ }
3612+ }
3613+
35473614 completion (
35483615 self . containersByIdentifier [ package ] . map { . success( $0) } ??
35493616 . failure( _MockLoadingError. unknownModule)
0 commit comments