Skip to content

Commit f3a4016

Browse files
committed
fixup
1 parent fc2121e commit f3a4016

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+539
-538
lines changed

Sources/Build/LLBuildManifestBuilder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ extension LLBuildManifestBuilder {
170170

171171
var outputs: [Node] = []
172172

173-
let infoPlistDestination = try! RelativePath(validating: "Info.plist") //try! safe
173+
let infoPlistDestination = RelativePath(static: "Info.plist")
174174

175175
// Create a copy command for each resource file.
176176
for resource in target.resources {

Sources/PackageLoading/TargetSourcesBuilder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ public struct TargetSourcesBuilder {
345345
}
346346

347347
private func diagnoseInfoPlistConflicts(in resources: [Resource]) {
348-
let infoPlist = try! RelativePath(validating: "Info.plist")
348+
let infoPlist = RelativePath(static: "Info.plist")
349349
for resource in resources {
350350
if resource.destination == infoPlist {
351351
self.observabilityScope.emit(.infoPlistResourceConflict(

Sources/SPMTestSupport/InMemoryGitRepository.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ extension InMemoryGitRepository: FileSystem {
247247
}
248248

249249
public var currentWorkingDirectory: AbsolutePath? {
250-
return AbsolutePath(path: "/")
250+
return AbsolutePath(static: "/")
251251
}
252252

253253
public func changeCurrentWorkingDirectory(to path: AbsolutePath) throws {

Sources/SPMTestSupport/SwiftPMProduct.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ public enum SwiftPMProduct: Product {
2626
public var exec: RelativePath {
2727
switch self {
2828
case .SwiftBuild:
29-
return try! RelativePath(validating: "swift-build") //try! safe
29+
return RelativePath(static: "swift-build")
3030
case .SwiftPackage:
31-
return try! RelativePath(validating: "swift-package") //try! safe
31+
return RelativePath(static: "swift-package")
3232
case .SwiftPackageRegistry:
33-
return try! RelativePath(validating: "swift-package-registry") //try! safe
33+
return RelativePath(static: "swift-package-registry")
3434
case .SwiftTest:
35-
return try! RelativePath(validating: "swift-test") //try! safe
35+
return RelativePath(static: "swift-test")
3636
case .SwiftRun:
37-
return try! RelativePath(validating: "swift-run") //try! safe
37+
return RelativePath(static: "swift-run")
3838
case .XCTestHelper:
39-
return try! RelativePath(validating: "swiftpm-xctest-helper") //try! safe
39+
return RelativePath(static: "swiftpm-xctest-helper")
4040
}
4141
}
4242
}

Sources/SPMTestSupport/misc.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public func fixture(
5757

5858
// Construct the expected path of the fixture.
5959
// FIXME: This seems quite hacky; we should provide some control over where fixtures are found.
60-
let fixtureDir = AbsolutePath(path: "../../../Fixtures", relativeTo: AbsolutePath(path: #file)).appending(fixtureSubpath)
60+
let fixtureDir = AbsolutePath(static: "../../../Fixtures", relativeTo: AbsolutePath(path: #file)).appending(fixtureSubpath)
6161

6262
// Check that the fixture is really there.
6363
guard localFileSystem.isDirectory(fixtureDir) else {

Tests/BasicsTests/FileSystemTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ final class FileSystemTests: XCTestCase {
2020
func testStripFirstLevelComponent() throws {
2121
let fileSystem = InMemoryFileSystem()
2222

23-
let rootPath = AbsolutePath(path: "/root")
23+
let rootPath = AbsolutePath(static: "/root")
2424
try fileSystem.createDirectory(rootPath)
2525

2626
let totalDirectories = Int.random(in: 0 ..< 100)

Tests/BasicsTests/VFSTests.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,62 +56,62 @@ class VFSTests: XCTestCase {
5656
let vfs = try VirtualFileSystem(path: vfsPath.path, fs: fs)
5757

5858
// exists()
59-
XCTAssertTrue(vfs.exists(AbsolutePath(path: "/")))
60-
XCTAssertFalse(vfs.exists(AbsolutePath(path: "/does-not-exist")))
59+
XCTAssertTrue(vfs.exists(AbsolutePath(static: "/")))
60+
XCTAssertFalse(vfs.exists(AbsolutePath(static: "/does-not-exist")))
6161

6262
// isFile()
63-
let filePath = AbsolutePath(path: "/best")
63+
let filePath = AbsolutePath(static: "/best")
6464
XCTAssertTrue(vfs.exists(filePath))
6565
XCTAssertTrue(vfs.isFile(filePath))
6666
XCTAssertEqual(try vfs.getFileInfo(filePath).fileType, .typeRegular)
6767
XCTAssertFalse(vfs.isDirectory(filePath))
68-
XCTAssertFalse(vfs.isFile(AbsolutePath(path: "/does-not-exist")))
69-
XCTAssertFalse(vfs.isSymlink(AbsolutePath(path: "/does-not-exist")))
70-
XCTAssertThrowsError(try vfs.getFileInfo(AbsolutePath(path: "/does-not-exist")))
68+
XCTAssertFalse(vfs.isFile(AbsolutePath(static: "/does-not-exist")))
69+
XCTAssertFalse(vfs.isSymlink(AbsolutePath(static: "/does-not-exist")))
70+
XCTAssertThrowsError(try vfs.getFileInfo(AbsolutePath(static: "/does-not-exist")))
7171

7272
// isSymlink()
73-
let symPath = AbsolutePath(path: "/hello")
73+
let symPath = AbsolutePath(static: "/hello")
7474
XCTAssertTrue(vfs.isSymlink(symPath))
7575
XCTAssertTrue(vfs.isFile(symPath))
7676
XCTAssertEqual(try vfs.getFileInfo(symPath).fileType, .typeSymbolicLink)
7777
XCTAssertFalse(vfs.isDirectory(symPath))
7878

7979
// isExecutableFile
80-
let executablePath = AbsolutePath(path: "/exec-foo")
81-
let executableSymPath = AbsolutePath(path: "/exec-sym")
80+
let executablePath = AbsolutePath(static: "/exec-foo")
81+
let executableSymPath = AbsolutePath(static: "/exec-sym")
8282
XCTAssertTrue(vfs.isExecutableFile(executablePath))
8383
XCTAssertTrue(vfs.isExecutableFile(executableSymPath))
8484
XCTAssertTrue(vfs.isSymlink(executableSymPath))
8585
XCTAssertFalse(vfs.isExecutableFile(symPath))
8686
XCTAssertFalse(vfs.isExecutableFile(filePath))
87-
XCTAssertFalse(vfs.isExecutableFile(AbsolutePath(path: "/does-not-exist")))
88-
XCTAssertFalse(vfs.isExecutableFile(AbsolutePath(path: "/")))
87+
XCTAssertFalse(vfs.isExecutableFile(AbsolutePath(static: "/does-not-exist")))
88+
XCTAssertFalse(vfs.isExecutableFile(AbsolutePath(static: "/")))
8989

9090
// readFileContents
9191
let execFileContents = try vfs.readFileContents(executablePath)
9292
XCTAssertEqual(execFileContents, ByteString(contents))
9393

9494
// isDirectory()
95-
XCTAssertTrue(vfs.isDirectory(AbsolutePath(path: "/")))
96-
XCTAssertFalse(vfs.isDirectory(AbsolutePath(path: "/does-not-exist")))
95+
XCTAssertTrue(vfs.isDirectory(AbsolutePath(static: "/")))
96+
XCTAssertFalse(vfs.isDirectory(AbsolutePath(static: "/does-not-exist")))
9797

9898
// getDirectoryContents()
9999
do {
100-
_ = try vfs.getDirectoryContents(AbsolutePath(path: "/does-not-exist"))
100+
_ = try vfs.getDirectoryContents(AbsolutePath(static: "/does-not-exist"))
101101
XCTFail("Unexpected success")
102102
} catch {
103-
XCTAssertEqual(error.localizedDescription, "no such file or directory: \(AbsolutePath(path: "/does-not-exist"))")
103+
XCTAssertEqual(error.localizedDescription, "no such file or directory: \(AbsolutePath(static: "/does-not-exist"))")
104104
}
105105

106-
let thisDirectoryContents = try vfs.getDirectoryContents(AbsolutePath(path: "/"))
106+
let thisDirectoryContents = try vfs.getDirectoryContents(AbsolutePath(static: "/"))
107107
XCTAssertFalse(thisDirectoryContents.contains(where: { $0 == "." }))
108108
XCTAssertFalse(thisDirectoryContents.contains(where: { $0 == ".." }))
109109
XCTAssertEqual(thisDirectoryContents.sorted(), ["best", "dir", "exec-foo", "exec-sym", "hello"])
110110

111-
let contents = try vfs.getDirectoryContents(AbsolutePath(path: "/dir"))
111+
let contents = try vfs.getDirectoryContents(AbsolutePath(static: "/dir"))
112112
XCTAssertEqual(contents, ["file"])
113113

114-
let fileContents = try vfs.readFileContents(AbsolutePath(path: "/dir/file"))
114+
let fileContents = try vfs.readFileContents(AbsolutePath(static: "/dir/file"))
115115
XCTAssertEqual(fileContents, "")
116116
}
117117
}

Tests/BasicsTests/ZipArchiverTests.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ZipArchiverTests: XCTestCase {
1919
func testZipArchiverSuccess() throws {
2020
try testWithTemporaryDirectory { tmpdir in
2121
let archiver = ZipArchiver(fileSystem: localFileSystem)
22-
let inputArchivePath = AbsolutePath(path: #file).parentDirectory.appending(components: "Inputs", "archive.zip")
22+
let inputArchivePath = AbsolutePath(static: #file).parentDirectory.appending(components: "Inputs", "archive.zip")
2323
try archiver.extract(from: inputArchivePath, to: tmpdir)
2424
let content = tmpdir.appending(component: "file")
2525
XCTAssert(localFileSystem.exists(content))
@@ -30,34 +30,34 @@ class ZipArchiverTests: XCTestCase {
3030
func testZipArchiverArchiveDoesntExist() {
3131
let fileSystem = InMemoryFileSystem()
3232
let archiver = ZipArchiver(fileSystem: fileSystem)
33-
let archive = AbsolutePath(path: "/archive.zip")
34-
XCTAssertThrowsError(try archiver.extract(from: archive, to: AbsolutePath(path: "/"))) { error in
33+
let archive = AbsolutePath(static: "/archive.zip")
34+
XCTAssertThrowsError(try archiver.extract(from: archive, to: AbsolutePath(static: "/"))) { error in
3535
XCTAssertEqual(error as? FileSystemError, FileSystemError(.noEntry, archive))
3636
}
3737
}
3838

3939
func testZipArchiverDestinationDoesntExist() throws {
4040
let fileSystem = InMemoryFileSystem(emptyFiles: "/archive.zip")
4141
let archiver = ZipArchiver(fileSystem: fileSystem)
42-
let destination = AbsolutePath(path: "/destination")
43-
XCTAssertThrowsError(try archiver.extract(from: AbsolutePath(path: "/archive.zip"), to: destination)) { error in
42+
let destination = AbsolutePath(static: "/destination")
43+
XCTAssertThrowsError(try archiver.extract(from: AbsolutePath(static: "/archive.zip"), to: destination)) { error in
4444
XCTAssertEqual(error as? FileSystemError, FileSystemError(.notDirectory, destination))
4545
}
4646
}
4747

4848
func testZipArchiverDestinationIsFile() throws {
4949
let fileSystem = InMemoryFileSystem(emptyFiles: "/archive.zip", "/destination")
5050
let archiver = ZipArchiver(fileSystem: fileSystem)
51-
let destination = AbsolutePath(path: "/destination")
52-
XCTAssertThrowsError(try archiver.extract(from: AbsolutePath(path: "/archive.zip"), to: destination)) { error in
51+
let destination = AbsolutePath(static: "/destination")
52+
XCTAssertThrowsError(try archiver.extract(from: AbsolutePath(static: "/archive.zip"), to: destination)) { error in
5353
XCTAssertEqual(error as? FileSystemError, FileSystemError(.notDirectory, destination))
5454
}
5555
}
5656

5757
func testZipArchiverInvalidArchive() throws {
5858
try testWithTemporaryDirectory { tmpdir in
5959
let archiver = ZipArchiver(fileSystem: localFileSystem)
60-
let inputArchivePath = AbsolutePath(path: #file).parentDirectory
60+
let inputArchivePath = AbsolutePath(static: #file).parentDirectory
6161
.appending(components: "Inputs", "invalid_archive.zip")
6262
XCTAssertThrowsError(try archiver.extract(from: inputArchivePath, to: tmpdir)) { error in
6363
#if os(Windows)
@@ -73,14 +73,14 @@ class ZipArchiverTests: XCTestCase {
7373
// valid
7474
try testWithTemporaryDirectory { tmpdir in
7575
let archiver = ZipArchiver(fileSystem: localFileSystem)
76-
let path = AbsolutePath(path: #file).parentDirectory
76+
let path = AbsolutePath(static: #file).parentDirectory
7777
.appending(components: "Inputs", "archive.zip")
7878
XCTAssertTrue(try archiver.validate(path: path))
7979
}
8080
// invalid
8181
try testWithTemporaryDirectory { tmpdir in
8282
let archiver = ZipArchiver(fileSystem: localFileSystem)
83-
let path = AbsolutePath(path: #file).parentDirectory
83+
let path = AbsolutePath(static: #file).parentDirectory
8484
.appending(components: "Inputs", "invalid_archive.zip")
8585
XCTAssertFalse(try archiver.validate(path: path))
8686
}

0 commit comments

Comments
 (0)