Skip to content

Commit 53a9026

Browse files
committed
Resolve warnings about deprecated 'AbsolutePath' initializer
1 parent eb06000 commit 53a9026

File tree

7 files changed

+28
-26
lines changed

7 files changed

+28
-26
lines changed

Sources/swift-build-sdk-interfaces/main.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ do {
174174
// modules for which a textual interface is discovered, ensuring that modules
175175
// always build from interface when one is available.
176176
if let supportedFlagsTestDriver = try? Driver(args: ["swiftc", "-v"],
177+
envBlock: ProcessEnv.block,
177178
executor: executor,
178179
compilerExecutableDir: swiftcPath.parentDirectory),
179180
supportedFlagsTestDriver.isFrontendArgSupported(.moduleLoadMode) {
@@ -185,6 +186,7 @@ do {
185186

186187
let baselineABIDir = try getArgumentAsPath("-baseline-abi-dir")
187188
var driver = try Driver(args: args,
189+
envBlock: ProcessEnv.block,
188190
diagnosticsOutput: .engine(diagnosticsEngine),
189191
executor: executor,
190192
compilerExecutableDir: swiftcPath.parentDirectory)

Sources/swift-driver/main.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ do {
144144
fileSystem: localFileSystem,
145145
env: ProcessEnv.block)
146146
var driver = try Driver(args: arguments,
147+
envBlock: ProcessEnv.block,
147148
diagnosticsOutput: .engine(diagnosticsEngine),
148149
executor: executor,
149150
integratedDriver: false)

Tests/SwiftDriverTests/AssertDiagnosticsTests.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,7 @@ class FailableTestCase: XCTestCase {
186186
}
187187

188188
if #available(macOS 10.13, *) {
189-
super.recordFailure(
190-
withDescription: description,
191-
inFile: filePath, atLine: lineNumber,
192-
expected: expected
193-
)
189+
super.record(XCTIssue(type: .assertionFailure, compactDescription: description, sourceCodeContext: XCTSourceCodeContext(location: XCTSourceCodeLocation(filePath: filePath, lineNumber: lineNumber))))
194190
} else {
195191
fatalError(description, line: UInt(lineNumber))
196192
}

Tests/SwiftDriverTests/Inputs/ExplicitModuleDependencyBuildInputs.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ enum ModuleDependenciesInputs {
163163
"-Xcc",
164164
"-fno-implicit-module-maps",
165165
"-candidate-module-file",
166-
"\(AbsolutePath("/dummy/path2/SwiftOnoneSupport.swiftmodule").nativePathString(escaped: true))",
166+
"\(try! AbsolutePath(validating: "/dummy/path2/SwiftOnoneSupport.swiftmodule").nativePathString(escaped: true))",
167167
"-candidate-module-file",
168-
"\(AbsolutePath("/dummy/path1/SwiftOnoneSupport.swiftmodule").nativePathString(escaped: true))",
168+
"\(try! AbsolutePath(validating: "/dummy/path1/SwiftOnoneSupport.swiftmodule").nativePathString(escaped: true))",
169169
"-target",
170170
"x86_64-apple-macosx10.15",
171171
"-sdk",

Tests/SwiftDriverTests/JobExecutorTests.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import TSCBasic
1616
import SwiftDriverExecution
1717
import TestUtilities
1818

19-
extension Job.ArgTemplate: ExpressibleByStringLiteral {
19+
extension Job.ArgTemplate: @retroactive ExpressibleByStringLiteral {
2020
public init(stringLiteral value: String) {
2121
self = .flag(value)
2222
}
@@ -490,6 +490,7 @@ final class JobExecutorTests: XCTestCase {
490490
var driver = try Driver(args: ["swiftc", main.pathString,
491491
"-driver-filelist-threshold", "0",
492492
"-o", outputPath.pathString] + getHostToolchainSdkArg(executor),
493+
envBlock: ProcessEnv.block,
493494
diagnosticsOutput: .engine(diags),
494495
fileSystem: localFileSystem,
495496
executor: executor)
@@ -525,6 +526,7 @@ final class JobExecutorTests: XCTestCase {
525526
"-save-temps",
526527
"-driver-filelist-threshold", "0",
527528
"-o", outputPath.pathString] + getHostToolchainSdkArg(executor),
529+
envBlock: ProcessEnv.block,
528530
diagnosticsOutput: .engine(diags),
529531
fileSystem: localFileSystem,
530532
executor: executor)
@@ -560,6 +562,7 @@ final class JobExecutorTests: XCTestCase {
560562
"-driver-filelist-threshold", "0",
561563
"-Xfrontend", "-debug-crash-immediately",
562564
"-o", outputPath.pathString] + getHostToolchainSdkArg(executor),
565+
envBlock: ProcessEnv.block,
563566
diagnosticsOutput: .engine(diags),
564567
fileSystem: localFileSystem,
565568
executor: executor)

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ final class SwiftDriverTests: XCTestCase {
620620
XCTAssertJobInvocationMatches(jobs[0], .flag("-file-compilation-dir"), .path(VirtualPath.lookup(path)))
621621
}
622622

623-
let workingDirectory = AbsolutePath("/tmp")
623+
let workingDirectory = try AbsolutePath(validating: "/tmp")
624624
try assertNoDriverDiagnostics(args: "swiftc", "foo.swift", "-g", "-c", "-working-directory", workingDirectory.nativePathString(escaped: false)) { driver in
625625
let jobs = try driver.planBuild()
626626
let path = try VirtualPath.intern(path: workingDirectory.nativePathString(escaped: false))
@@ -1752,7 +1752,7 @@ final class SwiftDriverTests: XCTestCase {
17521752
let manyArgs = (1...20000).map { "-DTEST_\($0)" }
17531753
// Needs response file
17541754
do {
1755-
let source = AbsolutePath("/foo.swift")
1755+
let source = try AbsolutePath(validating: "/foo.swift")
17561756
var driver = try Driver(args: ["swift"] + manyArgs + [source.nativePathString(escaped: false)])
17571757
let jobs = try driver.planBuild()
17581758
XCTAssertEqual(jobs.count, 1)
@@ -1784,7 +1784,7 @@ final class SwiftDriverTests: XCTestCase {
17841784

17851785
// Forced response file
17861786
do {
1787-
let source = AbsolutePath("/foo.swift")
1787+
let source = try AbsolutePath(validating: "/foo.swift")
17881788
var driver = try Driver(args: ["swift"] + [source.nativePathString(escaped: false)])
17891789
let jobs = try driver.planBuild()
17901790
XCTAssertEqual(jobs.count, 1)
@@ -3186,7 +3186,7 @@ final class SwiftDriverTests: XCTestCase {
31863186

31873187

31883188
func testIndexFileEntryInSupplementaryFileOutputMap() throws {
3189-
let workingDirectory = AbsolutePath("/tmp")
3189+
let workingDirectory = try AbsolutePath(validating: "/tmp")
31903190
var driver1 = try Driver(args: [
31913191
"swiftc", "foo1.swift", "foo2.swift", "foo3.swift", "foo4.swift", "foo5.swift",
31923192
"-index-file", "-index-file-path", "foo5.swift", "-o", "/tmp/t.o",
@@ -4046,7 +4046,7 @@ final class SwiftDriverTests: XCTestCase {
40464046
XCTAssertEqual(plannedJobs.count, 2)
40474047
XCTAssertEqual(plannedJobs[0].kind, .compile)
40484048
XCTAssertEqual(plannedJobs[1].kind, .link)
4049-
try XCTAssertJobInvocationMatches(plannedJobs[0], .flag("-default-isolation"), "MainActor")
4049+
XCTAssertJobInvocationMatches(plannedJobs[0], .flag("-default-isolation"), "MainActor")
40504050
}
40514051

40524052
func testImmediateMode() throws {
@@ -7021,9 +7021,9 @@ final class SwiftDriverTests: XCTestCase {
70217021

70227022
// 32-bit iOS jobs under Embedded should be allowed regardless of OS version
70237023
do {
7024-
try Driver(args: ["swiftc", "-c", "-target", "armv7-apple-ios8", "-enable-experimental-feature", "Embedded", "foo.swift"])
7025-
try Driver(args: ["swiftc", "-c", "-target", "armv7-apple-ios12.1", "-enable-experimental-feature", "Embedded", "foo.swift"])
7026-
try Driver(args: ["swiftc", "-c", "-target", "armv7-apple-ios16", "-enable-experimental-feature", "Embedded", "foo.swift"])
7024+
let _ = try Driver(args: ["swiftc", "-c", "-target", "armv7-apple-ios8", "-enable-experimental-feature", "Embedded", "foo.swift"])
7025+
let _ = try Driver(args: ["swiftc", "-c", "-target", "armv7-apple-ios12.1", "-enable-experimental-feature", "Embedded", "foo.swift"])
7026+
let _ = try Driver(args: ["swiftc", "-c", "-target", "armv7-apple-ios16", "-enable-experimental-feature", "Embedded", "foo.swift"])
70277027
}
70287028

70297029
do {
@@ -7322,7 +7322,7 @@ final class SwiftDriverTests: XCTestCase {
73227322
}
73237323

73247324
do {
7325-
let workingDirectory = AbsolutePath("/foo/bar")
7325+
let workingDirectory = try AbsolutePath(validating: "/foo/bar")
73267326

73277327
// Inputs with relative paths with -working-directory flag should prefix all inputs
73287328
var driver = try Driver(args: ["swiftc",
@@ -7334,9 +7334,9 @@ final class SwiftDriverTests: XCTestCase {
73347334
let plannedJobs = try driver.planBuild()
73357335
let compileJob = plannedJobs[0]
73367336
XCTAssertEqual(compileJob.kind, .compile)
7337-
try XCTAssertJobInvocationMatches(compileJob, .flag("-primary-file"), .path(.absolute(workingDirectory.appending(component: "foo.swift"))))
7338-
try XCTAssertJobInvocationMatches(compileJob, .flag("-resource-dir"), .path(.absolute(workingDirectory.appending(component: "relresourcepath"))))
7339-
try XCTAssertJobInvocationMatches(compileJob, .flag("-sdk"), .path(.absolute(workingDirectory.appending(component: "relsdkpath"))))
7337+
XCTAssertJobInvocationMatches(compileJob, .flag("-primary-file"), .path(.absolute(workingDirectory.appending(component: "foo.swift"))))
7338+
XCTAssertJobInvocationMatches(compileJob, .flag("-resource-dir"), .path(.absolute(workingDirectory.appending(component: "relresourcepath"))))
7339+
XCTAssertJobInvocationMatches(compileJob, .flag("-sdk"), .path(.absolute(workingDirectory.appending(component: "relsdkpath"))))
73407340
}
73417341

73427342
try withTemporaryFile { fileMapFile in
@@ -7361,7 +7361,7 @@ final class SwiftDriverTests: XCTestCase {
73617361
let plannedJobs = try driver.planBuild()
73627362
let compileJob = plannedJobs[0]
73637363
XCTAssertEqual(compileJob.kind, .compile)
7364-
try XCTAssertJobInvocationMatches(compileJob, .flag("-o"), .path(.absolute(.init("/tmp/foo/.build/x86_64-apple-macosx/debug/foo.build/foo.o"))))
7364+
try XCTAssertJobInvocationMatches(compileJob, .flag("-o"), .path(.absolute(.init(validating: "/tmp/foo/.build/x86_64-apple-macosx/debug/foo.build/foo.o"))))
73657365
}
73667366

73677367
try withTemporaryFile { fileMapFile in
@@ -7371,7 +7371,7 @@ final class SwiftDriverTests: XCTestCase {
73717371
"diagnostics": "/tmp/foo/.build/x86_64-apple-macosx/debug/foo.build/master.dia",
73727372
"emit-module-diagnostics": "/tmp/foo/.build/x86_64-apple-macosx/debug/foo.build/master.emit-module.dia"
73737373
},
7374-
"\(AbsolutePath("/some/workingdir/foo.swift").nativePathString(escaped: true))": {
7374+
"\(try AbsolutePath(validating: "/some/workingdir/foo.swift").nativePathString(escaped: true))": {
73757375
"object": "/tmp/foo/.build/x86_64-apple-macosx/debug/foo.build/foo.o"
73767376
}
73777377
}
@@ -7382,12 +7382,12 @@ final class SwiftDriverTests: XCTestCase {
73827382
var driver = try Driver(args: ["swiftc",
73837383
"-target", "arm64-apple-ios13.1",
73847384
"foo.swift",
7385-
"-working-directory", AbsolutePath("/some/workingdir").nativePathString(escaped: false),
7385+
"-working-directory", try AbsolutePath(validating: "/some/workingdir").nativePathString(escaped: false),
73867386
"-output-file-map", fileMapFile.path.description])
73877387
let plannedJobs = try driver.planBuild()
73887388
let compileJob = plannedJobs[0]
73897389
XCTAssertEqual(compileJob.kind, .compile)
7390-
try XCTAssertJobInvocationMatches(compileJob, .flag("-o"), .path(.absolute(.init("/tmp/foo/.build/x86_64-apple-macosx/debug/foo.build/foo.o"))))
7390+
try XCTAssertJobInvocationMatches(compileJob, .flag("-o"), .path(.absolute(.init(validating: "/tmp/foo/.build/x86_64-apple-macosx/debug/foo.build/foo.o"))))
73917391
}
73927392
}
73937393

@@ -7779,7 +7779,7 @@ final class SwiftDriverTests: XCTestCase {
77797779
var env = ProcessEnv.block
77807780
env["PLATFORM_DIR"] = "/tmp/PlatformDir/\(platform).platform"
77817781

7782-
let workingDirectory = AbsolutePath("/tmp")
7782+
let workingDirectory = try AbsolutePath(validating: "/tmp")
77837783

77847784
var driver = try Driver(
77857785
args: ["swiftc", "-typecheck", "foo.swift", "-sdk", VirtualPath.absolute(sdkRoot).name, "-plugin-path", "PluginA", "-external-plugin-path", "Plugin~B#Bexe", "-load-plugin-library", "PluginB2", "-plugin-path", "PluginC", "-working-directory", workingDirectory.nativePathString(escaped: false)],

Tests/SwiftDriverTests/TripleTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,7 @@ final class TripleTests: XCTestCase {
14521452
}
14531453
}
14541454

1455-
extension Triple.Version: ExpressibleByStringLiteral {
1455+
extension Triple.Version: @retroactive ExpressibleByStringLiteral {
14561456
public init(stringLiteral value: String) {
14571457
self.init(parse: value)
14581458
}

0 commit comments

Comments
 (0)