Skip to content

Commit 046c554

Browse files
authored
Use .mappedIfSafe in DataIOTests.test_largeFile (#720)
DataIOTests.test_largeFile reads a larger than 2GB file twice into the memory. Adding `.mappedIfSafe` option when reading Data to prevent the test getting killed due to memory usage. resolves: rdar://130769047
1 parent 046bb36 commit 046c554

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Tests/FoundationEssentialsTests/DataIOTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,19 +209,19 @@ class DataIOTests : XCTestCase {
209209
let data = generateTestData(count: size)
210210

211211
try data.write(to: url)
212-
let read = try! Data(contentsOf: url)
213-
212+
let read = try! Data(contentsOf: url, options: .mappedIfSafe)
213+
214214
// No need to compare the contents, but do compare the size
215215
XCTAssertEqual(data.count, read.count)
216216

217217
#if FOUNDATION_FRAMEWORK
218218
// Try the NSData path
219-
let readNS = try! NSData(contentsOf: url) as Data
219+
let readNS = try! NSData(contentsOf: url, options: .mappedIfSafe) as Data
220220
XCTAssertEqual(data.count, readNS.count)
221221
#endif
222222

223223
cleanup(at: url)
224-
#endif
224+
#endif // !os(watchOS)
225225
}
226226

227227
func test_writeToSpecialFile() throws {

0 commit comments

Comments
 (0)