simplecov 0.16.0 → 0.18.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +110 -1
- data/CODE_OF_CONDUCT.md +76 -0
- data/LICENSE +20 -0
- data/README.md +281 -112
- data/doc/alternate-formatters.md +10 -0
- data/lib/simplecov.rb +248 -63
- 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 +60 -0
- data/lib/simplecov/command_guesser.rb +6 -3
- data/lib/simplecov/configuration.rb +110 -9
- data/lib/simplecov/coverage_statistics.rb +56 -0
- data/lib/simplecov/defaults.rb +6 -2
- data/lib/simplecov/file_list.rb +66 -13
- data/lib/simplecov/filter.rb +2 -1
- data/lib/simplecov/formatter/multi_formatter.rb +2 -2
- data/lib/simplecov/formatter/simple_formatter.rb +4 -4
- data/lib/simplecov/last_run.rb +3 -1
- data/lib/simplecov/lines_classifier.rb +2 -2
- data/lib/simplecov/profiles.rb +9 -7
- data/lib/simplecov/profiles/hidden_filter.rb +5 -0
- data/lib/simplecov/profiles/rails.rb +1 -1
- data/lib/simplecov/result.rb +39 -6
- data/lib/simplecov/result_adapter.rb +30 -0
- data/lib/simplecov/result_merger.rb +18 -11
- data/lib/simplecov/simulate_coverage.rb +29 -0
- data/lib/simplecov/source_file.rb +227 -126
- 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 +1 -1
- metadata +32 -53
- data/lib/simplecov/jruby_fix.rb +0 -44
- data/lib/simplecov/railtie.rb +0 -9
- data/lib/simplecov/railties/tasks.rake +0 -13
- data/lib/simplecov/raw_coverage.rb +0 -41
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SimpleCov
|
4
|
+
class SourceFile
|
5
|
+
#
|
6
|
+
# Representing single branch that has been detected in coverage report.
|
7
|
+
# Give us support methods that handle needed calculations.
|
8
|
+
class Branch
|
9
|
+
attr_reader :start_line, :end_line, :coverage, :type
|
10
|
+
|
11
|
+
# rubocop:disable Metrics/ParameterLists
|
12
|
+
def initialize(start_line:, end_line:, coverage:, inline:, type:)
|
13
|
+
@start_line = start_line
|
14
|
+
@end_line = end_line
|
15
|
+
@coverage = coverage
|
16
|
+
@inline = inline
|
17
|
+
@type = type
|
18
|
+
@skipped = false
|
19
|
+
end
|
20
|
+
# rubocop:enable Metrics/ParameterLists
|
21
|
+
|
22
|
+
def inline?
|
23
|
+
@inline
|
24
|
+
end
|
25
|
+
|
26
|
+
#
|
27
|
+
# Return true if there is relevant count defined > 0
|
28
|
+
#
|
29
|
+
# @return [Boolean]
|
30
|
+
#
|
31
|
+
def covered?
|
32
|
+
!skipped? && coverage.positive?
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
# Check if branche missed or not
|
37
|
+
#
|
38
|
+
# @return [Boolean]
|
39
|
+
#
|
40
|
+
def missed?
|
41
|
+
!skipped? && coverage.zero?
|
42
|
+
end
|
43
|
+
|
44
|
+
# The line on which we want to report the coverage
|
45
|
+
#
|
46
|
+
# Usually we choose the line above the start of the branch (so that it shows up
|
47
|
+
# at if/else) because that
|
48
|
+
# * highlights the condition
|
49
|
+
# * makes it distinguishable if the first line of the branch is an inline branch
|
50
|
+
# (see the nested_branches fixture)
|
51
|
+
#
|
52
|
+
def report_line
|
53
|
+
if inline?
|
54
|
+
start_line
|
55
|
+
else
|
56
|
+
start_line - 1
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Flags the branch as skipped
|
61
|
+
def skipped!
|
62
|
+
@skipped = true
|
63
|
+
end
|
64
|
+
|
65
|
+
# Returns true if the branch was marked skipped by virtue of nocov comments.
|
66
|
+
def skipped?
|
67
|
+
@skipped
|
68
|
+
end
|
69
|
+
|
70
|
+
def overlaps_with?(line_range)
|
71
|
+
start_line <= line_range.end && end_line >= line_range.begin
|
72
|
+
end
|
73
|
+
|
74
|
+
#
|
75
|
+
# Return array with coverage count and badge
|
76
|
+
#
|
77
|
+
# @return [Array]
|
78
|
+
#
|
79
|
+
def report
|
80
|
+
[type, coverage]
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SimpleCov
|
4
|
+
class SourceFile
|
5
|
+
# Representation of a single line in a source file including
|
6
|
+
# this specific line's source code, line_number and code coverage,
|
7
|
+
# with the coverage being either nil (coverage not applicable, e.g. comment
|
8
|
+
# line), 0 (line not covered) or >1 (the amount of times the line was
|
9
|
+
# executed)
|
10
|
+
class Line
|
11
|
+
# The source code for this line. Aliased as :source
|
12
|
+
attr_reader :src
|
13
|
+
# The line number in the source file. Aliased as :line, :number
|
14
|
+
attr_reader :line_number
|
15
|
+
# The coverage data for this line: either nil (never), 0 (missed) or >=1 (times covered)
|
16
|
+
attr_reader :coverage
|
17
|
+
# Whether this line was skipped
|
18
|
+
attr_reader :skipped
|
19
|
+
|
20
|
+
# Lets grab some fancy aliases, shall we?
|
21
|
+
alias source src
|
22
|
+
alias line line_number
|
23
|
+
alias number line_number
|
24
|
+
|
25
|
+
def initialize(src, line_number, coverage)
|
26
|
+
raise ArgumentError, "Only String accepted for source" unless src.is_a?(String)
|
27
|
+
raise ArgumentError, "Only Integer accepted for line_number" unless line_number.is_a?(Integer)
|
28
|
+
raise ArgumentError, "Only Integer and nil accepted for coverage" unless coverage.is_a?(Integer) || coverage.nil?
|
29
|
+
|
30
|
+
@src = src
|
31
|
+
@line_number = line_number
|
32
|
+
@coverage = coverage
|
33
|
+
@skipped = false
|
34
|
+
end
|
35
|
+
|
36
|
+
# Returns true if this is a line that should have been covered, but was not
|
37
|
+
def missed?
|
38
|
+
!never? && !skipped? && coverage.zero?
|
39
|
+
end
|
40
|
+
|
41
|
+
# Returns true if this is a line that has been covered
|
42
|
+
def covered?
|
43
|
+
!never? && !skipped? && coverage.positive?
|
44
|
+
end
|
45
|
+
|
46
|
+
# Returns true if this line is not relevant for coverage
|
47
|
+
def never?
|
48
|
+
!skipped? && coverage.nil?
|
49
|
+
end
|
50
|
+
|
51
|
+
# Flags this line as skipped
|
52
|
+
def skipped!
|
53
|
+
@skipped = true
|
54
|
+
end
|
55
|
+
|
56
|
+
# Returns true if this line was skipped, false otherwise. Lines are skipped if they are wrapped with
|
57
|
+
# # :nocov: comment lines.
|
58
|
+
def skipped?
|
59
|
+
!!skipped
|
60
|
+
end
|
61
|
+
|
62
|
+
# The status of this line - either covered, missed, skipped or never. Useful i.e. for direct use
|
63
|
+
# as a css class in report generation
|
64
|
+
def status
|
65
|
+
return "skipped" if skipped?
|
66
|
+
return "never" if never?
|
67
|
+
return "missed" if missed?
|
68
|
+
return "covered" if covered?
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SimpleCov
|
4
|
+
#
|
5
|
+
# Select the files that related to working scope directory of SimpleCov
|
6
|
+
#
|
7
|
+
module UselessResultsRemover
|
8
|
+
ROOT_REGX = /\A#{Regexp.escape(SimpleCov.root + File::SEPARATOR)}/io.freeze
|
9
|
+
|
10
|
+
def self.call(coverage_result)
|
11
|
+
coverage_result.select do |path, _coverage|
|
12
|
+
path =~ ROOT_REGX
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/simplecov/version.rb
CHANGED
metadata
CHANGED
@@ -1,49 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simplecov
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.18.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christoph Olszowka
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: json
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.8'
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '3'
|
23
|
-
type: :runtime
|
24
|
-
prerelease: false
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '1.8'
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '3'
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: simplecov-html
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: 0.10.0
|
40
|
-
type: :runtime
|
41
|
-
prerelease: false
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - "~>"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 0.10.0
|
47
13
|
- !ruby/object:Gem::Dependency
|
48
14
|
name: docile
|
49
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,21 +25,21 @@ dependencies:
|
|
59
25
|
- !ruby/object:Gem::Version
|
60
26
|
version: '1.1'
|
61
27
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
28
|
+
name: simplecov-html
|
63
29
|
requirement: !ruby/object:Gem::Requirement
|
64
30
|
requirements:
|
65
31
|
- - "~>"
|
66
32
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
68
|
-
type: :
|
33
|
+
version: 0.11.0
|
34
|
+
type: :runtime
|
69
35
|
prerelease: false
|
70
36
|
version_requirements: !ruby/object:Gem::Requirement
|
71
37
|
requirements:
|
72
38
|
- - "~>"
|
73
39
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
75
|
-
description: Code coverage for Ruby
|
76
|
-
|
40
|
+
version: 0.11.0
|
41
|
+
description: Code coverage for Ruby with a powerful configuration library and automatic
|
42
|
+
merging of coverage across test suites
|
77
43
|
email:
|
78
44
|
- christoph at olszowka de
|
79
45
|
executables: []
|
@@ -81,15 +47,23 @@ extensions: []
|
|
81
47
|
extra_rdoc_files: []
|
82
48
|
files:
|
83
49
|
- CHANGELOG.md
|
50
|
+
- CODE_OF_CONDUCT.md
|
84
51
|
- CONTRIBUTING.md
|
85
52
|
- ISSUE_TEMPLATE.md
|
53
|
+
- LICENSE
|
86
54
|
- README.md
|
87
55
|
- doc/alternate-formatters.md
|
88
56
|
- doc/commercial-services.md
|
89
57
|
- doc/editor-integration.md
|
90
58
|
- lib/simplecov.rb
|
59
|
+
- lib/simplecov/combine.rb
|
60
|
+
- lib/simplecov/combine/branches_combiner.rb
|
61
|
+
- lib/simplecov/combine/files_combiner.rb
|
62
|
+
- lib/simplecov/combine/lines_combiner.rb
|
63
|
+
- lib/simplecov/combine/results_combiner.rb
|
91
64
|
- lib/simplecov/command_guesser.rb
|
92
65
|
- lib/simplecov/configuration.rb
|
66
|
+
- lib/simplecov/coverage_statistics.rb
|
93
67
|
- lib/simplecov/defaults.rb
|
94
68
|
- lib/simplecov/exit_codes.rb
|
95
69
|
- lib/simplecov/file_list.rb
|
@@ -97,27 +71,34 @@ files:
|
|
97
71
|
- lib/simplecov/formatter.rb
|
98
72
|
- lib/simplecov/formatter/multi_formatter.rb
|
99
73
|
- lib/simplecov/formatter/simple_formatter.rb
|
100
|
-
- lib/simplecov/jruby_fix.rb
|
101
74
|
- lib/simplecov/last_run.rb
|
102
75
|
- lib/simplecov/lines_classifier.rb
|
103
76
|
- lib/simplecov/load_global_config.rb
|
104
77
|
- lib/simplecov/no_defaults.rb
|
105
78
|
- lib/simplecov/profiles.rb
|
106
79
|
- lib/simplecov/profiles/bundler_filter.rb
|
80
|
+
- lib/simplecov/profiles/hidden_filter.rb
|
107
81
|
- lib/simplecov/profiles/rails.rb
|
108
82
|
- lib/simplecov/profiles/root_filter.rb
|
109
83
|
- lib/simplecov/profiles/test_frameworks.rb
|
110
|
-
- lib/simplecov/railtie.rb
|
111
|
-
- lib/simplecov/railties/tasks.rake
|
112
|
-
- lib/simplecov/raw_coverage.rb
|
113
84
|
- lib/simplecov/result.rb
|
85
|
+
- lib/simplecov/result_adapter.rb
|
114
86
|
- lib/simplecov/result_merger.rb
|
87
|
+
- lib/simplecov/simulate_coverage.rb
|
115
88
|
- lib/simplecov/source_file.rb
|
89
|
+
- lib/simplecov/source_file/branch.rb
|
90
|
+
- lib/simplecov/source_file/line.rb
|
91
|
+
- lib/simplecov/useless_results_remover.rb
|
116
92
|
- lib/simplecov/version.rb
|
117
|
-
homepage:
|
93
|
+
homepage: https://github.com/colszowka/simplecov
|
118
94
|
licenses:
|
119
95
|
- MIT
|
120
|
-
metadata:
|
96
|
+
metadata:
|
97
|
+
bug_tracker_uri: https://github.com/colszowka/simplecov/issues
|
98
|
+
changelog_uri: https://github.com/colszowka/simplecov/blob/master/CHANGELOG.md
|
99
|
+
documentation_uri: https://www.rubydoc.info/gems/simplecov/0.18.1
|
100
|
+
mailing_list_uri: https://groups.google.com/forum/#!forum/simplecov
|
101
|
+
source_code_uri: https://github.com/colszowka/simplecov/tree/v0.18.1
|
121
102
|
post_install_message:
|
122
103
|
rdoc_options: []
|
123
104
|
require_paths:
|
@@ -126,17 +107,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
107
|
requirements:
|
127
108
|
- - ">="
|
128
109
|
- !ruby/object:Gem::Version
|
129
|
-
version:
|
110
|
+
version: 2.4.0
|
130
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
112
|
requirements:
|
132
113
|
- - ">="
|
133
114
|
- !ruby/object:Gem::Version
|
134
115
|
version: '0'
|
135
116
|
requirements: []
|
136
|
-
|
137
|
-
rubygems_version: 2.6.13
|
117
|
+
rubygems_version: 3.1.2
|
138
118
|
signing_key:
|
139
119
|
specification_version: 4
|
140
|
-
summary: Code coverage for Ruby
|
141
|
-
merging of coverage across test suites
|
120
|
+
summary: Code coverage for Ruby
|
142
121
|
test_files: []
|
data/lib/simplecov/jruby_fix.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
if defined?(JRUBY_VERSION) && JRUBY_VERSION.to_f < 1.7
|
4
|
-
require "jruby"
|
5
|
-
java_import "org.jruby.ast.NodeType"
|
6
|
-
|
7
|
-
# Coverage for JRuby < 1.7.0 does not work correctly
|
8
|
-
#
|
9
|
-
# - does not distinguish lines that cannot be executed
|
10
|
-
# - does (partial) coverage for files loaded before `Coverage.start`.
|
11
|
-
# - does not expand a path like `lib/../spec` to `spec`.
|
12
|
-
#
|
13
|
-
# This monkey patches Coverage to address those issues
|
14
|
-
module Coverage
|
15
|
-
class << self
|
16
|
-
alias __broken_result__ result
|
17
|
-
|
18
|
-
def result # rubocop:disable Metrics/MethodLength
|
19
|
-
fixed = {}
|
20
|
-
__broken_result__.each do |path, executed_lines|
|
21
|
-
next unless File.file? path
|
22
|
-
|
23
|
-
covered_lines = executed_lines.dup
|
24
|
-
|
25
|
-
process = lambda do |node|
|
26
|
-
if node.node_type == NodeType::NEWLINENODE
|
27
|
-
pos = node.position
|
28
|
-
covered_lines[pos.line] ||= 0
|
29
|
-
end
|
30
|
-
node.child_nodes.each(&process)
|
31
|
-
end
|
32
|
-
|
33
|
-
process[JRuby.parse(File.read(path), path)]
|
34
|
-
|
35
|
-
if (first = covered_lines.detect { |x| x }) && first > 0
|
36
|
-
fixed[File.expand_path(path)] = covered_lines
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
fixed
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
data/lib/simplecov/railtie.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rake/testtask"
|
4
|
-
Rake::TestTask.new do |t|
|
5
|
-
t.name = "simplecov"
|
6
|
-
t.loader = :direct # uses require() which skips PWD in Ruby 1.9
|
7
|
-
t.libs.push "test", "spec", Dir.pwd
|
8
|
-
t.test_files = FileList["{test,spec}/**/*_{test,spec}.rb"]
|
9
|
-
t.ruby_opts.push "-r", "simplecov", "-e", "SimpleCov.start(:rails)".inspect
|
10
|
-
end
|
11
|
-
|
12
|
-
require "rake/clean"
|
13
|
-
CLOBBER.include "coverage"
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module SimpleCov
|
4
|
-
module RawCoverage
|
5
|
-
module_function
|
6
|
-
|
7
|
-
# Merges multiple Coverage.result hashes
|
8
|
-
def merge_results(*results)
|
9
|
-
results.reduce({}) do |result, merged|
|
10
|
-
merge_resultsets(result, merged)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
# Merges two Coverage.result hashes
|
15
|
-
def merge_resultsets(result1, result2)
|
16
|
-
(result1.keys | result2.keys).each_with_object({}) do |filename, merged|
|
17
|
-
file1 = result1[filename]
|
18
|
-
file2 = result2[filename]
|
19
|
-
merged[filename] = merge_file_coverage(file1, file2)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def merge_file_coverage(file1, file2)
|
24
|
-
return (file1 || file2).dup unless file1 && file2
|
25
|
-
|
26
|
-
file1.map.with_index do |count1, index|
|
27
|
-
count2 = file2[index]
|
28
|
-
merge_line_coverage(count1, count2)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def merge_line_coverage(count1, count2)
|
33
|
-
sum = count1.to_i + count2.to_i
|
34
|
-
if sum.zero? && (count1.nil? || count2.nil?)
|
35
|
-
nil
|
36
|
-
else
|
37
|
-
sum
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|