-
-
Notifications
You must be signed in to change notification settings - Fork 910
Don't call +[QuickConfiguration initialize]
method manually
#873
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
Conversation
Reopened to trigger CI. |
This fixes a runtime crash when a subclass of QuickSpec is subclassed and the subclass has a Swift struct property. This avoids nested calls of `+[QuickConfiguration initialize]` and `objc_getClassList`.
+initialize
method manually+[QuickConfiguration initialize]
method manually
@@ -26,7 +26,7 @@ @implementation QuickSpec | |||
included an expectation outside of a "it", "describe", or "context" block. | |||
*/ | |||
+ (void)initialize { | |||
[QuickConfiguration initialize]; | |||
[QuickConfiguration class]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By accessing the class, let the Objective-C runtime call +initialize
method of the class.
The new test case is great, allowed me to confirm that the change in this PR does resolve the test issue. However, I still get a crash in gzafra/QuickCrashTest#1 |
Thanks @phatblat, I also confirmed that. So the right direction would be to avoid using |
It seems that replacing diff --git a/Sources/QuickObjectiveC/QuickSpec.m b/Sources/QuickObjectiveC/QuickSpec.m
index 1418fec..080cf52 100644
--- a/Sources/QuickObjectiveC/QuickSpec.m
+++ b/Sources/QuickObjectiveC/QuickSpec.m
@@ -25,7 +25,7 @@ static QuickSpec *currentSpec = nil;
If an exception occurs when compiling the examples, report it to the user. Chances are they
included an expectation outside of a "it", "describe", or "context" block.
*/
-+ (void)initialize {
++ (XCTestSuite *)defaultTestSuite {
[QuickConfiguration class];
World *world = [World sharedWorld];
@@ -48,6 +48,8 @@ static QuickSpec *currentSpec = nil;
}
[self testInvocations];
}];
+
+ return [super defaultTestSuite];
}
/**
Quick/Sources/Quick/QuickSpec.swift Lines 41 to 54 in 8ff77f9
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the ticket! 🎫 Nice work! 🎉
Fixes #853.
This fixes a runtime crash when a subclass of QuickSpec is subclassed and the subclass has a Swift struct property. This avoids nested calls of
+[QuickConfiguration initialize]
andobjc_getClassList
.