Skip to content

Remove remaining appearences of deprecated 'AbsolutePath' initializer in tests #1231

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
Sep 22, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ extension IncrementalCompilationState.FirstWaveComputer {
let invalidateOutOfDate = { (modulesRequiringRebuild: inout Set<ModuleDependencyId>) in
reporter?.reportExplicitDependencyWillBeReBuilt(moduleId.moduleNameForDiagnostic, reason: "Out-of-date")
modulesRequiringRebuild.insert(moduleId)
try invalidatePath(&modulesRequiringRebuild)
invalidatePath(&modulesRequiringRebuild)
}

// Visit the module's dependencies
Expand All @@ -202,10 +202,10 @@ extension IncrementalCompilationState.FirstWaveComputer {
}

if modulesRequiringRebuild.contains(moduleId) {
try invalidatePath(&modulesRequiringRebuild)
invalidatePath(&modulesRequiringRebuild)
} else if try !IncrementalCompilationState.IncrementalDependencyAndInputSetup.verifyModuleDependencyUpToDate(moduleID: moduleId, moduleInfo: moduleInfo,
fileSystem: fileSystem, reporter: reporter) {
try invalidateOutOfDate(&modulesRequiringRebuild)
invalidateOutOfDate(&modulesRequiringRebuild)
} else {
// Only if this module is known to be up-to-date with respect to its inputs
// and dependencies do we mark it as visited. We may need to re-visit
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ extension Driver {
if let value = parsedOptions.getLastArgument(rootArg)?.asSingle,
isFrontendArgSupported(rootArg) {
commandLine.appendFlag(rootArg.spelling)
commandLine.appendPath(.init(value))
commandLine.appendPath(try .init(validating: value))
}

if let value = parsedOptions.getLastArgument(versionArg)?.asSingle,
Expand Down
11 changes: 6 additions & 5 deletions Sources/swift-build-sdk-interfaces/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ do {
// append the SDK version number so all modules will built into
// the SDK-versioned sub-directory.
if outputDir.basename == "prebuilt-modules" {
outputDir = try AbsolutePath(validating: collector.versionString, relativeTo: outputDir)
outputDir = try AbsolutePath(validating: collector.versionString,
relativeTo: outputDir)
}
if !localFileSystem.exists(outputDir) {
try localFileSystem.createDirectory(outputDir, recursive: true)
Expand All @@ -100,10 +101,10 @@ do {
} else {
swiftcPath = try AbsolutePath(validating: "Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc",
relativeTo: sdkPath.parentDirectory
.parentDirectory
.parentDirectory
.parentDirectory
.parentDirectory)
.parentDirectory
.parentDirectory
.parentDirectory
.parentDirectory)
}
if !localFileSystem.exists(swiftcPath) {
diagnosticsEngine.emit(error: "cannot find swift compiler: \(swiftcPath.pathString)")
Expand Down
20 changes: 10 additions & 10 deletions Tests/SwiftDriverTests/APIDigesterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class APIDigesterTests: XCTestCase {
"-output-file-map", ofmPath.pathString,
])
let digesterJob = try XCTUnwrap(driver.planBuild().first { $0.kind == .generateABIBaseline })
XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-o", .path(.absolute(.init("/path/to/baseline.abi.json")))]))
try XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-o", .path(.absolute(.init(validating: "/path/to/baseline.abi.json")))]))
}
}
do {
Expand All @@ -136,7 +136,7 @@ class APIDigesterTests: XCTestCase {
"-output-file-map", ofmPath.pathString,
])
let digesterJob = try XCTUnwrap(driver.planBuild().first { $0.kind == .generateABIBaseline })
XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-o", .path(.absolute(.init("/path/to/sourceinfo.abi.json")))]))
try XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-o", .path(.absolute(.init(validating: "/path/to/sourceinfo.abi.json")))]))
}
}
}
Expand All @@ -149,8 +149,8 @@ class APIDigesterTests: XCTestCase {
XCTAssertTrue(digesterJob.commandLine.contains("-dump-sdk"))
XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-module", "foo"]))
XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-I", .path(.relative(.init(".")))]))
XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-sdk", .path(.absolute(.init("/path/to/sdk")))]))
XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-I", .path(.absolute(.init("/some/path")))]))
try XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-sdk", .path(.absolute(.init(validating: "/path/to/sdk")))]))
try XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-I", .path(.absolute(.init(validating: "/some/path")))]))
XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-F", .path(.relative(.init("framework/path")))]))
XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-o", .path(.relative(.init("foo.api.json")))]))

Expand All @@ -165,8 +165,8 @@ class APIDigesterTests: XCTestCase {
XCTAssertTrue(digesterJob.commandLine.contains("-dump-sdk"))
XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-module", "foo"]))
XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-I", .path(.relative(.init(".")))]))
XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-sdk", .path(.absolute(.init("/path/to/sdk")))]))
XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-I", .path(.absolute(.init("/some/path")))]))
try XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-sdk", .path(.absolute(.init(validating: "/path/to/sdk")))]))
try XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-I", .path(.absolute(.init(validating: "/some/path")))]))
XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-F", .path(.relative(.init("framework/path")))]))
XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-o", .path(.relative(.init("foo.abi.json")))]))

Expand Down Expand Up @@ -238,10 +238,10 @@ class APIDigesterTests: XCTestCase {
let digesterJob = try XCTUnwrap(driver.planBuild().first { $0.kind == .compareAPIBaseline })
XCTAssertTrue(digesterJob.commandLine.contains("-diagnose-sdk"))
XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-module", "foo"]))
XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-baseline-path", .path(.absolute(.init("/baseline/path")))]))
try XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-baseline-path", .path(.absolute(.init(validating: "/baseline/path")))]))
XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-I", .path(.relative(.init(".")))]))
XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-sdk", .path(.absolute(.init("/path/to/sdk")))]))
XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-I", .path(.absolute(.init("/some/path")))]))
try XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-sdk", .path(.absolute(.init(validating: "/path/to/sdk")))]))
try XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-I", .path(.absolute(.init(validating: "/some/path")))]))
XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-F", .path(.relative(.init("framework/path")))]))
XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-breakage-allowlist-path",
.path(.relative(.init("allowlist/path")))]))
Expand All @@ -257,7 +257,7 @@ class APIDigesterTests: XCTestCase {
"-digester-breakage-allowlist-path", "allowlist/path"])
let digesterJob = try XCTUnwrap(driver.planBuild().first { $0.kind == .compareABIBaseline })
XCTAssertTrue(digesterJob.commandLine.contains("-diagnose-sdk"))
XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-input-paths", .path(.absolute(.init("/baseline/path")))]))
try XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-input-paths", .path(.absolute(.init(validating: "/baseline/path")))]))
XCTAssertTrue(digesterJob.commandLine.contains(subsequence: ["-breakage-allowlist-path",
.path(.relative(.init("allowlist/path")))]))
XCTAssertTrue(digesterJob.commandLine.contains("-abi"))
Expand Down
48 changes: 25 additions & 23 deletions Tests/SwiftDriverTests/CachingBuildTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ import TSCBasic
import XCTest
import TestUtilities

