diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb index 4373ee338c..d0f68c41a9 100644 --- a/test/ruby/test_jit.rb +++ b/test/ruby/test_jit.rb @@ -163,14 +163,18 @@ class TestJIT < Test::Unit::TestCase end def test_compile_insn_putspecialobject_putiseq - assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: 'hello', success_count: 2, insns: %i[putspecialobject putiseq]) + if /mingw/ =~ RUBY_PLATFORM + skip "this is currently failing on MinGW [Bug #14948]" + end + + assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: 'hellohello', success_count: 2, insns: %i[putspecialobject putiseq]) begin; - print proc { + print 2.times.map { def method_definition 'hello' end method_definition - }.call + }.join end; end @@ -534,37 +538,36 @@ class TestJIT < Test::Unit::TestCase end def test_unload_units - if /mingw/ =~ RUBY_PLATFORM - skip "this is currently failing on MinGW [Bug #14948]" - end - Dir.mktmpdir("jit_test_unload_units_") do |dir| # MIN_CACHE_SIZE is 10 out, err = eval_with_jit({"TMPDIR"=>dir}, "#{<<~"begin;"}\n#{<<~'end;'}", verbose: 1, min_calls: 1, max_cache: 10) begin; - 10.times do |i| + i = 0 + while i < 11 eval(<<-EOS) def mjit#{i} print #{i} end mjit#{i} EOS + i += 1 end end; - assert_equal('0123456789', out) + assert_equal('012345678910', out) compactions, errs = err.lines.partition do |l| l.match?(/\AJIT compaction \(\d+\.\dms\): Compacted \d+ methods ->/) end - assert_match(/\A#{JIT_SUCCESS_PREFIX}: block in
@-e:/, errs[0]) - 9.times do |i| - assert_match(/\A#{JIT_SUCCESS_PREFIX}: mjit#{i}@\(eval\):/, errs[i + 1]) + 10.times do |i| + assert_match(/\A#{JIT_SUCCESS_PREFIX}: mjit#{i}@\(eval\):/, errs[i]) end assert_equal("Too many JIT code -- 1 units unloaded\n", errs[10]) - assert_match(/\A#{JIT_SUCCESS_PREFIX}: mjit9@\(eval\):/, errs[11]) + assert_match(/\A#{JIT_SUCCESS_PREFIX}: mjit10@\(eval\):/, errs[11]) # On --jit-wait, when the number of JIT-ed code reaches --jit-max-cache, # it should trigger compaction. - assert_equal(2, compactions.size) + unless RUBY_PLATFORM.match?(/mswin|mingw/) # compaction is not supported on Windows yet + assert_equal(2, compactions.size) + end # verify .o files are deleted on unload_units assert_send([Dir, :empty?, dir])