Skip to content

Commit 80d8813

Browse files
Fix filesystem test on macOS (#466)
It looks like we end up with `EEXISTS` here on newer versions of macOS. Co-authored-by: Boris Buegling <bbuegling@apple.com>
1 parent 3695ee4 commit 80d8813

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Sources/TSCBasic/FileSystem.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ public extension FileSystemError {
104104
self.init(.noEntry, path)
105105
case TSCLibc.ENOTDIR:
106106
self.init(.notDirectory, path)
107+
case TSCLibc.EEXIST:
108+
self.init(.alreadyExistsAtDestination, path)
107109
default:
108110
self.init(.ioError(code: errno), path)
109111
}

Tests/TSCBasicTests/FileSystemTests.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,13 @@ class FileSystemTests: XCTestCase {
331331
_ = try fs.readFileContents(root)
332332

333333
}
334-
XCTAssertThrows(FileSystemError(.isDirectory, root)) {
334+
#if os(macOS)
335+
// Newer versions of macOS end up with `EEXISTS` instead of `EISDIR` here.
336+
let expectedError = FileSystemError(.alreadyExistsAtDestination, root)
337+
#else
338+
let expectedError = FileSystemError(.isDirectory, root)
339+
#endif
340+
XCTAssertThrows(expectedError) {
335341
try fs.writeFileContents(root, bytes: [])
336342
}
337343
XCTAssert(fs.exists(filePath))

0 commit comments

Comments
 (0)