Skip to content

Commit 0ae561f

Browse files
committed
Ensure FileManager.createDirectory does not crash if directory already exists on Linux.
Add a test for [SR-4298](https://bugs.swift.org/browse/SR-4298) to ensure calling FileManager.createDirectory does not crash if the directory already exists.
1 parent b18f3a0 commit 0ae561f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

TestFoundation/TestFileManager.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ class TestFileManager : XCTestCase {
4949
} catch _ {
5050
XCTFail()
5151
}
52-
52+
53+
// Ensure attempting to create the directory again fails gracefully.
54+
XCTAssertNil(try? fm.createDirectory(atPath: path, withIntermediateDirectories:false, attributes:nil))
55+
5356
var isDir = false
5457
let exists = fm.fileExists(atPath: path, isDirectory: &isDir)
5558
XCTAssertTrue(exists)

0 commit comments

Comments
 (0)