123456789_123456789_123456789_123456789_123456789_

Module: SimpleCov::CLI::Run

Relationships & Source Files
Defined in: lib/simplecov/cli/run.rb

Overview

simplecov run <command...> — exec the given command with simplecov auto-loaded so a coverage report drops into the project's coverage/ directory at the end. Useful for projects without a test_helper that already calls SimpleCov.start (e.g. plain bundle exec rake test on an unconfigured library).

Constant Summary

Class Method Summary

Class Method Details

.rubyopt_env (mod_func)

[ GitHub ]

  
# File 'lib/simplecov/cli/run.rb', line 28

def rubyopt_env
  existing = ENV["RUBYOPT"].to_s.strip
  injection = "-r#{AUTOSTART}"
  merged = existing.empty? ? injection : "#{existing} #{injection}"
  ENV.to_hash.merge("RUBYOPT" => merged)
end

.run(args, stderr:) (mod_func)

[ GitHub ]

  
# File 'lib/simplecov/cli/run.rb', line 15

def run(args, stderr:, **)
  cmd = args.first == "--" ? args.drop(1) : args
  if cmd.empty?
    stderr.puts("simplecov run: missing command")
    return 1
  end

  Kernel.exec(rubyopt_env, *cmd)
rescue Errno::ENOENT => e
  stderr.puts("simplecov run: #{e.message}")
  127
end