diff options
| author | Takashi Kokubun <takashikkbn@gmail.com> | 2023-10-19 10:54:35 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-19 10:54:35 -0700 |
| commit | 6beb09c2c99a2575027bdbc60a6fbb099416f74d (patch) | |
| tree | dc0033f88b48f9cfd7ecaa67ca055a09a4437f96 /test/ruby | |
| parent | 62e340251b577e3a9d11ac5c2b75ad49b8036294 (diff) | |
YJIT: Add RubyVM::YJIT.enable (#8705)
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_yjit.rb | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/test/ruby/test_yjit.rb b/test/ruby/test_yjit.rb index 4066664600..fa357b4977 100644 --- a/test/ruby/test_yjit.rb +++ b/test/ruby/test_yjit.rb @@ -51,27 +51,36 @@ class TestYJIT < Test::Unit::TestCase #assert_in_out_err('--yjit-call-threshold=', '', [], /--yjit-call-threshold needs an argument/) end - def test_starting_paused - program = <<~RUBY + def test_yjit_enable + args = [] + args << "--disable=yjit" if RubyVM::YJIT.enabled? + assert_separately(args, <<~RUBY) + assert_false RubyVM::YJIT.enabled? + assert_false RUBY_DESCRIPTION.include?("+YJIT") + + RubyVM::YJIT.enable + + assert_true RubyVM::YJIT.enabled? + assert_true RUBY_DESCRIPTION.include?("+YJIT") + RUBY + end + + def test_yjit_enable_with_call_threshold + assert_separately(%w[--yjit-disable --yjit-call-threshold=1], <<~RUBY) def not_compiled = nil def will_compile = nil - def compiled_counts = RubyVM::YJIT.runtime_stats[:compiled_iseq_count] - counts = [] + def compiled_counts = RubyVM::YJIT.runtime_stats&.dig(:compiled_iseq_count) + not_compiled - counts << compiled_counts + assert_nil compiled_counts + assert_false RubyVM::YJIT.enabled? - RubyVM::YJIT.resume + RubyVM::YJIT.enable will_compile - counts << compiled_counts - - if counts[0] == 0 && counts[1] > 0 - p :ok - end + assert compiled_counts > 0 + assert_true RubyVM::YJIT.enabled? RUBY - assert_in_out_err(%w[--yjit-pause --yjit-stats --yjit-call-threshold=1], program, success: true) do |stdout, stderr| - assert_equal([":ok"], stdout) - end end def test_yjit_stats_and_v_no_error |
