Skip to content

Commit c0920bb

Browse files
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.
1 parent 3aa9222 commit c0920bb

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

lib/rbs/cli.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ def run_test(args, options)
10611061
env_hash = {
10621062
'RUBYOPT' => "#{ENV['RUBYOPT']} -rrbs/test/setup",
10631063
'RBS_TEST_OPT' => test_opt(options),
1064-
'RBS_TEST_LOGLEVEL' => %w(DEBUG INFO WARN ERROR FATAL)[RBS.logger_level || 5] || "UNKNOWN",
1064+
'RBS_TEST_LOGLEVEL' => RBS.logger_level || "UNKNOWN",
10651065
'RBS_TEST_SAMPLE_SIZE' => sample_size,
10661066
'RBS_TEST_DOUBLE_SUITE' => double_suite,
10671067
'RBS_TEST_UNCHECKED_CLASSES' => (unchecked_classes.join(',') unless unchecked_classes.empty?),

test/rbs/cli_test.rb

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,22 @@ def test_prototype__runtime__todo
10441044
def test_test
10451045
Dir.mktmpdir do |dir|
10461046
dir = Pathname(dir)
1047+
dir.join('foo.rb').write(<<~RB)
1048+
class Foo
1049+
def foo(*)
1050+
end
1051+
end
1052+
1053+
module Bar
1054+
class Baz
1055+
def foo
1056+
end
1057+
end
1058+
end
1059+
1060+
# violates type definition
1061+
Foo.new.foo(1)
1062+
RB
10471063
dir.join('foo.rbs').write(<<~RBS)
10481064
class Foo
10491065
def foo: () -> void
@@ -1059,10 +1075,12 @@ def foo: () -> void
10591075
with_cli do |cli|
10601076
# `exit` is a common shell built-in command.
10611077
assert_rbs_test_no_errors(cli, dir, %w(--target ::Foo exit))
1078+
assert_rbs_test_no_errors(cli, dir, %w(--target ::Foo exit), %w(--log-level debug))
10621079

10631080
refute_cli_success cli.run(%w(test))
10641081
refute_cli_success cli.run(%W(-I #{dir} test))
10651082
refute_cli_success cli.run(%W(-I #{dir} test --target ::Foo))
1083+
refute_cli_success cli.run(%W(-I #{dir} test --target ::Foo ruby #{dir}/foo.rb))
10661084
end
10671085
end
10681086
end
@@ -1715,8 +1733,8 @@ def x: () -> untyped
17151733
end
17161734
end
17171735

1718-
def assert_rbs_test_no_errors cli, dir, arg_array
1719-
args = ['-I', dir.to_s, 'test', *arg_array]
1736+
def assert_rbs_test_no_errors cli, dir, arg_array, env_array = []
1737+
args = ['-I', dir.to_s, *env_array, 'test', *arg_array]
17201738
exit_status = cli.run(args)
17211739
assert_instance_of Integer, exit_status
17221740
assert_predicate exit_status, :zero?

0 commit comments

Comments
 (0)