aboutsummaryrefslogtreecommitdiff
path: root/Foundation
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2009-07-22 17:15:19 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2009-07-22 17:15:19 +0000
commit992bf43928c259fd791f16d8639f000195310017 (patch)
tree1da9664048fe86da3ee7b76741448e81fdc8a91e /Foundation
parenta255d21f63b45fed9e15fbee3708ffadd3b0c443 (diff)
[Author: dmaclach]
Evil bug that ended up with us getting the class instead of an instance passed in to our callback. DELTA=30 (29 added, 0 deleted, 1 changed) R=thomasvl
Diffstat (limited to 'Foundation')
-rw-r--r--Foundation/GTMFileSystemKQueue.m2
-rw-r--r--Foundation/GTMFileSystemKQueueTest.m26
2 files changed, 27 insertions, 1 deletions
diff --git a/Foundation/GTMFileSystemKQueue.m b/Foundation/GTMFileSystemKQueue.m
index ad516f7..1db71c1 100644
--- a/Foundation/GTMFileSystemKQueue.m
+++ b/Foundation/GTMFileSystemKQueue.m
@@ -251,7 +251,7 @@ static void SocketCallBack(CFSocketRef socketref, CFSocketCallBackType type,
= [NSInvocation invocationWithMethodSignature:methodSig];
[invocation setTarget:target_];
[invocation setSelector:action_];
- [invocation setArgument:self atIndex:2];
+ [invocation setArgument:&self atIndex:2];
[invocation setArgument:&eventFFlags atIndex:3];
[invocation invoke];
}
diff --git a/Foundation/GTMFileSystemKQueueTest.m b/Foundation/GTMFileSystemKQueueTest.m
index c2ded10..ec1edc0 100644
--- a/Foundation/GTMFileSystemKQueueTest.m
+++ b/Foundation/GTMFileSystemKQueueTest.m
@@ -32,6 +32,7 @@
@interface GTMFSKQTestHelper : NSObject {
@private
int writes_, renames_, deletes_;
+ __weak GTMFileSystemKQueue *queue_;
}
@end
@@ -39,6 +40,19 @@
- (void)callbackForQueue:(GTMFileSystemKQueue *)queue
events:(GTMFileSystemKQueueEvents)event {
+ // Can't use standard ST macros here because our helper
+ // is not a subclass of GTMTestCase. This is intentional.
+ if (queue != queue_) {
+ NSString *file = [NSString stringWithUTF8String:__FILE__];
+ NSException *exception
+ = [NSException failureInEqualityBetweenObject:queue
+ andObject:queue_
+ inFile:file
+ atLine:__LINE__
+ withDescription:nil];
+ [exception raise];
+ }
+
if (event & kGTMFileSystemKQueueWriteEvent) {
++writes_;
}
@@ -61,6 +75,11 @@
- (int)deletes {
return deletes_;
}
+
+- (void)setKQueue:(GTMFileSystemKQueue *)queue {
+ queue_ = queue;
+}
+
@end
@@ -178,6 +197,7 @@
action:@selector(callbackForQueue:events:)];
STAssertNotNil(testKQ, nil);
STAssertEqualObjects([testKQ path], testPath_, nil);
+ [helper setKQueue:testKQ];
// Write to the file
[testFH writeData:[@"doh!" dataUsingEncoding:NSUnicodeStringEncoding]];
@@ -226,6 +246,8 @@
action:@selector(callbackForQueue:events:)];
STAssertNotNil(testKQ, nil);
STAssertEqualObjects([testKQ path], testPath_, nil);
+ [helper setKQueue:testKQ];
+
GTMFileSystemKQueue *testKQ2
= [[GTMFileSystemKQueue alloc] initWithPath:testPath_
forEvents:kGTMFileSystemKQueueAllEvents
@@ -234,6 +256,7 @@
action:@selector(callbackForQueue:events:)];
STAssertNotNil(testKQ2, nil);
STAssertEqualObjects([testKQ2 path], testPath_, nil);
+ [helper2 setKQueue:testKQ2];
// Write to the file
[testFH writeData:[@"doh!" dataUsingEncoding:NSUnicodeStringEncoding]];
@@ -313,6 +336,8 @@
action:@selector(callbackForQueue:events:)];
STAssertNotNil(testKQ, nil);
STAssertEqualObjects([testKQ path], testPath_, nil);
+ [helper setKQueue:testKQ];
+
GTMFileSystemKQueue *testKQ2
= [[GTMFileSystemKQueue alloc] initWithPath:testPath_
forEvents:kGTMFileSystemKQueueAllEvents
@@ -321,6 +346,7 @@
action:@selector(callbackForQueue:events:)];
STAssertNotNil(testKQ2, nil);
STAssertEqualObjects([testKQ2 path], testPath_, nil);
+ [helper2 setKQueue:testKQ2];
// Write to the file
[testFH writeData:[@"doh!" dataUsingEncoding:NSUnicodeStringEncoding]];