From 94bbf643651acf58491f934b5ad3c3bfd4bee758 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 10 Dec 2025 22:04:43 +0900 Subject: [PATCH 1/2] ZJIT: Fix tests about `--zjit-stats-quiet` option The `--zjit-stats-quiet` and `--zjit-stats=quiet` options differ. The latter option, `=quiet`, does print stats to the file "quiet", but does not suppress output like yjit option `--yjit-stats=quiet`. Fix up ruby/ruby#15414, 29c29c2b7e972359ab83038c5dc27a7e53ae65c7 --- test/ruby/test_zjit.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/test/ruby/test_zjit.rb b/test/ruby/test_zjit.rb index 49b3616425ecd3..06c4b1d89b0a1d 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,7 +44,7 @@ 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) @@ -88,7 +88,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 +3622,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") From ebd196c1e33a4ebb6071671273edb57fa48cdc0f Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 10 Dec 2025 22:13:36 +0900 Subject: [PATCH 2/2] ZJIT: Add a test for `--zjit-stats=` option Fix up ruby/ruby#15414, 29c29c2b7e972359ab83038c5dc27a7e53ae65c7 --- test/ruby/test_zjit.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/ruby/test_zjit.rb b/test/ruby/test_zjit.rb index 06c4b1d89b0a1d..49b23947774eea 100644 --- a/test/ruby/test_zjit.rb +++ b/test/ruby/test_zjit.rb @@ -49,6 +49,19 @@ def test = 42 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