Skip to content

Commit

Permalink
Fix filesystem test on macOS (#466)
Browse files Browse the repository at this point in the history
It looks like we end up with `EEXISTS` here on newer versions of macOS.

Co-authored-by: Boris Buegling <[email protected]>
  • Loading branch information
MaxDesiatov and neonichu authored May 4, 2024
1 parent 3695ee4 commit 80d8813
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Sources/TSCBasic/FileSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public extension FileSystemError {
self.init(.noEntry, path)
case TSCLibc.ENOTDIR:
self.init(.notDirectory, path)
case TSCLibc.EEXIST:
self.init(.alreadyExistsAtDestination, path)
default:
self.init(.ioError(code: errno), path)
}
Expand Down
8 changes: 7 additions & 1 deletion Tests/TSCBasicTests/FileSystemTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,13 @@ class FileSystemTests: XCTestCase {
_ = try fs.readFileContents(root)

}
XCTAssertThrows(FileSystemError(.isDirectory, root)) {
#if os(macOS)
// Newer versions of macOS end up with `EEXISTS` instead of `EISDIR` here.
let expectedError = FileSystemError(.alreadyExistsAtDestination, root)
#else
let expectedError = FileSystemError(.isDirectory, root)
#endif
XCTAssertThrows(expectedError) {
try fs.writeFileContents(root, bytes: [])
}
XCTAssert(fs.exists(filePath))
Expand Down

0 comments on commit 80d8813

Please sign in to comment.