@@ -2044,12 +2044,18 @@ final class PubGrubTestsBasicGraphs: XCTestCase {
2044
2044
] )
2045
2045
2046
2046
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
+ ] )
2049
2055
2050
2056
let result2 = resolver. solve ( constraints: dependencies2)
2051
2057
AssertResult ( result2, [
2052
- ( " foo " , . version( . init( stringLiteral: " 1.2.0 " ) ) ) ,
2058
+ ( " foo " , fooRef . kind , . version( . init( stringLiteral: " 1.2.0 " ) ) ) ,
2053
2059
] )
2054
2060
}
2055
2061
@@ -2101,14 +2107,23 @@ final class PubGrubTestsBasicGraphs: XCTestCase {
2101
2107
" target " : ( . versionSet( . range( . upToNextMajor( from: " 2.0.0 " ) ) ) , . everything) ,
2102
2108
] )
2103
2109
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.
2108
2114
2109
2115
let result = resolver. solve ( constraints: dependencies)
2110
2116
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
+ ) ,
2112
2127
] )
2113
2128
}
2114
2129
@@ -2152,8 +2167,8 @@ final class PubGrubTestsBasicGraphs: XCTestCase {
2152
2167
2153
2168
let result = resolver. solve ( constraints: dependencies)
2154
2169
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 " ) ) ) ,
2157
2172
] )
2158
2173
}
2159
2174
}
@@ -3297,6 +3312,22 @@ private func AssertBindings(
3297
3312
_ packages: [ ( identity: PackageIdentity , version: BoundVersion ) ] ,
3298
3313
file: StaticString = #file,
3299
3314
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
3300
3331
) {
3301
3332
if bindings. count > packages. count {
3302
3333
let unexpectedBindings = bindings
@@ -3314,7 +3345,17 @@ private func AssertBindings(
3314
3345
)
3315
3346
}
3316
3347
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 {
3318
3359
XCTFail ( " No binding found for \( package . identity) . " , file: file, line: line)
3319
3360
continue
3320
3361
}
@@ -3335,10 +3376,24 @@ private func AssertResult(
3335
3376
_ packages: [ ( identifier: String , version: BoundVersion ) ] ,
3336
3377
file: StaticString = #file,
3337
3378
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
3338
3388
) {
3339
3389
switch result {
3340
3390
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
+ )
3342
3397
case . failure( let error) :
3343
3398
XCTFail ( " Unexpected error: \( error) " , file: file, line: line)
3344
3399
}
@@ -3544,6 +3599,18 @@ public struct MockProvider: PackageContainerProvider {
3544
3599
) -> Void
3545
3600
) {
3546
3601
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
+
3547
3614
completion (
3548
3615
self . containersByIdentifier [ package ] . map { . success( $0) } ??
3549
3616
. failure( _MockLoadingError. unknownModule)
0 commit comments