lib/raap/cli.rb in raap-0.6.0 vs lib/raap/cli.rb in raap-0.8.0
- old
+ new
@@ -10,10 +10,11 @@
:timeout,
:size_from,
:size_to,
:size_by,
:allow_private,
+ :coverage,
keyword_init: true
)
# Should skip methods has side effects
DEFAULT_SKIP = Set.new
@@ -35,34 +36,32 @@
attr_accessor :option, :argv, :skip, :results
def initialize(argv)
# defaults
@option = Option.new(
- dirs: [],
- requires: [],
- libraries: [],
timeout: 3,
size_from: 0,
size_to: 99,
size_by: 1,
+ coverage: true,
allow_private: false,
)
@argv = argv
@skip = DEFAULT_SKIP.dup
@results = []
end
def load
OptionParser.new do |o|
o.on('-I', '--include PATH') do |path|
- @option.dirs << path
+ RaaP::RBS.loader.add(path: Pathname(path))
end
o.on('--library lib', 'load rbs library') do |lib|
- @option.libraries << lib
+ RaaP::RBS.loader.add(library: lib, version: nil)
end
o.on('--require lib', 'require ruby library') do |lib|
- @option.requires << lib
+ require lib
end
o.on('--log-level level', "default: info") do |arg|
RaaP.logger.level = arg
end
o.on('--timeout sec', Float, "default: #{@option.timeout}") do |arg|
@@ -78,22 +77,18 @@
@option.size_by = arg
end
o.on('--allow-private', "default: #{@option.allow_private}") do
@option.allow_private = true
end
+ o.on('--preload path', 'Kernel.load path') do |path|
+ Kernel.load path
+ end
+ o.on('--[no-]coverage', "Show coverage for RBS (default: #{@option.coverage})") do |arg|
+ @option.coverage = arg
+ end
end.parse!(@argv)
- @option.dirs.each do |dir|
- RaaP::RBS.loader.add(path: Pathname(dir))
- end
- @option.libraries.each do |lib|
- RaaP::RBS.loader.add(library: lib, version: nil)
- end
- @option.requires.each do |lib|
- require lib
- end
-
self
end
def run
Signal.trap(:INT) do
@@ -298,10 +293,11 @@
),
size_step: @option.size_from.step(to: @option.size_to, by: @option.size_by),
timeout: @option.timeout,
allow_private: @option.allow_private,
)
+ RaaP::Coverage.start(method_type) if @option.coverage
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
stats = prop.run do |called|
case called
in Result::Success => s
print '.'
@@ -335,9 +331,12 @@
RaaP.logger.debug(e.exception.backtrace.join("\n"))
end
end
end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
puts
+ RaaP::Coverage.show($stdout) if @option.coverage
+ puts
+
time_diff = end_time - start_time
time = ", time: #{(time_diff * 1000).round}ms"
stats_log = "success: #{stats.success}, skip: #{stats.skip}, exception: #{stats.exception}#{time}"
RaaP.logger.info(stats_log)