Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check GC.enable'd status before and after test execution. Write this checker in gc_checker.rb, it was renamed from gc_compact_checker.rb.
- Loading branch information
Showing
4 changed files
with
38 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# frozen_string_literal: true | ||
|
||
module GCDisabledChecker | ||
def before_setup | ||
if @__gc_disabled__ = GC.enable # return true if GC is disabled | ||
GC.disable | ||
end | ||
|
||
super | ||
end | ||
|
||
def after_teardown | ||
super | ||
|
||
disabled = GC.enable | ||
GC.disable if @__gc_disabled__ | ||
|
||
if @__gc_disabled__ != disabled | ||
label = { | ||
true => 'disabled', | ||
false => 'enabled', | ||
} | ||
raise "GC was #{label[@__gc_disabled__]}, but is #{label[disabled]} after the test." | ||
end | ||
end | ||
end | ||
|
||
module GCCompactChecker | ||
def after_teardown | ||
super | ||
GC.compact | ||
end | ||
end | ||
|
||
Test::Unit::TestCase.include GCDisabledChecker | ||
Test::Unit::TestCase.include GCCompactChecker if ENV['RUBY_TEST_GC_COMPACT'] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters