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

check GC.enable'd status #4710

Merged
merged 1 commit into from Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 36 additions & 0 deletions tool/lib/gc_checker.rb
@@ -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']
10 changes: 0 additions & 10 deletions tool/lib/gc_compact_checker.rb

This file was deleted.

2 changes: 1 addition & 1 deletion tool/lib/test/unit/parallel.rb
Expand Up @@ -6,7 +6,7 @@
require "tracepointchecker"
require "zombie_hunter"
require "iseq_loader_checker"
require "gc_compact_checker"
require "gc_checker"

module Test
module Unit
Expand Down
2 changes: 1 addition & 1 deletion tool/test/runner.rb
Expand Up @@ -9,7 +9,7 @@
require "tracepointchecker"
require "zombie_hunter"
require "iseq_loader_checker"
require "gc_compact_checker"
require "gc_checker"
require_relative "../test-coverage.rb" if ENV.key?('COVERAGE')

case $0
Expand Down