File tree Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -481,16 +481,15 @@ class TestFileHandle : XCTestCase {
481481
482482 func test_readToEndOfFileAndNotify( ) {
483483 let handle = createFileHandle ( )
484- var readSomeData = false
485-
484+ let readSomeData = XCTestExpectation ( description: " At least some data must've been read " )
486485 let done = expectation ( forNotification: FileHandle . readCompletionNotification, object: handle, notificationCenter: . default) { ( notification) -> Bool in
487486 guard let data = notification. userInfo ? [ NSFileHandleNotificationDataItem] as? Data else {
488487 XCTFail ( " Couldn't find the data in the user info: \( notification) " )
489488 return true
490489 }
491490
492491 if !data. isEmpty {
493- readSomeData = true
492+ readSomeData. fulfill ( )
494493 handle. readInBackgroundAndNotify ( )
495494 return false
496495 } else {
@@ -500,8 +499,7 @@ class TestFileHandle : XCTestCase {
500499
501500 handle. readInBackgroundAndNotify ( )
502501
503- wait ( for: [ done] , timeout: 10 )
504- XCTAssertTrue ( readSomeData, " At least some data must've been read " )
502+ wait ( for: [ readSomeData, done] , timeout: 10 )
505503 }
506504
507505 func test_readToEndOfFileAndNotify_readError( ) {
You can’t perform that action at this time.
0 commit comments