Commit
this prevents test state from accumulating, resulting in leaked objects and slow tests due to overactive GC.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module ActiveSupport | ||
module Testing | ||
module GarbageCollection | ||
def self.included(base) | ||
base.teardown :scrub_leftover_instance_variables | ||
end | ||
|
||
private | ||
|
||
RESERVED_INSTANCE_VARIABLES = %w(@test_passed @passed @method_name @__name__ @_result).map(&:to_sym) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
tenderlove
Member
|
||
|
||
def scrub_leftover_instance_variables | ||
(instance_variables.map(&:to_sym) - RESERVED_INSTANCE_VARIABLES).each do |var| | ||
remove_instance_variable(var) | ||
end | ||
end | ||
end | ||
end | ||
end |
This list must be changed every time minitest changes. In fact, this list is inaccurate for 1.9.3 trunk and anyone on 1.9.2 who upgrades minitest.
Can we write this in such a way that if minitest is updated, we don't need to update this list? Or remove this from Rails and make it a plugin so that it can be release out of band from Rails?
This list is missing the
@__io__
variable found here.