Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/PackageLoading/ManifestLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import TSCUtility
import Foundation
public typealias FileSystem = TSCBasic.FileSystem

public enum ManifestParseError: Swift.Error {
public enum ManifestParseError: Swift.Error, Equatable {
/// The manifest contains invalid format.
case invalidManifestFormat(String, diagnosticFile: AbsolutePath?)

Expand Down
6 changes: 5 additions & 1 deletion Sources/PackageLoading/PackageDescription4Loader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,11 @@ extension PackageDependencyDescription {
} else if dependencyLocation.hasPrefix(filePrefix) {
// FIXME: SwiftPM can't handle file locations with file:// scheme so we need to
// strip that. We need to design a Location data structure for SwiftPM.
return AbsolutePath(String(dependencyLocation.dropFirst(filePrefix.count)), relativeTo: AbsolutePath(packageLocation)).pathString
let location = String(dependencyLocation.dropFirst(filePrefix.count))
if location.first != "/" {
throw ManifestParseError.invalidManifestFormat("file:// URLs cannot be relative, did you mean to use `.package(path:)`?", diagnosticFile: nil)
}
return AbsolutePath(location).pathString
} else if URL.scheme(dependencyLocation) == nil {
// If the dependency URL is not remote, try to "fix" it.
// If the URL has no scheme, we treat it as a path (either absolute or relative to the base URL).
Expand Down
13 changes: 1 addition & 12 deletions Tests/PackageLoadingTests/PD4_2LoadingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -516,18 +516,7 @@ class PackageDescription4_2LoadingTests: PackageDescriptionLoadingTests {
)
"""

try loadManifestThrowing(stream.bytes) { manifest in
if let dep = manifest.dependencies.first {
switch dep {
case .scm(let scm):
XCTAssertEqual(scm.location, "/best")
default:
XCTFail("dependency was expected to be remote")
}
} else {
XCTFail("manifest had no dependencies")
}
}
XCTAssertManifestLoadThrows(ManifestParseError.invalidManifestFormat("file:// URLs cannot be relative, did you mean to use `.package(path:)`?", diagnosticFile: nil), stream.bytes)
}

func testCacheInvalidationOnEnv() throws {
Expand Down