diff --git a/test/ruby/test_zjit.rb b/test/ruby/test_zjit.rb index 49b3616425ecd3..49b23947774eea 100644 --- a/test/ruby/test_zjit.rb +++ b/test/ruby/test_zjit.rb @@ -28,7 +28,7 @@ def test_stats_enabled end def test_stats_quiet - # Test that --zjit-stats=quiet collects stats but doesn't print them + # Test that --zjit-stats-quiet collects stats but doesn't print them script = <<~RUBY def test = 42 test @@ -44,11 +44,24 @@ def test = 42 assert_includes(err, stats_header) assert_equal("true\n", out) - # With --zjit-stats=quiet, stats should NOT be printed but still enabled + # With --zjit-stats-quiet, stats should NOT be printed but still enabled out, err, status = eval_with_jit(script, stats: :quiet) assert_success(out, err, status) refute_includes(err, stats_header) assert_equal("true\n", out) + + # With --zjit-stats=, stats should be printed to the path + Tempfile.create("zjit-stats-") {|tmp| + stats_file = tmp.path + tmp.puts("Lorem ipsum dolor sit amet, consectetur adipiscing elit, ...") + tmp.close + + out, err, status = eval_with_jit(script, stats: stats_file) + assert_success(out, err, status) + refute_includes(err, stats_header) + assert_equal("true\n", out) + assert_equal stats_header, File.open(stats_file) {|f| f.gets(chomp: true)}, "should be overwritten" + } end def test_enable_through_env @@ -88,7 +101,7 @@ def test_zjit_disable end def test_zjit_enable_respects_existing_options - assert_separately(['--zjit-disable', '--zjit-stats=quiet'], <<~RUBY) + assert_separately(['--zjit-disable', '--zjit-stats-quiet'], <<~RUBY) refute_predicate RubyVM::ZJIT, :enabled? assert_predicate RubyVM::ZJIT, :stats_enabled? @@ -3622,7 +3635,14 @@ def eval_with_jit( if zjit args << "--zjit-call-threshold=#{call_threshold}" args << "--zjit-num-profiles=#{num_profiles}" - args << "--zjit-stats#{"=#{stats}" unless stats == true}" if stats + case stats + when true + args << "--zjit-stats" + when :quiet + args << "--zjit-stats-quiet" + else + args << "--zjit-stats=#{stats}" if stats + end args << "--zjit-debug" if debug if allowed_iseqs jitlist = Tempfile.new("jitlist")