Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid to stop process by invalid jobs_count #419

Merged
merged 1 commit into from
Aug 27, 2021
Merged
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/steep/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def handle_jobs_option(command, opts, modifier = 0)
default = physical_processor_count + modifier
command.jobs_count = default
opts.on("-j N", "--jobs=N", "Specify the number of type check workers (defaults: #{default})") do |count|
command.jobs_count = Integer(count)
command.jobs_count = Integer(count) if Integer(count) > 0
end
end

Expand Down
24 changes: 24 additions & 0 deletions test/cli_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,30 @@ def test_version
end
end

def test_jobs_count
sub_test = -> (command, args) do
in_tmpdir do
(current_dir + "Steepfile").write(<<-EOF)
target :app do
check "foo.rb"
end
EOF

(current_dir + "foo.rb").write(<<-EOF)
1 + 2
EOF

stdout, status = sh(*steep, command, *args)

assert_predicate status, :success?, stdout
assert_match /No type error detected\./, stdout
end
end
sub_test.call("check", %w(-j 1))
sub_test.call("check", %w(-j 0))
sub_test.call("check", %w(-j -1))
end

def test_check_success
in_tmpdir do
(current_dir + "Steepfile").write(<<-EOF)
Expand Down