Skip to content

Fix deprecation warnings #301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 23, 2022
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/TSCBasic/FileSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ public class RerootedFileSystemView: FileSystem {
return root
} else {
// FIXME: Optimize?
return root.appending(RelativePath(String(path.pathString.dropFirst(1))))
return AbsolutePath(String(path.pathString.dropFirst(1)), relativeTo: root)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/TSCBasic/Path.swift
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ extension AbsolutePath {
result = RelativePath(relComps.joined(separator: "/"))
#endif
}
assert(base.appending(result) == self)
assert(AbsolutePath(base, result) == self)
return result
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/TSCBasic/Process.swift
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ public final class Process {
// The program might be a multi-component relative path.
if let rel = try? RelativePath(validating: program), rel.components.count > 1 {
if let cwd = cwdOpt {
let abs = cwd.appending(rel)
let abs = AbsolutePath(cwd, rel)
if localFileSystem.isExecutableFile(abs) {
return abs
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/TSCBasic/TemporaryFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public struct TemporaryFile {
// Determine in which directory to create the temporary file.
self.dir = try determineTempDirectory(dir)
// Construct path to the temporary file.
let path = self.dir.appending(RelativePath(prefix + ".XXXXXX" + suffix))
let path = AbsolutePath(prefix + ".XXXXXX" + suffix, relativeTo: self.dir)

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

// Convert templatePath to a C style string terminating with null char to be an valid input
// to mkdtemp method. The XXXXXX in this string will be replaced by a random string
Expand Down
2 changes: 1 addition & 1 deletion Sources/TSCTestSupport/FileSystemExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ extension FileSystem {
do {
try createDirectory(root, recursive: true)
for path in files {
let path = root.appending(RelativePath(String(path.dropFirst())))
let path = AbsolutePath(String(path.dropFirst()), relativeTo: root)
try createDirectory(path.parentDirectory, recursive: true)
try writeFileContents(path, bytes: "")
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/TSCTestSupport/Product.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ extension Product {
public var path: AbsolutePath {
#if canImport(Darwin)
for bundle in Bundle.allBundles where bundle.bundlePath.hasSuffix(".xctest") {
return AbsolutePath(bundle.bundlePath).parentDirectory.appending(self.exec)
return AbsolutePath(AbsolutePath(bundle.bundlePath).parentDirectory, self.exec)
}
fatalError()
#else
Expand Down Expand Up @@ -116,7 +116,7 @@ extension Product {
let packagesPath = packageRoot.appending(components: ".build", "checkouts")
for name in try localFileSystem.getDirectoryContents(packagesPath) {
if name.hasPrefix(packageName) {
return packagesPath.appending(RelativePath(name))
return AbsolutePath(name, relativeTo: packagesPath)
}
}
throw SwiftPMProductError.packagePathNotFound
Expand Down
1 change: 1 addition & 0 deletions Sources/TSCUtility/dlopen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public enum DLError: Error {
case close(String)
}

@available(*, deprecated, message: "moved to swift-driver")
extension DLError: CustomNSError {
public var errorUserInfo: [String : Any] {
return [NSLocalizedDescriptionKey: "\(self)"]
Expand Down
1 change: 1 addition & 0 deletions Tests/TSCBasicPerformanceTests/PathPerfTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import TSCTestSupport
class PathPerfTests: XCTestCasePerf {

/// Tests creating very long AbsolutePaths by joining path components.
@available(*, deprecated)
func testJoinPerf_X100000() {
#if canImport(Darwin)
let absPath = AbsolutePath("/hello/little")
Expand Down
1 change: 1 addition & 0 deletions Tests/TSCBasicTests/PathTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ class PathTests: XCTestCase {
XCTAssertEqual(AbsolutePath("/bar/../foo/..//yabba/a/b").parentDirectory.parentDirectory, AbsolutePath("/yabba"))
}

@available(*, deprecated)
func testConcatenation() {
XCTAssertEqual(AbsolutePath(AbsolutePath("/"), RelativePath("")).pathString, "/")
XCTAssertEqual(AbsolutePath(AbsolutePath("/"), RelativePath(".")).pathString, "/")
Expand Down
1 change: 1 addition & 0 deletions Tests/TSCUtilityTests/ArchiverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ private struct DummyError: Error, Equatable {

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

@available(*, deprecated)
private struct MockArchiver: Archiver {
let supportedExtensions: Set<String>
private let extract: Extraction
Expand Down