Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rbs/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?),
Expand Down
22 changes: 20 additions & 2 deletions test/rbs/cli_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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?
Expand Down
Loading