Skip to content

Commit 0ac23dd

Browse files
committed
Resolve warnings about deprecated 'AbsolutePath' initializer
1 parent 05c4e96 commit 0ac23dd

File tree

8 files changed

+40
-28
lines changed

8 files changed

+40
-28
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
@@ -609,7 +609,7 @@ final class SwiftDriverTests: XCTestCase {
609609
XCTAssertJobInvocationMatches(jobs[0], .flag("-file-compilation-dir"), .path(VirtualPath.lookup(path)))
610610
}
611611

612-
let workingDirectory = AbsolutePath("/tmp")
612+
let workingDirectory = try AbsolutePath(validating: "/tmp")
613613
try assertNoDriverDiagnostics(args: "swiftc", "foo.swift", "-g", "-c", "-working-directory", workingDirectory.nativePathString(escaped: false)) { driver in
614614
let jobs = try driver.planBuild()
615615
let path = try VirtualPath.intern(path: workingDirectory.nativePathString(escaped: false))
@@ -1741,7 +1741,7 @@ final class SwiftDriverTests: XCTestCase {
17411741
let manyArgs = (1...20000).map { "-DTEST_\($0)" }
17421742
// Needs response file
17431743
do {
1744-
let source = AbsolutePath("/foo.swift")
1744+
let source = try AbsolutePath(validating: "/foo.swift")
17451745
var driver = try Driver(args: ["swift"] + manyArgs + [source.nativePathString(escaped: false)])
17461746
let jobs = try driver.planBuild()
17471747
XCTAssertEqual(jobs.count, 1)
@@ -1773,7 +1773,7 @@ final class SwiftDriverTests: XCTestCase {
17731773

17741774
// Forced response file
17751775
do {
1776-
let source = AbsolutePath("/foo.swift")
1776+
let source = try AbsolutePath(validating: "/foo.swift")
17771777
var driver = try Driver(args: ["swift"] + [source.nativePathString(escaped: false)])
17781778
let jobs = try driver.planBuild()
17791779
XCTAssertEqual(jobs.count, 1)
@@ -3095,7 +3095,7 @@ final class SwiftDriverTests: XCTestCase {
30953095

30963096

30973097
func testIndexFileEntryInSupplementaryFileOutputMap() throws {
3098-
let workingDirectory = AbsolutePath("/tmp")
3098+
let workingDirectory = try AbsolutePath(validating: "/tmp")
30993099
var driver1 = try Driver(args: [
31003100
"swiftc", "foo1.swift", "foo2.swift", "foo3.swift", "foo4.swift", "foo5.swift",
31013101
"-index-file", "-index-file-path", "foo5.swift", "-o", "/tmp/t.o",
@@ -3955,7 +3955,7 @@ final class SwiftDriverTests: XCTestCase {
39553955
XCTAssertEqual(plannedJobs.count, 2)
39563956
XCTAssertEqual(plannedJobs[0].kind, .compile)
39573957
XCTAssertEqual(plannedJobs[1].kind, .link)
3958-
try XCTAssertJobInvocationMatches(plannedJobs[0], .flag("-default-isolation"), "MainActor")
3958+
XCTAssertJobInvocationMatches(plannedJobs[0], .flag("-default-isolation"), "MainActor")
39593959
}
39603960

39613961
func testImmediateMode() throws {
@@ -6927,9 +6927,9 @@ final class SwiftDriverTests: XCTestCase {
69276927

69286928
// 32-bit iOS jobs under Embedded should be allowed regardless of OS version
69296929
do {
6930-
try Driver(args: ["swiftc", "-c", "-target", "armv7-apple-ios8", "-enable-experimental-feature", "Embedded", "foo.swift"])
6931-
try Driver(args: ["swiftc", "-c", "-target", "armv7-apple-ios12.1", "-enable-experimental-feature", "Embedded", "foo.swift"])
6932-
try Driver(args: ["swiftc", "-c", "-target", "armv7-apple-ios16", "-enable-experimental-feature", "Embedded", "foo.swift"])
6930+
let _ = try Driver(args: ["swiftc", "-c", "-target", "armv7-apple-ios8", "-enable-experimental-feature", "Embedded", "foo.swift"])
6931+
let _ = try Driver(args: ["swiftc", "-c", "-target", "armv7-apple-ios12.1", "-enable-experimental-feature", "Embedded", "foo.swift"])
6932+
let _ = try Driver(args: ["swiftc", "-c", "-target", "armv7-apple-ios16", "-enable-experimental-feature", "Embedded", "foo.swift"])
69336933
}
69346934

69356935
do {
@@ -7228,7 +7228,7 @@ final class SwiftDriverTests: XCTestCase {
72287228
}
72297229

72307230
do {
7231-
let workingDirectory = AbsolutePath("/foo/bar")
7231+
let workingDirectory = try AbsolutePath(validating: "/foo/bar")
72327232

72337233
// Inputs with relative paths with -working-directory flag should prefix all inputs
72347234
var driver = try Driver(args: ["swiftc",
@@ -7240,9 +7240,9 @@ final class SwiftDriverTests: XCTestCase {
72407240
let plannedJobs = try driver.planBuild()
72417241
let compileJob = plannedJobs[0]
72427242
XCTAssertEqual(compileJob.kind, .compile)
7243-
try XCTAssertJobInvocationMatches(compileJob, .flag("-primary-file"), .path(.absolute(workingDirectory.appending(component: "foo.swift"))))
7244-
try XCTAssertJobInvocationMatches(compileJob, .flag("-resource-dir"), .path(.absolute(workingDirectory.appending(component: "relresourcepath"))))
7245-
try XCTAssertJobInvocationMatches(compileJob, .flag("-sdk"), .path(.absolute(workingDirectory.appending(component: "relsdkpath"))))
7243+
XCTAssertJobInvocationMatches(compileJob, .flag("-primary-file"), .path(.absolute(workingDirectory.appending(component: "foo.swift"))))
7244+
XCTAssertJobInvocationMatches(compileJob, .flag("-resource-dir"), .path(.absolute(workingDirectory.appending(component: "relresourcepath"))))
7245+
XCTAssertJobInvocationMatches(compileJob, .flag("-sdk"), .path(.absolute(workingDirectory.appending(component: "relsdkpath"))))
72467246
}
72477247

72487248
try withTemporaryFile { fileMapFile in
@@ -7267,7 +7267,7 @@ final class SwiftDriverTests: XCTestCase {
72677267
let plannedJobs = try driver.planBuild()
72687268
let compileJob = plannedJobs[0]
72697269
XCTAssertEqual(compileJob.kind, .compile)
7270-
try XCTAssertJobInvocationMatches(compileJob, .flag("-o"), .path(.absolute(.init("/tmp/foo/.build/x86_64-apple-macosx/debug/foo.build/foo.o"))))
7270+
try XCTAssertJobInvocationMatches(compileJob, .flag("-o"), .path(.absolute(.init(validating: "/tmp/foo/.build/x86_64-apple-macosx/debug/foo.build/foo.o"))))
72717271
}
72727272

72737273
try withTemporaryFile { fileMapFile in
@@ -7277,7 +7277,7 @@ final class SwiftDriverTests: XCTestCase {
72777277
"diagnostics": "/tmp/foo/.build/x86_64-apple-macosx/debug/foo.build/master.dia",
72787278
"emit-module-diagnostics": "/tmp/foo/.build/x86_64-apple-macosx/debug/foo.build/master.emit-module.dia"
72797279
},
7280-
"\(AbsolutePath("/some/workingdir/foo.swift").nativePathString(escaped: true))": {
7280+
"\(try AbsolutePath(validating: "/some/workingdir/foo.swift").nativePathString(escaped: true))": {
72817281
"object": "/tmp/foo/.build/x86_64-apple-macosx/debug/foo.build/foo.o"
72827282
}
72837283
}
@@ -7288,12 +7288,12 @@ final class SwiftDriverTests: XCTestCase {
72887288
var driver = try Driver(args: ["swiftc",
72897289
"-target", "arm64-apple-ios13.1",
72907290
"foo.swift",
7291-
"-working-directory", AbsolutePath("/some/workingdir").nativePathString(escaped: false),
7291+
"-working-directory", try AbsolutePath(validating: "/some/workingdir").nativePathString(escaped: false),
72927292
"-output-file-map", fileMapFile.path.description])
72937293
let plannedJobs = try driver.planBuild()
72947294
let compileJob = plannedJobs[0]
72957295
XCTAssertEqual(compileJob.kind, .compile)
7296-
try XCTAssertJobInvocationMatches(compileJob, .flag("-o"), .path(.absolute(.init("/tmp/foo/.build/x86_64-apple-macosx/debug/foo.build/foo.o"))))
7296+
try XCTAssertJobInvocationMatches(compileJob, .flag("-o"), .path(.absolute(.init(validating: "/tmp/foo/.build/x86_64-apple-macosx/debug/foo.build/foo.o"))))
72977297
}
72987298
}
72997299

@@ -7685,7 +7685,7 @@ final class SwiftDriverTests: XCTestCase {
76857685
var env = ProcessEnv.block
76867686
env["PLATFORM_DIR"] = "/tmp/PlatformDir/\(platform).platform"
76877687

7688-
let workingDirectory = AbsolutePath("/tmp")
7688+
let workingDirectory = try AbsolutePath(validating: "/tmp")
76897689

76907690
var driver = try Driver(
76917691
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/SwiftDriverToolingInterfaceTests.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,12 @@ final class SwiftDriverToolingInterfaceTests: XCTestCase {
9898
let inputFile = path.appending(components: "test.swift")
9999
try localFileSystem.writeFileContents(inputFile) { $0.send("public func foo()") }
100100

101-
let env = ProcessEnv.vars
101+
let envBlock = ProcessEnv.block
102+
let env = envBlock.reduce([:]) { (partialResult: [String: String], tuple: (key: ProcessEnvironmentKey, value: String)) in
103+
var result = partialResult
104+
result[tuple.key.value] = tuple.value
105+
return result
106+
}
102107
let resolver = try ArgsResolver(fileSystem: localFileSystem)
103108
let executor = SimpleExecutor(resolver: resolver, fileSystem: localFileSystem, env: ProcessEnv.block)
104109

@@ -191,7 +196,12 @@ final class SwiftDriverToolingInterfaceTests: XCTestCase {
191196
let inputFile = path.appending(components: "test.swift")
192197
try localFileSystem.writeFileContents(inputFile) { $0.send("public func foo()") }
193198

194-
let env = ProcessEnv.vars
199+
let envBlock = ProcessEnv.block
200+
let env = envBlock.reduce([:]) { (partialResult: [String: String], tuple: (key: ProcessEnvironmentKey, value: String)) in
201+
var result = partialResult
202+
result[tuple.key.value] = tuple.value
203+
return result
204+
}
195205
let resolver = try ArgsResolver(fileSystem: localFileSystem)
196206
let executor = SimpleExecutor(resolver: resolver, fileSystem: localFileSystem, env: ProcessEnv.block)
197207

Tests/SwiftDriverTests/TripleTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1443,7 +1443,7 @@ final class TripleTests: XCTestCase {
14431443
}
14441444
}
14451445

1446-
extension Triple.Version: ExpressibleByStringLiteral {
1446+
extension Triple.Version: @retroactive ExpressibleByStringLiteral {
14471447
public init(stringLiteral value: String) {
14481448
self.init(parse: value)
14491449
}

0 commit comments

Comments
 (0)