-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Add a test function to detect a memory leak if it it happened #3859
base: master
Are you sure you want to change the base?
Add a test function to detect a memory leak if it it happened #3859
Conversation
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.
Thanks, this seems like it could be useful. Just a couple small notes.
/// - object: The testing object for each class. | ||
/// - file: Which file that failure test happens. | ||
/// - line: Which line that failure test happens. | ||
@available(iOS 13.0, macOS 10.15, tvOS 13.0, *) |
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.
Can you add explicit watchOS and visionOS support as well? I think the other OSes are on their own.
checkMemoryLeaksIfApplicable(interceptor) | ||
} | ||
|
||
private func checkMemoryLeaksIfApplicable(_ object: AnyObject, file: StaticString = #file, line: UInt = #line) { |
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.
Seems like this should just live in the BaseTestCase
to allow for all tests to use it. And given we can't test back before iOS 13 anyway, I'm not sure the IfApplicable
is really necessary here.
Goals ⚽
Follow up from #3766, I create a test function to check that is
RequestInterceptor
has a memory leak or not. It's becoming this pull request because it could be used with other places as well.Implementation Details 🚧
checkMemoryLeaks
inBaseTestCase
so that all subclassed test classes can use this function.InterceptorTests
class.Example of memory leaks (It's just fake from me):