Skip to content

Commit a87f61c

Browse files
committed
Resolve warnings about deprecated 'AbsolutePath' initializer
1 parent 0fc8f73 commit a87f61c

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
@@ -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 {
@@ -6930,9 +6930,9 @@ final class SwiftDriverTests: XCTestCase {
69306930

69316931
// 32-bit iOS jobs under Embedded should be allowed regardless of OS version
69326932
do {
6933-
try Driver(args: ["swiftc", "-c", "-target", "armv7-apple-ios8", "-enable-experimental-feature", "Embedded", "foo.swift"])
6934-
try Driver(args: ["swiftc", "-c", "-target", "armv7-apple-ios12.1", "-enable-experimental-feature", "Embedded", "foo.swift"])
6935-
try Driver(args: ["swiftc", "-c", "-target", "armv7-apple-ios16", "-enable-experimental-feature", "Embedded", "foo.swift"])
6933+
let _ = try Driver(args: ["swiftc", "-c", "-target", "armv7-apple-ios8", "-enable-experimental-feature", "Embedded", "foo.swift"])
6934+
let _ = try Driver(args: ["swiftc", "-c", "-target", "armv7-apple-ios12.1", "-enable-experimental-feature", "Embedded", "foo.swift"])
6935+
let _ = try Driver(args: ["swiftc", "-c", "-target", "armv7-apple-ios16", "-enable-experimental-feature", "Embedded", "foo.swift"])
69366936
}
69376937

69386938
do {
@@ -7231,7 +7231,7 @@ final class SwiftDriverTests: XCTestCase {
72317231
}
72327232

72337233
do {
7234-
let workingDirectory = AbsolutePath("/foo/bar")
7234+
let workingDirectory = try AbsolutePath(validating: "/foo/bar")
72357235

72367236
// Inputs with relative paths with -working-directory flag should prefix all inputs
72377237
var driver = try Driver(args: ["swiftc",
@@ -7243,9 +7243,9 @@ final class SwiftDriverTests: XCTestCase {
72437243
let plannedJobs = try driver.planBuild()
72447244
let compileJob = plannedJobs[0]
72457245
XCTAssertEqual(compileJob.kind, .compile)
7246-
try XCTAssertJobInvocationMatches(compileJob, .flag("-primary-file"), .path(.absolute(workingDirectory.appending(component: "foo.swift"))))
7247-
try XCTAssertJobInvocationMatches(compileJob, .flag("-resource-dir"), .path(.absolute(workingDirectory.appending(component: "relresourcepath"))))
7248-
try XCTAssertJobInvocationMatches(compileJob, .flag("-sdk"), .path(.absolute(workingDirectory.appending(component: "relsdkpath"))))
7246+
XCTAssertJobInvocationMatches(compileJob, .flag("-primary-file"), .path(.absolute(workingDirectory.appending(component: "foo.swift"))))
7247+
XCTAssertJobInvocationMatches(compileJob, .flag("-resource-dir"), .path(.absolute(workingDirectory.appending(component: "relresourcepath"))))
7248+
XCTAssertJobInvocationMatches(compileJob, .flag("-sdk"), .path(.absolute(workingDirectory.appending(component: "relsdkpath"))))
72497249
}
72507250

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

72767276
try withTemporaryFile { fileMapFile in
@@ -7280,7 +7280,7 @@ final class SwiftDriverTests: XCTestCase {
72807280
"diagnostics": "/tmp/foo/.build/x86_64-apple-macosx/debug/foo.build/master.dia",
72817281
"emit-module-diagnostics": "/tmp/foo/.build/x86_64-apple-macosx/debug/foo.build/master.emit-module.dia"
72827282
},
7283-
"\(AbsolutePath("/some/workingdir/foo.swift").nativePathString(escaped: true))": {
7283+
"\(try AbsolutePath(validating: "/some/workingdir/foo.swift").nativePathString(escaped: true))": {
72847284
"object": "/tmp/foo/.build/x86_64-apple-macosx/debug/foo.build/foo.o"
72857285
}
72867286
}
@@ -7291,12 +7291,12 @@ final class SwiftDriverTests: XCTestCase {
72917291
var driver = try Driver(args: ["swiftc",
72927292
"-target", "arm64-apple-ios13.1",
72937293
"foo.swift",
7294-
"-working-directory", AbsolutePath("/some/workingdir").nativePathString(escaped: false),
7294+
"-working-directory", try AbsolutePath(validating: "/some/workingdir").nativePathString(escaped: false),
72957295
"-output-file-map", fileMapFile.path.description])
72967296
let plannedJobs = try driver.planBuild()
72977297
let compileJob = plannedJobs[0]
72987298
XCTAssertEqual(compileJob.kind, .compile)
7299-
try XCTAssertJobInvocationMatches(compileJob, .flag("-o"), .path(.absolute(.init("/tmp/foo/.build/x86_64-apple-macosx/debug/foo.build/foo.o"))))
7299+
try XCTAssertJobInvocationMatches(compileJob, .flag("-o"), .path(.absolute(.init(validating: "/tmp/foo/.build/x86_64-apple-macosx/debug/foo.build/foo.o"))))
73007300
}
73017301
}
73027302

@@ -7688,7 +7688,7 @@ final class SwiftDriverTests: XCTestCase {
76887688
var env = ProcessEnv.block
76897689
env["PLATFORM_DIR"] = "/tmp/PlatformDir/\(platform).platform"
76907690

7691-
let workingDirectory = AbsolutePath("/tmp")
7691+
let workingDirectory = try AbsolutePath(validating: "/tmp")
76927692

76937693
var driver = try Driver(
76947694
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
@@ -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)