-
-
Notifications
You must be signed in to change notification settings - Fork 61
/
coverage.rb
42 lines (35 loc) · 1.12 KB
/
coverage.rb
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
# frozen_string_literal: true
require 'coverage'
require 'simplecov'
SimpleCov.root File.expand_path(__dir__)
if ENV['CODECOV_TOKEN']
require 'simplecov-cobertura'
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::CoberturaFormatter,
SimpleCov.formatter,
])
else
warn "Provide a CODECOV_TOKEN environment variable to enable Codecov uploads"
end
def (SimpleCov::ResultAdapter).call(result)
result = result.transform_keys do |path|
template_path = path.sub(
"#{SimpleCov.root}/dummy-app/",
"#{SimpleCov.root}/lib/generators/solidus_stripe/install/templates/"
)
File.exist?(template_path) ? template_path : path
end
result.each do |path, coverage|
next unless path.end_with?('.erb')
# Remove the extra trailing lines added by ERB
coverage[:lines] = coverage[:lines][...File.read(path).lines.size]
end
result
end
warn "Tracking coverage on process #{$$}..."
SimpleCov.start do
root __dir__
enable_coverage_for_eval
add_filter %r{dummy-app/(db|config|spec|tmp)/}
track_files "#{SimpleCov.root}/{dummy-app,lib,app}/**/*.{rb,erb}}"
end