Skip to content

Commit

Permalink
Merge pull request #411 from ruby/validate-silent
Browse files Browse the repository at this point in the history
Run validation silently
  • Loading branch information
soutaro authored Oct 8, 2020
2 parents aa488d9 + 579f2ac commit 63cdbd7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ task :test_doc => :parser do
end

task :validate => :parser do
sh "#{ruby} #{rbs} validate"
sh "#{ruby} #{rbs} validate --silent"

FileList["stdlib/*"].each do |path|
next if path =~ %r{stdlib/builtin}
sh "#{ruby} #{rbs} -r#{File.basename(path)} validate"
sh "#{ruby} #{rbs} -r#{File.basename(path)} validate --silent"
end
end

Expand Down
7 changes: 6 additions & 1 deletion lib/rbs/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,11 @@ def run_validate(args, options)
$ rbs validate
EOU

opts.on("--silent") do
require "stringio"
@stdout = StringIO.new
end
end.parse!(args)

loader = EnvironmentLoader.new()
Expand Down Expand Up @@ -544,7 +549,7 @@ def run_prototype(args, options)
Usage: rbs prototype runtime [options...] [pattern...]
Generate RBS prototype based on runtime introspection.
It loads Ruby code specified in [options] and generates RBS prototypes for classes matches to [pattern].
It loads Ruby code specified in [options] and generates RBS prototypes for classes matches to [pattern].
Examples:
Expand Down
6 changes: 6 additions & 0 deletions test/rbs/cli_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ def test_method
def test_validate
with_cli do |cli|
cli.run(%w(-r set validate))
assert_match /Validating/, stdout.string
end

with_cli do |cli|
cli.run(%w(validate --silent))
assert_equal "", stdout.string
end

with_cli do |cli|
Expand Down

0 comments on commit 63cdbd7

Please sign in to comment.