simplecov 0.15.1 → 0.18.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +89 -1
- data/CODE_OF_CONDUCT.md +76 -0
- data/CONTRIBUTING.md +12 -9
- data/ISSUE_TEMPLATE.md +23 -0
- data/{MIT-LICENSE → LICENSE} +0 -0
- data/README.md +300 -115
- data/doc/alternate-formatters.md +20 -0
- data/lib/simplecov.rb +298 -45
- data/lib/simplecov/combine.rb +30 -0
- data/lib/simplecov/combine/branches_combiner.rb +32 -0
- data/lib/simplecov/combine/files_combiner.rb +24 -0
- data/lib/simplecov/combine/lines_combiner.rb +43 -0
- data/lib/simplecov/combine/results_combiner.rb +100 -0
- data/lib/simplecov/command_guesser.rb +8 -3
- data/lib/simplecov/configuration.rb +95 -8
- data/lib/simplecov/defaults.rb +13 -80
- data/lib/simplecov/exit_codes.rb +2 -0
- data/lib/simplecov/file_list.rb +32 -3
- data/lib/simplecov/filter.rb +5 -2
- data/lib/simplecov/formatter.rb +2 -0
- data/lib/simplecov/formatter/multi_formatter.rb +4 -2
- data/lib/simplecov/formatter/simple_formatter.rb +6 -4
- data/lib/simplecov/last_run.rb +5 -1
- data/lib/simplecov/lines_classifier.rb +21 -5
- data/lib/simplecov/load_global_config.rb +2 -0
- data/lib/simplecov/no_defaults.rb +2 -0
- data/lib/simplecov/profiles.rb +11 -7
- data/lib/simplecov/profiles/bundler_filter.rb +5 -0
- data/lib/simplecov/profiles/hidden_filter.rb +5 -0
- data/lib/simplecov/profiles/rails.rb +18 -0
- data/lib/simplecov/profiles/root_filter.rb +10 -0
- data/lib/simplecov/profiles/test_frameworks.rb +8 -0
- data/lib/simplecov/result.rb +13 -4
- data/lib/simplecov/result_adapter.rb +30 -0
- data/lib/simplecov/result_merger.rb +20 -11
- data/lib/simplecov/simulate_coverage.rb +29 -0
- data/lib/simplecov/source_file.rb +190 -109
- data/lib/simplecov/source_file/branch.rb +84 -0
- data/lib/simplecov/source_file/line.rb +72 -0
- data/lib/simplecov/useless_results_remover.rb +16 -0
- data/lib/simplecov/version.rb +3 -1
- metadata +44 -162
- data/.gitignore +0 -31
- data/.rspec +0 -3
- data/.rubocop.yml +0 -88
- data/.travis.yml +0 -29
- data/.yardopts +0 -1
- data/Gemfile +0 -38
- data/Rakefile +0 -39
- data/cucumber.yml +0 -13
- data/features/config_autoload.feature +0 -46
- data/features/config_command_name.feature +0 -45
- data/features/config_coverage_dir.feature +0 -33
- data/features/config_deactivate_merging.feature +0 -42
- data/features/config_formatters.feature +0 -77
- data/features/config_merge_timeout.feature +0 -39
- data/features/config_nocov_token.feature +0 -79
- data/features/config_profiles.feature +0 -44
- data/features/config_project_name.feature +0 -27
- data/features/config_styles.feature +0 -121
- data/features/config_tracked_files.feature +0 -29
- data/features/config_tracked_files_relevant_lines.feature +0 -31
- data/features/cucumber_basic.feature +0 -29
- data/features/maximum_coverage_drop.feature +0 -89
- data/features/merging_test_unit_and_rspec.feature +0 -44
- data/features/minimum_coverage.feature +0 -59
- data/features/refuse_coverage_drop.feature +0 -95
- data/features/rspec_basic.feature +0 -32
- data/features/rspec_fails_on_initialization.feature +0 -14
- data/features/rspec_groups_and_filters_basic.feature +0 -29
- data/features/rspec_groups_and_filters_complex.feature +0 -37
- data/features/rspec_groups_using_filter_class.feature +0 -41
- data/features/rspec_without_simplecov.feature +0 -20
- data/features/skipping_code_blocks_manually.feature +0 -70
- data/features/step_definitions/html_steps.rb +0 -44
- data/features/step_definitions/simplecov_steps.rb +0 -68
- data/features/step_definitions/transformers.rb +0 -13
- data/features/step_definitions/web_steps.rb +0 -64
- data/features/support/aruba_freedom_patch.rb +0 -53
- data/features/support/env.rb +0 -50
- data/features/test_unit_basic.feature +0 -34
- data/features/test_unit_groups_and_filters_basic.feature +0 -29
- data/features/test_unit_groups_and_filters_complex.feature +0 -35
- data/features/test_unit_groups_using_filter_class.feature +0 -40
- data/features/test_unit_without_simplecov.feature +0 -20
- data/features/unicode_compatiblity.feature +0 -67
- data/lib/simplecov/jruby_fix.rb +0 -42
- data/lib/simplecov/railtie.rb +0 -7
- data/lib/simplecov/railties/tasks.rake +0 -11
- data/lib/simplecov/raw_coverage.rb +0 -39
- data/simplecov.gemspec +0 -27
- data/spec/1_8_fallbacks_spec.rb +0 -31
- data/spec/command_guesser_spec.rb +0 -48
- data/spec/config_loader_spec.rb +0 -14
- data/spec/configuration_spec.rb +0 -35
- data/spec/defaults_spec.rb +0 -41
- data/spec/deleted_source_spec.rb +0 -12
- data/spec/faked_project/Gemfile +0 -6
- data/spec/faked_project/Rakefile +0 -8
- data/spec/faked_project/cucumber.yml +0 -13
- data/spec/faked_project/features/step_definitions/my_steps.rb +0 -22
- data/spec/faked_project/features/support/env.rb +0 -12
- data/spec/faked_project/features/test_stuff.feature +0 -6
- data/spec/faked_project/lib/faked_project.rb +0 -11
- data/spec/faked_project/lib/faked_project/framework_specific.rb +0 -18
- data/spec/faked_project/lib/faked_project/meta_magic.rb +0 -24
- data/spec/faked_project/lib/faked_project/some_class.rb +0 -28
- data/spec/faked_project/lib/faked_project/untested_class.rb +0 -11
- data/spec/faked_project/spec/faked_spec.rb +0 -11
- data/spec/faked_project/spec/forking_spec.rb +0 -8
- data/spec/faked_project/spec/meta_magic_spec.rb +0 -15
- data/spec/faked_project/spec/some_class_spec.rb +0 -13
- data/spec/faked_project/spec/spec_helper.rb +0 -11
- data/spec/faked_project/test/faked_test.rb +0 -11
- data/spec/faked_project/test/meta_magic_test.rb +0 -13
- data/spec/faked_project/test/some_class_test.rb +0 -15
- data/spec/faked_project/test/test_helper.rb +0 -12
- data/spec/file_list_spec.rb +0 -50
- data/spec/filters_spec.rb +0 -202
- data/spec/fixtures/app/controllers/sample_controller.rb +0 -10
- data/spec/fixtures/app/models/user.rb +0 -10
- data/spec/fixtures/deleted_source_sample.rb +0 -15
- data/spec/fixtures/frameworks/rspec_bad.rb +0 -9
- data/spec/fixtures/frameworks/rspec_good.rb +0 -9
- data/spec/fixtures/frameworks/testunit_bad.rb +0 -9
- data/spec/fixtures/frameworks/testunit_good.rb +0 -9
- data/spec/fixtures/iso-8859.rb +0 -3
- data/spec/fixtures/never.rb +0 -2
- data/spec/fixtures/resultset1.rb +0 -4
- data/spec/fixtures/resultset2.rb +0 -4
- data/spec/fixtures/sample.rb +0 -16
- data/spec/fixtures/skipped.rb +0 -4
- data/spec/fixtures/skipped_and_executed.rb +0 -8
- data/spec/fixtures/utf-8.rb +0 -3
- data/spec/helper.rb +0 -26
- data/spec/last_run_spec.rb +0 -48
- data/spec/lines_classifier_spec.rb +0 -103
- data/spec/multi_formatter_spec.rb +0 -20
- data/spec/raw_coverage_spec.rb +0 -92
- data/spec/result_merger_spec.rb +0 -171
- data/spec/result_spec.rb +0 -209
- data/spec/return_codes_spec.rb +0 -34
- data/spec/simplecov_spec.rb +0 -109
- data/spec/source_file_line_spec.rb +0 -155
- data/spec/source_file_spec.rb +0 -145
- data/spec/support/fail_rspec_on_ruby_warning.rb +0 -75
data/lib/simplecov/defaults.rb
CHANGED
@@ -1,48 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Load default formatter gem
|
2
4
|
require "simplecov-html"
|
3
5
|
require "pathname"
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
root_filter ||= /\A#{Regexp.escape(SimpleCov.root + File::SEPARATOR)}/io
|
10
|
-
src.filename !~ root_filter
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
SimpleCov.profiles.define "test_frameworks" do
|
15
|
-
add_filter "/test/"
|
16
|
-
add_filter "/features/"
|
17
|
-
add_filter "/spec/"
|
18
|
-
add_filter "/autotest/"
|
19
|
-
end
|
20
|
-
|
21
|
-
SimpleCov.profiles.define "bundler_filter" do
|
22
|
-
add_filter "/vendor/bundle/"
|
23
|
-
end
|
24
|
-
|
25
|
-
SimpleCov.profiles.define "rails" do
|
26
|
-
load_profile "test_frameworks"
|
27
|
-
|
28
|
-
add_filter %r{^/config/}
|
29
|
-
add_filter %r{^/db/}
|
30
|
-
|
31
|
-
add_group "Controllers", "app/controllers"
|
32
|
-
add_group "Channels", "app/channels" if defined?(ActionCable)
|
33
|
-
add_group "Models", "app/models"
|
34
|
-
add_group "Mailers", "app/mailers"
|
35
|
-
add_group "Helpers", "app/helpers"
|
36
|
-
add_group "Jobs", %w[app/jobs app/workers]
|
37
|
-
add_group "Libraries", "lib"
|
38
|
-
|
39
|
-
track_files "{app,lib}/**/*.rb"
|
40
|
-
end
|
6
|
+
require "simplecov/profiles/root_filter"
|
7
|
+
require "simplecov/profiles/test_frameworks"
|
8
|
+
require "simplecov/profiles/bundler_filter"
|
9
|
+
require "simplecov/profiles/hidden_filter"
|
10
|
+
require "simplecov/profiles/rails"
|
41
11
|
|
42
12
|
# Default configuration
|
43
13
|
SimpleCov.configure do
|
44
14
|
formatter SimpleCov::Formatter::HTMLFormatter
|
45
15
|
load_profile "bundler_filter"
|
16
|
+
load_profile "hidden_filter"
|
46
17
|
# Exclude files outside of SimpleCov.root
|
47
18
|
load_profile "root_filter"
|
48
19
|
end
|
@@ -50,52 +21,14 @@ end
|
|
50
21
|
# Gotta stash this a-s-a-p, see the CommandGuesser class and i.e. #110 for further info
|
51
22
|
SimpleCov::CommandGuesser.original_run_command = "#{$PROGRAM_NAME} #{ARGV.join(' ')}"
|
52
23
|
|
53
|
-
at_exit do
|
24
|
+
at_exit do
|
54
25
|
# If we are in a different process than called start, don't interfere.
|
55
26
|
next if SimpleCov.pid != Process.pid
|
56
27
|
|
57
|
-
|
58
|
-
|
59
|
-
# otherwise set a non-zero status representing termination by
|
60
|
-
# some other exception (see github issue 41)
|
61
|
-
$!.is_a?(SystemExit) ? $!.status : SimpleCov::ExitCodes::EXCEPTION
|
62
|
-
else
|
63
|
-
# Store the exit status of the test run since it goes away
|
64
|
-
# after calling the at_exit proc...
|
65
|
-
SimpleCov::ExitCodes::SUCCESS
|
66
|
-
end
|
67
|
-
|
68
|
-
SimpleCov.at_exit.call
|
69
|
-
|
70
|
-
if SimpleCov.result? # Result has been computed
|
71
|
-
covered_percent = SimpleCov.result.covered_percent.round(2)
|
72
|
-
covered_percentages = SimpleCov.result.covered_percentages.map { |p| p.round(2) }
|
73
|
-
|
74
|
-
if @exit_status == SimpleCov::ExitCodes::SUCCESS # No other errors
|
75
|
-
if covered_percent < SimpleCov.minimum_coverage # rubocop:disable Metrics/BlockNesting
|
76
|
-
$stderr.printf("Coverage (%.2f%%) is below the expected minimum coverage (%.2f%%).\n", covered_percent, SimpleCov.minimum_coverage)
|
77
|
-
@exit_status = SimpleCov::ExitCodes::MINIMUM_COVERAGE
|
78
|
-
elsif covered_percentages.any? { |p| p < SimpleCov.minimum_coverage_by_file } # rubocop:disable Metrics/BlockNesting
|
79
|
-
$stderr.printf("File (%s) is only (%.2f%%) covered. This is below the expected minimum coverage per file of (%.2f%%).\n", SimpleCov.result.least_covered_file, covered_percentages.min, SimpleCov.minimum_coverage_by_file)
|
80
|
-
@exit_status = SimpleCov::ExitCodes::MINIMUM_COVERAGE
|
81
|
-
elsif (last_run = SimpleCov::LastRun.read) # rubocop:disable Metrics/BlockNesting
|
82
|
-
coverage_diff = last_run["result"]["covered_percent"] - covered_percent
|
83
|
-
if coverage_diff > SimpleCov.maximum_coverage_drop # rubocop:disable Metrics/BlockNesting
|
84
|
-
$stderr.printf("Coverage has dropped by %.2f%% since the last time (maximum allowed: %.2f%%).\n", coverage_diff, SimpleCov.maximum_coverage_drop)
|
85
|
-
@exit_status = SimpleCov::ExitCodes::MAXIMUM_COVERAGE_DROP
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
# Don't overwrite last_run file if refuse_coverage_drop option is enabled and the coverage has dropped
|
91
|
-
unless @exit_status == SimpleCov::ExitCodes::MAXIMUM_COVERAGE_DROP
|
92
|
-
SimpleCov::LastRun.write(:result => {:covered_percent => covered_percent})
|
93
|
-
end
|
94
|
-
end
|
28
|
+
# If SimpleCov is no longer running then don't run exit tasks
|
29
|
+
next unless SimpleCov.running
|
95
30
|
|
96
|
-
|
97
|
-
# unless it's nil or 0 (see github issue #281)
|
98
|
-
Kernel.exit @exit_status if @exit_status && @exit_status > 0
|
31
|
+
SimpleCov.run_exit_tasks!
|
99
32
|
end
|
100
33
|
|
101
34
|
# Autoload config from ~/.simplecov if present
|
@@ -111,7 +44,7 @@ loop do
|
|
111
44
|
begin
|
112
45
|
load filename
|
113
46
|
rescue LoadError, StandardError
|
114
|
-
|
47
|
+
warn "Warning: Error occurred while trying to load #{filename}. " \
|
115
48
|
"Error message: #{$!.message}"
|
116
49
|
end
|
117
50
|
break
|
data/lib/simplecov/exit_codes.rb
CHANGED
data/lib/simplecov/file_list.rb
CHANGED
@@ -1,28 +1,34 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
3
|
module SimpleCov
|
4
|
+
# An array of SimpleCov SourceFile instances with additional collection helper
|
5
|
+
# methods for calculating coverage across them etc.
|
4
6
|
class FileList < Array
|
5
7
|
# Returns the count of lines that have coverage
|
6
8
|
def covered_lines
|
7
9
|
return 0.0 if empty?
|
10
|
+
|
8
11
|
map { |f| f.covered_lines.count }.inject(:+)
|
9
12
|
end
|
10
13
|
|
11
14
|
# Returns the count of lines that have been missed
|
12
15
|
def missed_lines
|
13
16
|
return 0.0 if empty?
|
17
|
+
|
14
18
|
map { |f| f.missed_lines.count }.inject(:+)
|
15
19
|
end
|
16
20
|
|
17
21
|
# Returns the count of lines that are not relevant for coverage
|
18
22
|
def never_lines
|
19
23
|
return 0.0 if empty?
|
24
|
+
|
20
25
|
map { |f| f.never_lines.count }.inject(:+)
|
21
26
|
end
|
22
27
|
|
23
28
|
# Returns the count of skipped lines
|
24
29
|
def skipped_lines
|
25
30
|
return 0.0 if empty?
|
31
|
+
|
26
32
|
map { |f| f.skipped_lines.count }.inject(:+)
|
27
33
|
end
|
28
34
|
|
@@ -34,7 +40,7 @@ module SimpleCov
|
|
34
40
|
|
35
41
|
# Finds the least covered file and returns that file's name
|
36
42
|
def least_covered_file
|
37
|
-
|
43
|
+
min_by(&:covered_percent).filename
|
38
44
|
end
|
39
45
|
|
40
46
|
# Returns the overall amount of relevant lines of code across all files in this list
|
@@ -46,6 +52,7 @@ module SimpleCov
|
|
46
52
|
# @return [Float]
|
47
53
|
def covered_percent
|
48
54
|
return 100.0 if empty? || lines_of_code.zero?
|
55
|
+
|
49
56
|
Float(covered_lines * 100.0 / lines_of_code)
|
50
57
|
end
|
51
58
|
|
@@ -53,7 +60,29 @@ module SimpleCov
|
|
53
60
|
# @return [Float]
|
54
61
|
def covered_strength
|
55
62
|
return 0.0 if empty? || lines_of_code.zero?
|
63
|
+
|
56
64
|
Float(map { |f| f.covered_strength * f.lines_of_code }.inject(:+) / lines_of_code)
|
57
65
|
end
|
66
|
+
|
67
|
+
# Return total count of branches in all files
|
68
|
+
def total_branches
|
69
|
+
return 0 if empty?
|
70
|
+
|
71
|
+
map { |file| file.total_branches.count }.inject(:+)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Return total count of covered branches
|
75
|
+
def covered_branches
|
76
|
+
return 0 if empty?
|
77
|
+
|
78
|
+
map { |file| file.covered_branches.count }.inject(:+)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Return total count of covered branches
|
82
|
+
def missed_branches
|
83
|
+
return 0 if empty?
|
84
|
+
|
85
|
+
map { |file| file.missed_branches.count }.inject(:+)
|
86
|
+
end
|
58
87
|
end
|
59
88
|
end
|
data/lib/simplecov/filter.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SimpleCov
|
2
4
|
#
|
3
5
|
# Base filter class. Inherit from this to create custom filters,
|
@@ -16,7 +18,7 @@ module SimpleCov
|
|
16
18
|
@filter_argument = filter_argument
|
17
19
|
end
|
18
20
|
|
19
|
-
def matches?(
|
21
|
+
def matches?(_source_file)
|
20
22
|
raise "The base filter class is not intended for direct use"
|
21
23
|
end
|
22
24
|
|
@@ -27,6 +29,7 @@ module SimpleCov
|
|
27
29
|
|
28
30
|
def self.build_filter(filter_argument)
|
29
31
|
return filter_argument if filter_argument.is_a?(SimpleCov::Filter)
|
32
|
+
|
30
33
|
class_for_argument(filter_argument).new(filter_argument)
|
31
34
|
end
|
32
35
|
|
@@ -49,7 +52,7 @@ module SimpleCov
|
|
49
52
|
# Returns true when the given source file's filename matches the
|
50
53
|
# string configured when initializing this Filter with StringFilter.new('somestring)
|
51
54
|
def matches?(source_file)
|
52
|
-
|
55
|
+
source_file.project_filename.include?(filter_argument)
|
53
56
|
end
|
54
57
|
end
|
55
58
|
|
data/lib/simplecov/formatter.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SimpleCov
|
2
4
|
module Formatter
|
3
5
|
class MultiFormatter
|
@@ -6,8 +8,8 @@ module SimpleCov
|
|
6
8
|
formatters.map do |formatter|
|
7
9
|
begin
|
8
10
|
formatter.new.format(result)
|
9
|
-
rescue => e
|
10
|
-
|
11
|
+
rescue StandardError => e
|
12
|
+
warn("Formatter #{formatter} failed with #{e.class}: #{e.message} (#{e.backtrace.first})")
|
11
13
|
nil
|
12
14
|
end
|
13
15
|
end
|
@@ -1,12 +1,14 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
4
3
|
module SimpleCov
|
5
4
|
module Formatter
|
5
|
+
#
|
6
|
+
# A ridiculously simple formatter for SimpleCov results.
|
7
|
+
#
|
6
8
|
class SimpleFormatter
|
7
9
|
# Takes a SimpleCov::Result and generates a string out of it
|
8
10
|
def format(result)
|
9
|
-
output = ""
|
11
|
+
output = +""
|
10
12
|
result.groups.each do |name, files|
|
11
13
|
output << "Group: #{name}\n"
|
12
14
|
output << "=" * 40
|
data/lib/simplecov/last_run.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "json"
|
2
4
|
|
3
5
|
module SimpleCov
|
@@ -9,9 +11,11 @@ module SimpleCov
|
|
9
11
|
|
10
12
|
def read
|
11
13
|
return nil unless File.exist?(last_run_path)
|
14
|
+
|
12
15
|
json = File.read(last_run_path)
|
13
16
|
return nil if json.strip.empty?
|
14
|
-
|
17
|
+
|
18
|
+
JSON.parse(json, symbolize_names: true)
|
15
19
|
end
|
16
20
|
|
17
21
|
def write(json)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SimpleCov
|
2
4
|
# Classifies whether lines are relevant for code coverage analysis.
|
3
5
|
# Comments & whitespace lines, and :nocov: token blocks, are considered not relevant.
|
@@ -6,22 +8,36 @@ module SimpleCov
|
|
6
8
|
RELEVANT = 0
|
7
9
|
NOT_RELEVANT = nil
|
8
10
|
|
9
|
-
WHITESPACE_LINE = /^\s
|
10
|
-
COMMENT_LINE = /^\s
|
11
|
+
WHITESPACE_LINE = /^\s*$/.freeze
|
12
|
+
COMMENT_LINE = /^\s*#/.freeze
|
11
13
|
WHITESPACE_OR_COMMENT_LINE = Regexp.union(WHITESPACE_LINE, COMMENT_LINE)
|
12
14
|
|
13
15
|
def self.no_cov_line
|
14
|
-
/^(\s*)#(\s*)(\:#{SimpleCov.nocov_token}\:)/
|
16
|
+
/^(\s*)#(\s*)(\:#{SimpleCov.nocov_token}\:)/o
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.no_cov_line?(line)
|
20
|
+
line =~ no_cov_line
|
21
|
+
rescue ArgumentError
|
22
|
+
# E.g., line contains an invalid byte sequence in UTF-8
|
23
|
+
false
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.whitespace_line?(line)
|
27
|
+
line =~ WHITESPACE_OR_COMMENT_LINE
|
28
|
+
rescue ArgumentError
|
29
|
+
# E.g., line contains an invalid byte sequence in UTF-8
|
30
|
+
false
|
15
31
|
end
|
16
32
|
|
17
33
|
def classify(lines)
|
18
34
|
skipping = false
|
19
35
|
|
20
36
|
lines.map do |line|
|
21
|
-
if
|
37
|
+
if self.class.no_cov_line?(line)
|
22
38
|
skipping = !skipping
|
23
39
|
NOT_RELEVANT
|
24
|
-
elsif skipping || line
|
40
|
+
elsif skipping || self.class.whitespace_line?(line)
|
25
41
|
NOT_RELEVANT
|
26
42
|
else
|
27
43
|
RELEVANT
|
data/lib/simplecov/profiles.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
# loaded using SimpleCov.start :rails and defined using
|
4
|
-
# SimpleCov.profiles.define :foo do
|
5
|
-
# # SimpleCov configuration here, same as in SimpleCov.configure
|
6
|
-
# end
|
7
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
8
3
|
module SimpleCov
|
4
|
+
#
|
5
|
+
# Profiles are SimpleCov configuration procs that can be easily
|
6
|
+
# loaded using SimpleCov.start :rails and defined using
|
7
|
+
# SimpleCov.profiles.define :foo do
|
8
|
+
# # SimpleCov configuration here, same as in SimpleCov.configure
|
9
|
+
# end
|
10
|
+
#
|
9
11
|
class Profiles < Hash
|
10
12
|
#
|
11
13
|
# Define a SimpleCov profile:
|
@@ -16,6 +18,7 @@ module SimpleCov
|
|
16
18
|
def define(name, &blk)
|
17
19
|
name = name.to_sym
|
18
20
|
raise "SimpleCov Profile '#{name}' is already defined" unless self[name].nil?
|
21
|
+
|
19
22
|
self[name] = blk
|
20
23
|
end
|
21
24
|
|
@@ -25,6 +28,7 @@ module SimpleCov
|
|
25
28
|
def load(name)
|
26
29
|
name = name.to_sym
|
27
30
|
raise "Could not find SimpleCov Profile called '#{name}'" unless key?(name)
|
31
|
+
|
28
32
|
SimpleCov.configure(&self[name])
|
29
33
|
end
|
30
34
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
SimpleCov.profiles.define "rails" do
|
4
|
+
load_profile "test_frameworks"
|
5
|
+
|
6
|
+
add_filter %r{^/config/}
|
7
|
+
add_filter %r{^/db/}
|
8
|
+
|
9
|
+
add_group "Controllers", "app/controllers"
|
10
|
+
add_group "Channels", "app/channels"
|
11
|
+
add_group "Models", "app/models"
|
12
|
+
add_group "Mailers", "app/mailers"
|
13
|
+
add_group "Helpers", "app/helpers"
|
14
|
+
add_group "Jobs", %w[app/jobs app/workers]
|
15
|
+
add_group "Libraries", "lib/"
|
16
|
+
|
17
|
+
track_files "{app,lib}/**/*.rb"
|
18
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
SimpleCov.profiles.define "root_filter" do
|
4
|
+
# Exclude all files outside of simplecov root
|
5
|
+
root_filter = nil
|
6
|
+
add_filter do |src|
|
7
|
+
root_filter ||= /\A#{Regexp.escape(SimpleCov.root + File::SEPARATOR)}/io
|
8
|
+
src.filename !~ root_filter
|
9
|
+
end
|
10
|
+
end
|