Skip to content

Commit d9dad59

Browse files
authored
Fix filesystem test on macOS (#460)
1 parent 990afca commit d9dad59

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
@@ -103,6 +103,8 @@ public extension FileSystemError {
103103
self.init(.noEntry, path)
104104
case TSCLibc.ENOTDIR:
105105
self.init(.notDirectory, path)
106+
case TSCLibc.EEXIST:
107+
self.init(.alreadyExistsAtDestination, path)
106108
default:
107109
self.init(.ioError(code: errno), path)
108110
}

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)