summaryrefslogtreecommitdiff
path: root/test/mmtk/helper.rb
blob: 3bede9ed301895e8439700e54b64757268b25e7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 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