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 8, 2021
1 parent 541d140 commit 68b7578
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
13 changes: 13 additions & 0 deletions .simplecov
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
SimpleCov.start do
if ENV['SIMPLECOV_ROOT']
SimpleCov.root(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 =~ /^#{SimpleCov.root}/)
end
end

add_group 'Source code', 'lib'

add_group 'Unit tests', 'spec'
Expand Down
30 changes: 7 additions & 23 deletions bin/msync
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,18 @@

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'
#
# Note: This environment variable (ie. COVERAGE) is set in Cucumber/Aruba configuration to collect reports
simplecov_root = File.expand_path File.join(File.dirname(__FILE__), '..')

# When running with aruba simplecov was using /tmp/aruba as the root folder.
# This is to force using the project folder
ENV['SIMPLECOV_ROOT'] = simplecov_root
require 'simplecov'

# https://github.com/simplecov-ruby/simplecov/issues/234
# As described in the issue, every process must have an unique name:
SimpleCov.command_name "#{File.basename $PROGRAM_NAME} (pid: #{Process.pid})"

# 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
end

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

0 comments on commit 68b7578

Please sign in to comment.