mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00

Even if `setup` is omitted, but `teardown` is called and `EnvUtil.timeout_scale` was reset with `nil`.
32 lines
645 B
Ruby
32 lines
645 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "test/unit"
|
|
require "core_assertions"
|
|
|
|
module MMTk
|
|
class TestCase < ::Test::Unit::TestCase
|
|
include Test::Unit::CoreAssertions
|
|
|
|
def setup
|
|
omit "Not running on MMTk" unless using_mmtk?
|
|
|
|
@original_timeout_scale = EnvUtil.timeout_scale
|
|
timeout_scale = ENV["RUBY_TEST_TIMEOUT_SCALE"].to_f
|
|
EnvUtil.timeout_scale = timeout_scale if timeout_scale > 0
|
|
|
|
super
|
|
end
|
|
|
|
def teardown
|
|
if using_mmtk?
|
|
EnvUtil.timeout_scale = @original_timeout_scale
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def using_mmtk?
|
|
GC.config[:implementation] == "mmtk"
|
|
end
|
|
end
|
|
end
|