Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swizzle XCTestObservationCenter observer registration methods #278

Merged
merged 1 commit into from
Apr 7, 2016

Conversation

phatblat
Copy link
Member

@phatblat phatblat commented Apr 6, 2016

As discussed in #273, this approach uses swizzling of the private _addLegacyTestObserver: method to register CurrentTestCaseTracker, ensuring that XCTestLog has been registered first. The approach in #271 appeared to work for the typical use case, but Quick's test suite still had failing tests due to something not working right with these observers. This approach seems to work for all these cases.

Addresses Quick/Quick#494. Redo of #271. May address #276. Hope to unblock Quick/Quick#507.

@phatblat
Copy link
Member Author

phatblat commented Apr 7, 2016

Could one of the brilliant @Quick/contributors kindly look this over? Quick's Xcode 7.3 support is waiting on this fix.

///
/// @param originalSelector Original method to replace.
/// @param replacementSelector Replacement method.
+ (void)swizzleSelector:(SEL)originalSelector withSelector:(SEL)replacementSelector {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add the NMB_ prefix on here too? Or alternatively, turn it into a free function.

@briancroom
Copy link
Member

Hey @phatblat, thanks for moving forward with this! I'm left some comments on the implementation but I'm fine with the fundamental approach, as the least-evil solution we have available to us at this point in time.

I'd love to hear input from @jeffh though, with his extensive experience monkey-patching ObjC.

@ashfurrow
Copy link
Member

Looks good to merge! (modulo comments)

@phatblat
Copy link
Member Author

phatblat commented Apr 7, 2016

Thanks for the feedback, @briancroom! I'll fix these up shortly.

@phatblat
Copy link
Member Author

phatblat commented Apr 7, 2016

This is ready for re-review.

@ashfurrow
Copy link
Member

Looks great 👍 Gonna leave it up to @briancroom to hit the 'merge' button.

@briancroom
Copy link
Member

Cool, yeah this looks good. Sorry to nit, but would you mind squashing the commits @phatblat? Then go ahead and hit the button, I'd say. I was hoping I could do the squash myself but it looks like that isn't enabled for this repo. @modocache I think you or another admin would have to turn this on?

Adding CurrentTestCaseTracker after XCTestLog has been registered.
@phatblat
Copy link
Member Author

phatblat commented Apr 7, 2016

Squashed. Just waiting for CI to finish and then I'll merge.

@phatblat phatblat merged commit 1a9e53e into Quick:master Apr 7, 2016
@phatblat phatblat deleted the test-observer3 branch April 7, 2016 21:59
@phatblat
Copy link
Member Author

phatblat commented Apr 7, 2016

@briancroom the squash option shows up after the first click on the merge button
screen shot 2016-04-07 at 3 58 47 pm

@briancroom
Copy link
Member

Aha, that explains it. Glad to see this fix go in. Thanks @phatblat!

Megal pushed a commit to Megal/Nimble that referenced this pull request Jul 31, 2019
)

Swizzle XCTestObservationCenter observer registration methods
phatblat pushed a commit to phatblat/Nimble that referenced this pull request May 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants