aboutsummaryrefslogtreecommitdiff
path: root/Foundation
diff options
context:
space:
mode:
authorGravatar dmaclach <dmaclach@gmail.com>2018-11-19 08:31:50 -0800
committerGravatar GitHub <noreply@github.com>2018-11-19 08:31:50 -0800
commit9dbe45334a8f4c76553d2b8585915e8a3cfe94f6 (patch)
treebdbbc7870c42c67255b0fb46b6bef48dacd292ed /Foundation
parent17aaac660353e33625d2c9aa7cd29b0d14949795 (diff)
Fix up GTMNSThread+block test. (#214)
Made an assumption about how runloops worked in all versions of iOS. Appears it was wrong in 32 bit versions on single processor. Runloop executes all input from an input source in a single burst which caused a test to fail. (iOS 8.4 on iPhone4s simulator)
Diffstat (limited to 'Foundation')
-rw-r--r--Foundation/GTMNSThread+BlocksTest.m9
1 files changed, 4 insertions, 5 deletions
diff --git a/Foundation/GTMNSThread+BlocksTest.m b/Foundation/GTMNSThread+BlocksTest.m
index e051de9..1b13ebf 100644
--- a/Foundation/GTMNSThread+BlocksTest.m
+++ b/Foundation/GTMNSThread+BlocksTest.m
@@ -223,12 +223,12 @@ static const int kThreadMethoduSleep = 10000;
}
- (void)testCancelFromOtherThread {
- // Show that cancel actually cancels before all blocks are executed.
- __block int counter = 0;
+ // Cancel will kill the thread at same point.
+ // It may or may not complete all the blocks.
+ // There is no guarantee made (unlike stop).
for (int i = 0; i < kThreadMethodCounter; i++) {
[workerThread_ gtm_performWaitingUntilDone:NO block:^{
- sleep(1);
- ++counter;
+ usleep(kThreadMethoduSleep);
}];
}
[workerThread_ cancel];
@@ -242,7 +242,6 @@ static const int kThreadMethoduSleep = 10000;
handler:NULL];
[self waitForExpectationsWithTimeout:kTestTimeout handler:NULL];
XCTAssertTrue([workerThread_ isFinished]);
- XCTAssertNotEqual(counter, kThreadMethodCounter);
}
- (void)testStopFromThread {