-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.simplecov
executable file
·53 lines (43 loc) · 1.56 KB
/
.simplecov
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env ruby
# frozen_string_literal: true
SimpleCov.print_error_status = false
SimpleCov.enable_coverage(:branch) if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.5')
SimpleCov.root __dir__
SimpleCov.formatter SimpleCov::Formatter::SimpleFormatter
SimpleCov.minimum_coverage 0
SimpleCov.add_filter '/backports'
SimpleCov.add_filter '/spec/'
# because i have to skip and mock some of it for expediency reasons
SimpleCov.add_filter '/bin/generate'
require 'parallel'
# internals of Parallel i'm sure it's fine
# this is the only way that i can tell to coverage inside parallel blocks
# without modifying my code in ugly ways
module Parallel
def self.worker(job_factory, options, &block) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
child_read, parent_write = IO.pipe
parent_read, child_write = IO.pipe
pid = Process.fork do
# here begins my additions
SimpleCov.command_name "Parallel #{Process.pid}"
SimpleCov.formatter SimpleCov::Formatter::SimpleFormatter
SimpleCov.minimum_coverage 0
SimpleCov.print_error_status = false
SimpleCov.start
# here ends my additions
self.worker_number = options[:worker_number]
begin
options.delete(:started_workers).each(&:close_pipes)
parent_write.close
parent_read.close
process_incoming_jobs(child_read, child_write, job_factory, options, &block)
ensure
child_read.close
child_write.close
end
end
child_read.close
child_write.close
Worker.new(parent_read, parent_write, pid)
end
end