Skip to content

Commit 4f228b7

Browse files
authored
Merge pull request #2218 from gmittert/TheLastLeg
Fix TestNSData on Windows
2 parents dea5c12 + 4e56496 commit 4f228b7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

TestFoundation/TestNSData.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4205,11 +4205,14 @@ extension TestNSData {
42054205
let filePath = dirPath.appendingPathComponent("temp_file")
42064206
guard FileManager.default.createFile(atPath: filePath.path, contents: nil, attributes: nil) else { XCTAssertTrue(false, "Unable to create temporary file"); return}
42074207
guard let fh = FileHandle(forWritingAtPath: filePath.path) else { XCTAssertTrue(false, "Unable to open temporary file"); return }
4208-
defer { try! FileManager.default.removeItem(atPath: dirPath.path) }
4209-
4208+
defer {
4209+
fh.closeFile()
4210+
try! FileManager.default.removeItem(atPath: dirPath.path)
4211+
}
4212+
42104213
// Now use this data with some Objective-C code that takes NSData arguments
42114214
fh.write(data)
4212-
4215+
42134216
// Get the data back
42144217
do {
42154218
let url = URL(fileURLWithPath: filePath.path)

0 commit comments

Comments
 (0)