simple_cov-formatter-terminal 0.2.4 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +45 -28
- data/README.md +10 -0
- data/lib/simple_cov/formatter/terminal/branch_coverage.rb +8 -0
- data/lib/simple_cov/formatter/terminal/config.rb +13 -9
- data/lib/simple_cov/formatter/terminal/line_printer.rb +14 -5
- data/lib/simple_cov/formatter/terminal/result_printer.rb +83 -5
- data/lib/simple_cov/formatter/terminal/spec_to_app_mapping.rb +1 -1
- data/lib/simple_cov/formatter/terminal/version.rb +1 -1
- data/lib/simple_cov/formatter/terminal.rb +7 -5
- data/simple_cov-formatter-terminal.gemspec +1 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90e4e8e76c6fbea7e49f8587759bdd94ccd6f01167b89cb80c7890987b50bdbd
|
4
|
+
data.tar.gz: af7ffaab304cfc8288dea90e273e2fa623b122c2b5ac08ff62b2bc2324fb3d72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baf0349637b76e0c9d57604dc638951433e358c69efc448ab2bad036784167c02640911948e2bcf639ca977a8c4a3413b6a1b1e8b850ed9a65084a82ab57e61a
|
7
|
+
data.tar.gz: 7fd74494139368a76d01731af52c2c1383789eb6c9f822b6e9988690a6485f8e390862fc9b491cada1e1d42bfee3348015bc15b775ade8e36e01c0c479b503b7
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,50 +1,63 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
simple_cov-formatter-terminal (0.
|
4
|
+
simple_cov-formatter-terminal (0.3.1)
|
5
5
|
activesupport (>= 7.0.4, < 8)
|
6
6
|
memo_wise (>= 1.7.0, < 2)
|
7
7
|
rouge (>= 4.0.0, < 5)
|
8
8
|
rspec-core (>= 3.11.0, < 4)
|
9
|
+
runger_config (>= 3.0.0)
|
9
10
|
simplecov (>= 0.21.2, < 1)
|
10
11
|
|
11
12
|
GEM
|
12
13
|
remote: https://rubygems.org/
|
13
14
|
specs:
|
14
|
-
activesupport (7.
|
15
|
+
activesupport (7.1.2)
|
16
|
+
base64
|
17
|
+
bigdecimal
|
15
18
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
19
|
+
connection_pool (>= 2.2.5)
|
20
|
+
drb
|
16
21
|
i18n (>= 1.6, < 2)
|
17
22
|
minitest (>= 5.1)
|
23
|
+
mutex_m
|
18
24
|
tzinfo (~> 2.0)
|
19
25
|
ast (2.4.2)
|
26
|
+
base64 (0.2.0)
|
27
|
+
bigdecimal (3.1.4)
|
20
28
|
byebug (11.1.3)
|
21
29
|
climate_control (1.2.0)
|
22
30
|
coderay (1.1.3)
|
23
|
-
colorize (0.8.1)
|
24
31
|
concurrent-ruby (1.2.2)
|
32
|
+
connection_pool (2.4.1)
|
25
33
|
diff-lcs (1.5.0)
|
26
34
|
docile (1.4.0)
|
27
|
-
|
35
|
+
drb (2.2.0)
|
36
|
+
ruby2_keywords
|
37
|
+
i18n (1.14.1)
|
28
38
|
concurrent-ruby (~> 1.0)
|
29
39
|
json (2.6.3)
|
30
|
-
|
31
|
-
|
40
|
+
language_server-protocol (3.17.0.3)
|
41
|
+
memo_wise (1.8.0)
|
32
42
|
method_source (1.0.0)
|
33
|
-
minitest (5.
|
43
|
+
minitest (5.20.0)
|
44
|
+
mutex_m (0.2.0)
|
34
45
|
parallel (1.23.0)
|
35
|
-
parser (3.2.2.
|
46
|
+
parser (3.2.2.4)
|
36
47
|
ast (~> 2.4.1)
|
48
|
+
racc
|
37
49
|
pry (0.14.2)
|
38
50
|
coderay (~> 1.1)
|
39
51
|
method_source (~> 1.0)
|
40
52
|
pry-byebug (3.10.1)
|
41
53
|
byebug (~> 11.0)
|
42
54
|
pry (>= 0.13, < 0.15)
|
55
|
+
racc (1.7.3)
|
43
56
|
rainbow (3.1.1)
|
44
|
-
rake (13.0
|
45
|
-
regexp_parser (2.8.
|
46
|
-
rexml (3.2.
|
47
|
-
rouge (4.
|
57
|
+
rake (13.1.0)
|
58
|
+
regexp_parser (2.8.2)
|
59
|
+
rexml (3.2.6)
|
60
|
+
rouge (4.2.0)
|
48
61
|
rspec (3.12.0)
|
49
62
|
rspec-core (~> 3.12.0)
|
50
63
|
rspec-expectations (~> 3.12.0)
|
@@ -54,40 +67,44 @@ GEM
|
|
54
67
|
rspec-expectations (3.12.3)
|
55
68
|
diff-lcs (>= 1.2.0, < 2.0)
|
56
69
|
rspec-support (~> 3.12.0)
|
57
|
-
rspec-mocks (3.12.
|
70
|
+
rspec-mocks (3.12.6)
|
58
71
|
diff-lcs (>= 1.2.0, < 2.0)
|
59
72
|
rspec-support (~> 3.12.0)
|
60
|
-
rspec-support (3.12.
|
61
|
-
rubocop (1.
|
73
|
+
rspec-support (3.12.1)
|
74
|
+
rubocop (1.57.2)
|
62
75
|
json (~> 2.3)
|
76
|
+
language_server-protocol (>= 3.17.0)
|
63
77
|
parallel (~> 1.10)
|
64
|
-
parser (>= 3.2.
|
78
|
+
parser (>= 3.2.2.4)
|
65
79
|
rainbow (>= 2.2.2, < 4.0)
|
66
80
|
regexp_parser (>= 1.8, < 3.0)
|
67
81
|
rexml (>= 3.2.5, < 4.0)
|
68
|
-
rubocop-ast (>= 1.28.
|
82
|
+
rubocop-ast (>= 1.28.1, < 2.0)
|
69
83
|
ruby-progressbar (~> 1.7)
|
70
84
|
unicode-display_width (>= 2.4.0, < 3.0)
|
71
|
-
rubocop-ast (1.
|
85
|
+
rubocop-ast (1.30.0)
|
72
86
|
parser (>= 3.2.1.0)
|
73
|
-
rubocop-capybara (2.
|
87
|
+
rubocop-capybara (2.19.0)
|
74
88
|
rubocop (~> 1.41)
|
75
|
-
rubocop-factory_bot (2.
|
89
|
+
rubocop-factory_bot (2.24.0)
|
76
90
|
rubocop (~> 1.33)
|
77
|
-
rubocop-performance (1.
|
91
|
+
rubocop-performance (1.19.1)
|
78
92
|
rubocop (>= 1.7.0, < 2.0)
|
79
93
|
rubocop-ast (>= 0.4.0)
|
80
|
-
rubocop-rspec (2.
|
81
|
-
rubocop (~> 1.
|
94
|
+
rubocop-rspec (2.25.0)
|
95
|
+
rubocop (~> 1.40)
|
82
96
|
rubocop-capybara (~> 2.17)
|
83
97
|
rubocop-factory_bot (~> 2.22)
|
84
98
|
ruby-progressbar (1.13.0)
|
85
|
-
|
99
|
+
ruby2_keywords (0.0.5)
|
100
|
+
runger_config (4.0.0)
|
101
|
+
activesupport (>= 7.1.2)
|
102
|
+
runger_release_assistant (0.5.0)
|
86
103
|
activesupport (>= 6, < 8)
|
87
|
-
|
88
|
-
|
104
|
+
memo_wise (>= 1.7, < 2)
|
105
|
+
rainbow (>= 3.0, < 4)
|
89
106
|
slop (~> 4.8)
|
90
|
-
runger_style (0.
|
107
|
+
runger_style (0.5.1)
|
91
108
|
rubocop (>= 1.38.0, < 2)
|
92
109
|
simplecov (0.22.0)
|
93
110
|
docile (~> 1.1)
|
@@ -101,7 +118,7 @@ GEM
|
|
101
118
|
slop (4.10.1)
|
102
119
|
tzinfo (2.0.6)
|
103
120
|
concurrent-ruby (~> 1.0)
|
104
|
-
unicode-display_width (2.
|
121
|
+
unicode-display_width (2.5.0)
|
105
122
|
|
106
123
|
PLATFORMS
|
107
124
|
ruby
|
data/README.md
CHANGED
@@ -37,6 +37,16 @@ SimpleCov.start
|
|
37
37
|
spec file (e.g. `bin/rspec spec/models/user_spec.rb`) and not when multiple specs are executed (e.g.
|
38
38
|
when simply running `bin/rspec` without any argument).
|
39
39
|
|
40
|
+
## Which lines to print
|
41
|
+
|
42
|
+
By default, only uncovered lines will be printed.
|
43
|
+
|
44
|
+
If you would like to print all lines, add this to your `spec_helper.rb` file:
|
45
|
+
|
46
|
+
```rb
|
47
|
+
SimpleCov::Formatter::Terminal.config.lines_to_print = :all
|
48
|
+
```
|
49
|
+
|
40
50
|
### Modifying the `spec_to_app_file_map`
|
41
51
|
|
42
52
|
`SimpleCov::Formatter::Terminal` has a default hash that is used to map spec files to their
|
@@ -1,21 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '
|
3
|
+
require_relative 'spec_to_app_mapping'
|
4
4
|
require 'memo_wise'
|
5
5
|
|
6
|
-
class SimpleCov::Formatter::Terminal::Config
|
6
|
+
class SimpleCov::Formatter::Terminal::Config < Runger::Config
|
7
7
|
prepend MemoWise
|
8
8
|
include SimpleCov::Formatter::Terminal::SpecToAppMapping
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
@spec_to_app_file_map =
|
14
|
-
SimpleCov::Formatter::Terminal::SpecToAppMapping.default_spec_to_app_map
|
15
|
-
@unmappable_spec_regexes =
|
16
|
-
SimpleCov::Formatter::Terminal::SpecToAppMapping::DEFAULT_UNMAPPABLE_SPEC_REGEXES
|
10
|
+
module LinesToPrint
|
11
|
+
ALL = :all
|
12
|
+
UNCOVERED = :uncovered
|
17
13
|
end
|
18
14
|
|
15
|
+
attr_config(
|
16
|
+
lines_to_print: LinesToPrint::UNCOVERED,
|
17
|
+
spec_to_app_file_map:
|
18
|
+
SimpleCov::Formatter::Terminal::SpecToAppMapping.default_spec_to_app_map,
|
19
|
+
unmappable_spec_regexes:
|
20
|
+
SimpleCov::Formatter::Terminal::SpecToAppMapping::DEFAULT_UNMAPPABLE_SPEC_REGEXES,
|
21
|
+
)
|
22
|
+
|
19
23
|
memo_wise \
|
20
24
|
def write_target_info_file?
|
21
25
|
ENV.fetch('SIMPLECOV_WRITE_TARGET_TO_FILE', nil) == '1'
|
@@ -7,7 +7,7 @@ class SimpleCov::Formatter::Terminal::LinePrinter
|
|
7
7
|
include SimpleCov::Formatter::Terminal::BranchCoverage
|
8
8
|
include SimpleCov::Formatter::Terminal::ColorPrinting
|
9
9
|
|
10
|
-
def initialize(targeted_application_file)
|
10
|
+
def initialize(targeted_application_file = nil)
|
11
11
|
@targeted_application_file = targeted_application_file
|
12
12
|
end
|
13
13
|
|
@@ -30,18 +30,27 @@ class SimpleCov::Formatter::Terminal::LinePrinter
|
|
30
30
|
end
|
31
31
|
|
32
32
|
# rubocop:disable Style/StringConcatenation
|
33
|
-
def numbered_line_output(line_number, color, source_code, missed_branch_info = nil)
|
33
|
+
def numbered_line_output(line_number, color, source_code = '', missed_branch_info = nil)
|
34
34
|
colored_space =
|
35
35
|
case color
|
36
36
|
when :red_on_yellow, :white_on_red then color(' ', color)
|
37
37
|
else color(' ', :white_on_green)
|
38
38
|
end
|
39
39
|
|
40
|
-
|
40
|
+
line_number_width =
|
41
41
|
if SimpleCov::Formatter::Terminal.config.write_target_info_file?
|
42
|
-
|
42
|
+
6
|
43
|
+
else
|
44
|
+
3
|
45
|
+
end
|
46
|
+
|
47
|
+
line_number_string =
|
48
|
+
if line_number.blank?
|
49
|
+
' ' * line_number_width
|
50
|
+
elsif SimpleCov::Formatter::Terminal.config.write_target_info_file?
|
51
|
+
":::#{line_number}".rjust(line_number_width, ' ')
|
43
52
|
else
|
44
|
-
line_number.to_s.rjust(
|
53
|
+
line_number.to_s.rjust(line_number_width, ' ')
|
45
54
|
end
|
46
55
|
|
47
56
|
output =
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '
|
4
|
-
require_relative '
|
5
|
-
require_relative '
|
6
|
-
require_relative '
|
3
|
+
require_relative 'branch_coverage'
|
4
|
+
require_relative 'color_printing'
|
5
|
+
require_relative 'line_printer'
|
6
|
+
require_relative 'target_file_writer'
|
7
7
|
|
8
8
|
class SimpleCov::Formatter::Terminal::ResultPrinter
|
9
9
|
extend Forwardable
|
@@ -48,14 +48,32 @@ class SimpleCov::Formatter::Terminal::ResultPrinter
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def print_coverage_details(sourcefile)
|
51
|
+
@sourcefile = sourcefile
|
52
|
+
|
51
53
|
if SimpleCov::Formatter::Terminal.config.write_target_info_file?
|
52
54
|
target_file_writer.write_target_info_file
|
53
55
|
end
|
54
56
|
|
55
57
|
puts("---- Coverage for #{targeted_application_file} ".ljust(80, '-').rstrip)
|
58
|
+
|
59
|
+
skipped_lines = []
|
56
60
|
sourcefile.lines.each do |line|
|
57
|
-
|
61
|
+
if print_line?(line.line_number)
|
62
|
+
if skipped_lines.any?
|
63
|
+
print_skipped_lines(skipped_lines)
|
64
|
+
end
|
65
|
+
|
66
|
+
puts(line_printer.colored_line(line, sourcefile))
|
67
|
+
skipped_lines = []
|
68
|
+
else
|
69
|
+
skipped_lines << line.line_number
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
if skipped_lines.any?
|
74
|
+
print_skipped_lines(skipped_lines)
|
58
75
|
end
|
76
|
+
|
59
77
|
puts(<<~LOG.squish)
|
60
78
|
----
|
61
79
|
Line coverage: #{colorized_coverage(sourcefile.covered_percent)}
|
@@ -65,6 +83,20 @@ class SimpleCov::Formatter::Terminal::ResultPrinter
|
|
65
83
|
LOG
|
66
84
|
end
|
67
85
|
|
86
|
+
def print_skipped_lines(skipped_lines)
|
87
|
+
divider = ' -' * 40
|
88
|
+
|
89
|
+
puts(line_printer.numbered_line_output(nil, :white, divider))
|
90
|
+
puts(
|
91
|
+
line_printer.numbered_line_output(
|
92
|
+
nil,
|
93
|
+
:white,
|
94
|
+
"#{skipped_lines.size} covered line(s) omitted".center(80, ' '),
|
95
|
+
),
|
96
|
+
)
|
97
|
+
puts(line_printer.numbered_line_output(nil, :white, divider))
|
98
|
+
end
|
99
|
+
|
68
100
|
def print_no_coverage_info_found
|
69
101
|
puts(<<~LOG.squish)
|
70
102
|
No code coverage info was found for "#{targeted_application_file}". Try stopping and
|
@@ -120,6 +152,52 @@ class SimpleCov::Formatter::Terminal::ResultPrinter
|
|
120
152
|
end
|
121
153
|
end
|
122
154
|
|
155
|
+
def print_line?(line_number)
|
156
|
+
line_numbers_to_print.include?(line_number)
|
157
|
+
end
|
158
|
+
|
159
|
+
def sourcefile
|
160
|
+
@sourcefile ||= @result.files.find { _1.filename.end_with?(targeted_application_file) }
|
161
|
+
end
|
162
|
+
|
163
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
164
|
+
memo_wise \
|
165
|
+
def line_numbers_to_print
|
166
|
+
max_line_number = sourcefile.lines.map(&:line_number).max
|
167
|
+
|
168
|
+
begin
|
169
|
+
case SimpleCov::Formatter::Terminal.config.lines_to_print.to_sym
|
170
|
+
in SimpleCov::Formatter::Terminal::Config::LinesToPrint::ALL
|
171
|
+
(1..max_line_number).to_a
|
172
|
+
in SimpleCov::Formatter::Terminal::Config::LinesToPrint::UNCOVERED
|
173
|
+
line_numbers_to_print = []
|
174
|
+
|
175
|
+
sourcefile.lines.each do |line|
|
176
|
+
if (
|
177
|
+
line.coverage.nil? || (
|
178
|
+
(line.coverage > 0) &&
|
179
|
+
!line_numbers_with_missing_branches(sourcefile).include?(line.line_number)
|
180
|
+
)
|
181
|
+
)
|
182
|
+
next
|
183
|
+
end
|
184
|
+
|
185
|
+
line_number = line.line_number
|
186
|
+
contextualized_line_numbers =
|
187
|
+
((line_number - 2)..(line_number + 2)).
|
188
|
+
to_a.
|
189
|
+
select do |context_line_number|
|
190
|
+
context_line_number.positive? && context_line_number <= max_line_number
|
191
|
+
end
|
192
|
+
line_numbers_to_print += contextualized_line_numbers
|
193
|
+
end
|
194
|
+
|
195
|
+
line_numbers_to_print
|
196
|
+
end
|
197
|
+
end.to_set
|
198
|
+
end
|
199
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
200
|
+
|
123
201
|
memo_wise \
|
124
202
|
def line_printer
|
125
203
|
SimpleCov::Formatter::Terminal::LinePrinter.new(targeted_application_file)
|
@@ -2,18 +2,20 @@
|
|
2
2
|
|
3
3
|
class SimpleCov::Formatter::Terminal ; end # rubocop:disable Lint/EmptyClass
|
4
4
|
|
5
|
-
require_relative 'terminal/config'
|
6
|
-
require_relative 'terminal/file_determiner'
|
7
|
-
require_relative 'terminal/r_spec_integration'
|
8
|
-
require_relative 'terminal/result_printer'
|
9
|
-
require_relative 'terminal/version'
|
10
5
|
require 'active_support/core_ext/object/blank'
|
11
6
|
require 'active_support/core_ext/string/filters'
|
12
7
|
require 'memo_wise'
|
13
8
|
require 'rouge'
|
14
9
|
require 'rspec/core'
|
10
|
+
require 'runger_config'
|
15
11
|
require 'simplecov'
|
16
12
|
|
13
|
+
require_relative 'terminal/config'
|
14
|
+
require_relative 'terminal/file_determiner'
|
15
|
+
require_relative 'terminal/r_spec_integration'
|
16
|
+
require_relative 'terminal/result_printer'
|
17
|
+
require_relative 'terminal/version'
|
18
|
+
|
17
19
|
class SimpleCov::Formatter::Terminal
|
18
20
|
extend Forwardable
|
19
21
|
prepend MemoWise
|
@@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_dependency('memo_wise', '>= 1.7.0', '< 2')
|
37
37
|
spec.add_dependency('rouge', '>= 4.0.0', '< 5')
|
38
38
|
spec.add_dependency('rspec-core', '>= 3.11.0', '< 4')
|
39
|
+
spec.add_dependency('runger_config', '>= 3.0.0')
|
39
40
|
spec.add_dependency('simplecov', '>= 0.21.2', '< 1')
|
40
41
|
|
41
42
|
# For more information and examples about making a new gem, check out our
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_cov-formatter-terminal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Runger
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -90,6 +90,20 @@ dependencies:
|
|
90
90
|
- - "<"
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: '4'
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: runger_config
|
95
|
+
requirement: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 3.0.0
|
100
|
+
type: :runtime
|
101
|
+
prerelease: false
|
102
|
+
version_requirements: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 3.0.0
|
93
107
|
- !ruby/object:Gem::Dependency
|
94
108
|
name: simplecov
|
95
109
|
requirement: !ruby/object:Gem::Requirement
|
@@ -162,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
176
|
- !ruby/object:Gem::Version
|
163
177
|
version: '0'
|
164
178
|
requirements: []
|
165
|
-
rubygems_version: 3.4.
|
179
|
+
rubygems_version: 3.4.22
|
166
180
|
signing_key:
|
167
181
|
specification_version: 4
|
168
182
|
summary: Print detailed code coverage info to the terminal
|