File tree Expand file tree Collapse file tree 2 files changed +40
-2
lines changed Expand file tree Collapse file tree 2 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -1777,8 +1777,7 @@ extension Workspace {
1777
1777
for target in manifest. targets where target. type == . binary {
1778
1778
if let path = target. path {
1779
1779
// TODO: find a better way to get the base path (not via the manifest)
1780
- // the target path is validated earlier to be within the package directory
1781
- let absolutePath = manifest. path. parentDirectory. appending ( RelativePath ( path) )
1780
+ let absolutePath = try manifest. path. parentDirectory. appending ( RelativePath ( validating: path) )
1782
1781
localArtifacts. append (
1783
1782
. local(
1784
1783
packageRef: packageReference,
Original file line number Diff line number Diff line change @@ -7020,6 +7020,45 @@ final class WorkspaceTests: XCTestCase {
7020
7020
}
7021
7021
}
7022
7022
}
7023
+
7024
+ func testBinaryArtifactsInvalidPath( ) throws {
7025
+ let fs = localFileSystem
7026
+ try testWithTemporaryDirectory { path in
7027
+ let foo = path. appending ( component: " foo " )
7028
+
7029
+ try fs. writeFileContents ( foo. appending ( component: " Package.swift " ) ) {
7030
+ $0 <<<
7031
+ """
7032
+ // swift-tools-version:5.3
7033
+ import PackageDescription
7034
+ let package = Package(
7035
+ name: " Best " ,
7036
+ targets: [
7037
+ .binaryTarget(name: " best " , path: " /best.xcframework " )
7038
+ ]
7039
+ )
7040
+ """
7041
+ }
7042
+
7043
+ let manifestLoader = ManifestLoader ( toolchain: ToolchainConfiguration . default)
7044
+ let sandbox = path. appending ( component: " ws " )
7045
+ let workspace = try Workspace (
7046
+ fileSystem: fs,
7047
+ location: . init( forRootPackage: sandbox, fileSystem: fs) ,
7048
+ customManifestLoader: manifestLoader,
7049
+ delegate: MockWorkspaceDelegate ( )
7050
+ )
7051
+
7052
+ do {
7053
+ let diagnostics = DiagnosticsEngine ( )
7054
+ try workspace. resolve ( root: . init( packages: [ foo] ) , diagnostics: diagnostics)
7055
+ } catch {
7056
+ XCTAssertEqual ( error. localizedDescription, " invalid relative path '/best.xcframework'; relative path should not begin with '/' or '~' " )
7057
+ return
7058
+ }
7059
+ XCTFail ( " unexpected success " )
7060
+ }
7061
+ }
7023
7062
}
7024
7063
7025
7064
struct DummyError : LocalizedError , Equatable {
You can’t perform that action at this time.
0 commit comments