private var testInputsPath: AbsolutePath = {
var root: AbsolutePath = AbsolutePath(#file)
while root.basename != "Tests" {
root = root.parentDirectory
private var testInputsPath: AbsolutePath {
get throws {
var root: AbsolutePath = try AbsolutePath(validating: #file)
while root.basename != "Tests" {
root = root.parentDirectory
}
return root.parentDirectory.appending(component: "TestInputs")
}
return root.parentDirectory.appending(component: "TestInputs")
}()
}

private func checkCachingBuildJob(job: Job,
moduleId: ModuleDependencyId,
Expand Down Expand Up @@ -151,14 +153,14 @@ final class CachingBuildTests: XCTestCase {
$0 <<< "import G;"
}
let casPath = path.appending(component: "cas")
let swiftModuleInterfacesPath: AbsolutePath =
try testInputsPath.appending(component: "ExplicitModuleBuilds")
.appending(component: "Swift")
let cHeadersPath: AbsolutePath =
testInputsPath.appending(component: "ExplicitModuleBuilds")
.appending(component: "CHeaders")
try testInputsPath.appending(component: "ExplicitModuleBuilds")
.appending(component: "CHeaders")
let bridgingHeaderpath: AbsolutePath =
cHeadersPath.appending(component: "Bridging.h")
let swiftModuleInterfacesPath: AbsolutePath =
testInputsPath.appending(component: "ExplicitModuleBuilds")
.appending(component: "Swift")
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
var driver = try Driver(args: ["swiftc",
"-target", "x86_64-apple-macosx11.0",
Expand Down Expand Up @@ -282,11 +284,11 @@ final class CachingBuildTests: XCTestCase {
}

let swiftModuleInterfacesPath: AbsolutePath =
testInputsPath.appending(component: "ExplicitModuleBuilds")
.appending(component: "Swift")
try testInputsPath.appending(component: "ExplicitModuleBuilds")
.appending(component: "Swift")
let cHeadersPath: AbsolutePath =
testInputsPath.appending(component: "ExplicitModuleBuilds")
.appending(component: "CHeaders")
try testInputsPath.appending(component: "ExplicitModuleBuilds")
.appending(component: "CHeaders")
let casPath = path.appending(component: "cas")
let swiftInterfacePath: AbsolutePath = path.appending(component: "testExplicitModuleVerifyInterfaceJobs.swiftinterface")
let privateSwiftInterfacePath: AbsolutePath = path.appending(component: "testExplicitModuleVerifyInterfaceJobs.private.swiftinterface")
Expand Down Expand Up @@ -431,11 +433,11 @@ final class CachingBuildTests: XCTestCase {
}

let cHeadersPath: AbsolutePath =
testInputsPath.appending(component: "ExplicitModuleBuilds")
.appending(component: "CHeaders")
try testInputsPath.appending(component: "ExplicitModuleBuilds")
.appending(component: "CHeaders")
let swiftModuleInterfacesPath: AbsolutePath =
testInputsPath.appending(component: "ExplicitModuleBuilds")
.appending(component: "Swift")
try testInputsPath.appending(component: "ExplicitModuleBuilds")
.appending(component: "Swift")
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
var driver = try Driver(args: ["swiftc",
"-I", cHeadersPath.nativePathString(escaped: true),
Expand Down Expand Up @@ -550,11 +552,11 @@ final class CachingBuildTests: XCTestCase {
}

let cHeadersPath: AbsolutePath =
testInputsPath.appending(component: "ExplicitModuleBuilds")
.appending(component: "CHeaders")
try testInputsPath.appending(component: "ExplicitModuleBuilds")
.appending(component: "CHeaders")
let swiftModuleInterfacesPath: AbsolutePath =
testInputsPath.appending(component: "ExplicitModuleBuilds")
.appending(component: "Swift")
try testInputsPath.appending(component: "ExplicitModuleBuilds")
.appending(component: "Swift")
let casPath = path.appending(component: "cas")
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
var driver = try Driver(args: ["swiftc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class DependencyGraphSerializationTests: XCTestCase, ModuleDependencyGraphMocker
///
/// Ensure that a round-trip fails when the minor version number changes
func testSerializedVersionChangeDetection() throws {
let mockPath = try VirtualPath.absolute(AbsolutePath(validating: "/module-dependency-graph"))
let mockPath = VirtualPath.absolute(try AbsolutePath(validating: "/module-dependency-graph"))
let fs = InMemoryFileSystem()
let graph = Self.mockGraphCreator.mockUpAGraph()
let currentVersion = ModuleDependencyGraph.serializedGraphVersion
Expand Down Expand Up @@ -55,7 +55,7 @@ class DependencyGraphSerializationTests: XCTestCase, ModuleDependencyGraphMocker
}

func roundTrip(_ originalGraph: ModuleDependencyGraph) throws {
let mockPath = try VirtualPath.absolute(AbsolutePath(validating: "/module-dependency-graph"))
let mockPath = VirtualPath.absolute(try AbsolutePath(validating: "/module-dependency-graph"))
let fs = InMemoryFileSystem()
let outputFileMap = OutputFileMap.mock(maxIndex: Self.maxIndex)

Expand Down
Loading