Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions Tests/Foundation/Tests/TestFileHandle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -481,16 +481,15 @@ class TestFileHandle : XCTestCase {

func test_readToEndOfFileAndNotify() {
let handle = createFileHandle()
var readSomeData = false

let readSomeData = XCTestExpectation(description: "At least some data must've been read")
let done = expectation(forNotification: FileHandle.readCompletionNotification, object: handle, notificationCenter: .default) { (notification) -> Bool in
guard let data = notification.userInfo?[NSFileHandleNotificationDataItem] as? Data else {
XCTFail("Couldn't find the data in the user info: \(notification)")
return true
}

if !data.isEmpty {
readSomeData = true
readSomeData.fulfill()
handle.readInBackgroundAndNotify()
return false
} else {
Expand All @@ -500,8 +499,7 @@ class TestFileHandle : XCTestCase {

handle.readInBackgroundAndNotify()

wait(for: [done], timeout: 10)
XCTAssertTrue(readSomeData, "At least some data must've been read")
wait(for: [readSomeData, done], timeout: 10)
}

func test_readToEndOfFileAndNotify_readError() {
Expand Down