File: sequel_coverage.rb

package info (click to toggle)
ruby-sequel 5.63.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,408 kB
  • sloc: ruby: 113,747; makefile: 3
file content (32 lines) | stat: -rw-r--r-- 982 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require 'simplecov'

def SimpleCov.sequel_coverage(opts = {})
  start do
    enable_coverage :branch
    command_name SEQUEL_COVERAGE unless SEQUEL_COVERAGE == "1"
    add_filter "/spec/"

    if ENV['SEQUEL_MERGE_COVERAGE']
      filter = %r{bin/sequel\z|lib/sequel/(\w+\.rb|(dataset|database|model|connection_pool|extensions|plugins)/\w+\.rb|adapters/(mock|(shared/)?postgres)\.rb)\z}
      add_filter{|src| src.filename !~ filter}
    elsif opts[:filter]
      add_filter{|src| src.filename !~ opts[:filter]}
    end

    if opts[:subprocesses]
      enable_for_subprocesses true
      ENV['COVERAGE'] = 'subprocess'
      ENV['RUBYOPT'] = "#{ENV['RUBYOPT']} -r ./spec/sequel_coverage"
    elsif SEQUEL_COVERAGE == 'subprocess'
      command_name "bin-#{$$}"
      self.print_error_status = false
      formatter SimpleCov::Formatter::SimpleFormatter
    end
  end
end

SEQUEL_COVERAGE = ENV.delete('COVERAGE')

if SEQUEL_COVERAGE == 'subprocess'
  SimpleCov.sequel_coverage
end