File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed
Tests/PackageLoadingTests Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -345,7 +345,7 @@ extension PackageDependencyDescription {
345
345
} else if dependencyLocation. hasPrefix ( filePrefix) {
346
346
// FIXME: SwiftPM can't handle file locations with file:// scheme so we need to
347
347
// strip that. We need to design a Location data structure for SwiftPM.
348
- return AbsolutePath ( String ( dependencyLocation. dropFirst ( filePrefix. count) ) ) . pathString
348
+ return AbsolutePath ( String ( dependencyLocation. dropFirst ( filePrefix. count) ) , relativeTo : AbsolutePath ( packageLocation ) ) . pathString
349
349
} else if URL . scheme ( dependencyLocation) == nil {
350
350
// If the dependency URL is not remote, try to "fix" it.
351
351
// If the URL has no scheme, we treat it as a path (either absolute or relative to the base URL).
Original file line number Diff line number Diff line change @@ -499,6 +499,37 @@ class PackageDescription4_2LoadingTests: PackageDescriptionLoadingTests {
499
499
}
500
500
}
501
501
502
+ func testURLContainsNotAbsolutePath( ) throws {
503
+ let stream = BufferedOutputByteStream ( )
504
+ stream <<< """
505
+ import PackageDescription
506
+ let package = Package(
507
+ name: " Trivial " ,
508
+ dependencies: [
509
+ .package(url: " file://../best " , from: " 1.0.0 " ),
510
+ ],
511
+ targets: [
512
+ .target(
513
+ name: " foo " ,
514
+ dependencies: []),
515
+ ]
516
+ )
517
+ """
518
+
519
+ try loadManifestThrowing ( stream. bytes) { manifest in
520
+ if let dep = manifest. dependencies. first {
521
+ switch dep {
522
+ case . scm( let scm) :
523
+ XCTAssertEqual ( scm. location, " /best " )
524
+ default :
525
+ XCTFail ( " dependency was expected to be remote " )
526
+ }
527
+ } else {
528
+ XCTFail ( " manifest had no dependencies " )
529
+ }
530
+ }
531
+ }
532
+
502
533
func testCacheInvalidationOnEnv( ) throws {
503
534
#if os(Linux)
504
535
// rdar://79415639 (Test Case 'PackageDescription4_2LoadingTests.testCacheInvalidationOnEnv' failed)
You can’t perform that action at this time.
0 commit comments