From 2f198a364c1affec42f8dc30cbb9248c7fc8dd66 Mon Sep 17 00:00:00 2001 From: HoneyryderChuck Date: Wed, 22 Apr 2026 15:56:39 +0100 Subject: [PATCH] fix: --log-level now works when used with rbs test the value was being parsed into a string, but was then being used as an array index. --- lib/rbs/cli.rb | 2 +- test/rbs/cli_test.rb | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/rbs/cli.rb b/lib/rbs/cli.rb index bf3a3c22a..5f0413490 100644 --- a/lib/rbs/cli.rb +++ b/lib/rbs/cli.rb @@ -1061,7 +1061,7 @@ def run_test(args, options) env_hash = { 'RUBYOPT' => "#{ENV['RUBYOPT']} -rrbs/test/setup", 'RBS_TEST_OPT' => test_opt(options), - 'RBS_TEST_LOGLEVEL' => %w(DEBUG INFO WARN ERROR FATAL)[RBS.logger_level || 5] || "UNKNOWN", + 'RBS_TEST_LOGLEVEL' => RBS.logger_level || "UNKNOWN", 'RBS_TEST_SAMPLE_SIZE' => sample_size, 'RBS_TEST_DOUBLE_SUITE' => double_suite, 'RBS_TEST_UNCHECKED_CLASSES' => (unchecked_classes.join(',') unless unchecked_classes.empty?), diff --git a/test/rbs/cli_test.rb b/test/rbs/cli_test.rb index a9becac11..2e8666398 100644 --- a/test/rbs/cli_test.rb +++ b/test/rbs/cli_test.rb @@ -1044,6 +1044,22 @@ def test_prototype__runtime__todo def test_test Dir.mktmpdir do |dir| dir = Pathname(dir) + dir.join('foo.rb').write(<<~RB) + class Foo + def foo(*) + end + end + + module Bar + class Baz + def foo + end + end + end + + # violates type definition + Foo.new.foo(1) + RB dir.join('foo.rbs').write(<<~RBS) class Foo def foo: () -> void @@ -1059,10 +1075,12 @@ def foo: () -> void with_cli do |cli| # `exit` is a common shell built-in command. assert_rbs_test_no_errors(cli, dir, %w(--target ::Foo exit)) + assert_rbs_test_no_errors(cli, dir, %w(--target ::Foo exit), %w(--log-level debug)) refute_cli_success cli.run(%w(test)) refute_cli_success cli.run(%W(-I #{dir} test)) refute_cli_success cli.run(%W(-I #{dir} test --target ::Foo)) + refute_cli_success cli.run(%W(-I #{dir} test --target ::Foo ruby #{dir}/foo.rb)) end end end @@ -1715,8 +1733,8 @@ def x: () -> untyped end end - def assert_rbs_test_no_errors cli, dir, arg_array - args = ['-I', dir.to_s, 'test', *arg_array] + def assert_rbs_test_no_errors cli, dir, arg_array, env_array = [] + args = ['-I', dir.to_s, *env_array, 'test', *arg_array] exit_status = cli.run(args) assert_instance_of Integer, exit_status assert_predicate exit_status, :zero?