Skip to content

Commit

Permalink
Simplecov: Centralize filters setup
Browse files Browse the repository at this point in the history
  • Loading branch information
neomilium committed Oct 6, 2021
1 parent 80fd32e commit a2cb064
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
13 changes: 13 additions & 0 deletions .simplecov
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
SimpleCov.start do
if ENV['SIMPLECOV_ROOT']
filters.clear # This will remove the :root_filter and :bundler_filter that come via simplecov's defaults

# Because simplecov filters everything outside of the SimpleCov.root
# This should be added, cf.
# https://github.com/colszowka/simplecov#default-root-filter-and-coverage-for-things-outside-of-it
add_filter do |src|
!(src.filename =~ /^#{ENV['SIMPLECOV_ROOT']}/) unless src.filename =~ /project/
end
end

add_group 'Source code', 'lib'

add_group 'Unit tests', 'spec'
Expand All @@ -24,3 +35,5 @@ if ENV['CODECOV']
SimpleCov::Formatter::Codecov,
]
end

# vim: filetype=ruby
22 changes: 3 additions & 19 deletions bin/msync
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
if ENV['COVERAGE']
# This block allow us to grab code coverage when running this script.
# Note: This environment variable is set in Cucumber/Aruba configuration to collect reports'
simplecov_root = File.expand_path File.join(File.dirname(__FILE__), '..')
ENV['SIMPLECOV_ROOT'] = simplecov_root
require 'simplecov'

# https://github.com/simplecov-ruby/simplecov/issues/234
Expand All @@ -11,25 +13,7 @@ if ENV['COVERAGE']

# When running with aruba simplecov was using /tmp/aruba as the root folder.
# This is to force using the project folder
SimpleCov.root(File.join(File.expand_path(File.dirname(__FILE__)), '..'))

SimpleCov.start do
filters.clear # This will remove the :root_filter and :bundler_filter that come via simplecov's defaults

# Because simplecov filters everything outside of the SimpleCov.root
# This should be added, cf.
# https://github.com/colszowka/simplecov#default-root-filter-and-coverage-for-things-outside-of-it
add_filter do |src|
!(src.filename =~ /^#{SimpleCov.root}/) unless src.filename =~ /project/
end

# Ignoring test folders and tmp for Aruba
add_filter '/spec/'
add_filter '/test/'
add_filter '/features/'
add_filter '/tmp/'
add_filter '/vendor/'
end
SimpleCov.root(simplecov_root)
end

lib = File.expand_path('../../lib', __FILE__)
Expand Down

0 comments on commit a2cb064

Please sign in to comment.