Skip to content

Commit 503e25f

Browse files
authored
Fix deprecation warnings (#301)
1 parent d67baa2 commit 503e25f

File tree

10 files changed

+12
-8
lines changed

10 files changed

+12
-8
lines changed

Sources/TSCBasic/FileSystem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ public class RerootedFileSystemView: FileSystem {
10281028
return root
10291029
} else {
10301030
// FIXME: Optimize?
1031-
return root.appending(RelativePath(String(path.pathString.dropFirst(1))))
1031+
return AbsolutePath(String(path.pathString.dropFirst(1)), relativeTo: root)
10321032
}
10331033
}
10341034

Sources/TSCBasic/Path.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ extension AbsolutePath {
930930
result = RelativePath(relComps.joined(separator: "/"))
931931
#endif
932932
}
933-
assert(base.appending(result) == self)
933+
assert(AbsolutePath(base, result) == self)
934934
return result
935935
}
936936

Sources/TSCBasic/Process.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ public final class Process {
458458
// The program might be a multi-component relative path.
459459
if let rel = try? RelativePath(validating: program), rel.components.count > 1 {
460460
if let cwd = cwdOpt {
461-
let abs = cwd.appending(rel)
461+
let abs = AbsolutePath(cwd, rel)
462462
if localFileSystem.isExecutableFile(abs) {
463463
return abs
464464
}

Sources/TSCBasic/TemporaryFile.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public struct TemporaryFile {
8787
// Determine in which directory to create the temporary file.
8888
self.dir = try determineTempDirectory(dir)
8989
// Construct path to the temporary file.
90-
let path = self.dir.appending(RelativePath(prefix + ".XXXXXX" + suffix))
90+
let path = AbsolutePath(prefix + ".XXXXXX" + suffix, relativeTo: self.dir)
9191

9292
// Convert path to a C style string terminating with null char to be an valid input
9393
// to mkstemps method. The XXXXXX in this string will be replaced by a random string
@@ -236,7 +236,7 @@ public func withTemporaryDirectory<Result>(
236236
dir: AbsolutePath? = nil, prefix: String = "TemporaryDirectory" , _ body: (AbsolutePath, @escaping (AbsolutePath) -> Void) throws -> Result
237237
) throws -> Result {
238238
// Construct path to the temporary directory.
239-
let templatePath = try determineTempDirectory(dir).appending(RelativePath(prefix + ".XXXXXX"))
239+
let templatePath = try AbsolutePath(prefix + ".XXXXXX", relativeTo: determineTempDirectory(dir))
240240

241241
// Convert templatePath to a C style string terminating with null char to be an valid input
242242
// to mkdtemp method. The XXXXXX in this string will be replaced by a random string

Sources/TSCTestSupport/FileSystemExtensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ extension FileSystem {
5252
do {
5353
try createDirectory(root, recursive: true)
5454
for path in files {
55-
let path = root.appending(RelativePath(String(path.dropFirst())))
55+
let path = AbsolutePath(String(path.dropFirst()), relativeTo: root)
5656
try createDirectory(path.parentDirectory, recursive: true)
5757
try writeFileContents(path, bytes: "")
5858
}

Sources/TSCTestSupport/Product.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ extension Product {
3535
public var path: AbsolutePath {
3636
#if canImport(Darwin)
3737
for bundle in Bundle.allBundles where bundle.bundlePath.hasSuffix(".xctest") {
38-
return AbsolutePath(bundle.bundlePath).parentDirectory.appending(self.exec)
38+
return AbsolutePath(AbsolutePath(bundle.bundlePath).parentDirectory, self.exec)
3939
}
4040
fatalError()
4141
#else
@@ -116,7 +116,7 @@ extension Product {
116116
let packagesPath = packageRoot.appending(components: ".build", "checkouts")
117117
for name in try localFileSystem.getDirectoryContents(packagesPath) {
118118
if name.hasPrefix(packageName) {
119-
return packagesPath.appending(RelativePath(name))
119+
return AbsolutePath(name, relativeTo: packagesPath)
120120
}
121121
}
122122
throw SwiftPMProductError.packagePathNotFound

Sources/TSCUtility/dlopen.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public enum DLError: Error {
8888
case close(String)
8989
}
9090

91+
@available(*, deprecated, message: "moved to swift-driver")
9192
extension DLError: CustomNSError {
9293
public var errorUserInfo: [String : Any] {
9394
return [NSLocalizedDescriptionKey: "\(self)"]

Tests/TSCBasicPerformanceTests/PathPerfTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import TSCTestSupport
1616
class PathPerfTests: XCTestCasePerf {
1717

1818
/// Tests creating very long AbsolutePaths by joining path components.
19+
@available(*, deprecated)
1920
func testJoinPerf_X100000() {
2021
#if canImport(Darwin)
2122
let absPath = AbsolutePath("/hello/little")

Tests/TSCBasicTests/PathTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ class PathTests: XCTestCase {
205205
XCTAssertEqual(AbsolutePath("/bar/../foo/..//yabba/a/b").parentDirectory.parentDirectory, AbsolutePath("/yabba"))
206206
}
207207

208+
@available(*, deprecated)
208209
func testConcatenation() {
209210
XCTAssertEqual(AbsolutePath(AbsolutePath("/"), RelativePath("")).pathString, "/")
210211
XCTAssertEqual(AbsolutePath(AbsolutePath("/"), RelativePath(".")).pathString, "/")

Tests/TSCUtilityTests/ArchiverTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ private struct DummyError: Error, Equatable {
107107

108108
private typealias Extraction = (AbsolutePath, AbsolutePath, (Result<Void, Error>) -> Void) -> Void
109109

110+
@available(*, deprecated)
110111
private struct MockArchiver: Archiver {
111112
let supportedExtensions: Set<String>
112113
private let extract: Extraction

0 commit comments

Comments
 (0)