simplecov-console 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +63 -19
- data/VERSION +1 -1
- data/lib/simplecov-console.rb +29 -2
- data/lib/simplecov-console/output/block.rb +1 -1
- data/lib/simplecov-console/output/table.rb +1 -1
- data/simplecov-console.gemspec +3 -3
- data/test/test_simplecov-console.rb +10 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 816c658af1a3631341c32bc6de8c315c9630dabc514f2afaafce3e5d2a08c4c5
|
4
|
+
data.tar.gz: 91eb4d147fdda1bd77860ed0ee7cf407baec1882fd56075a5092850663eaec14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76945af6f21860703b3c0e5f0e78bb24d9411698fd6bc98576e03eadd2bc5d86e60600539ee081f26003431e06d35d5fde4f47b604b4880974a401954da914b1
|
7
|
+
data.tar.gz: 60a05bd402183c8797523df22d8f3c947f650f059ec18ad2a02420639c821224d007b6f2eaf57696ca0776aec359d2e6265be1591f77c38f43338ddcbadb8714
|
data/README.md
CHANGED
@@ -47,58 +47,96 @@ showing bottom (worst) 15 of 69 files
|
|
47
47
|
|
48
48
|
## Configuration
|
49
49
|
|
50
|
-
|
50
|
+
simplecov-console is configurable through environment variables and/or via Ruby
|
51
|
+
code, generally in your test helper or setup file.
|
51
52
|
|
52
|
-
|
53
|
+
### Options
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
SimpleCov::Formatter::Console.sort = 'path' # sort by file path
|
57
|
+
SimpleCov::Formatter::Console.show_covered = true # show all files in coverage report
|
58
|
+
SimpleCov::Formatter::Console.max_rows = 15 # integer
|
59
|
+
SimpleCov::Formatter::Console.max_lines = 5 # integer
|
60
|
+
SimpleCov::Formatter::Console.missing_len = 20 # integer
|
61
|
+
SimpleCov::Formatter::Console.output_style = 'block' # 'table' (default) or 'block'
|
62
|
+
SimpleCov::Formatter::Console.table_options = {:style => {:width => 200}}
|
63
|
+
```
|
64
|
+
|
65
|
+
Note that all options except `table_options` can also be set via env var using
|
66
|
+
the uppercase name, e.g., `MAX_ROWS`.
|
67
|
+
|
68
|
+
#### Disabling colorized output
|
69
|
+
|
70
|
+
Color support is active by default. To disable, export `NO_COLOR=1`:
|
53
71
|
|
54
72
|
```sh
|
55
73
|
NO_COLOR=1 rake test
|
56
74
|
```
|
57
75
|
|
58
|
-
|
76
|
+
#### Sorting the output
|
59
77
|
|
60
|
-
By default the coverage report
|
78
|
+
By default the coverage report sorts by coverage % in descending order. To
|
79
|
+
sort alphabetically by path:
|
61
80
|
|
62
81
|
```ruby
|
63
82
|
SimpleCov::Formatter::Console.sort = 'path' # sort by file path
|
64
83
|
```
|
65
84
|
|
66
|
-
|
85
|
+
#### Showing covered files
|
67
86
|
|
68
|
-
By default, fully covered files are excluded from the report.
|
87
|
+
By default, fully covered files are excluded from the report. To include them:
|
69
88
|
|
70
89
|
```ruby
|
71
90
|
SimpleCov::Formatter::Console.show_covered = true # show all files in coverage report
|
72
91
|
```
|
73
92
|
|
74
|
-
|
93
|
+
#### Maximum rows displayed
|
75
94
|
|
76
|
-
By default, a maximum of 15 files with the worst coverage are displayed in the
|
95
|
+
By default, a maximum of 15 files with the worst coverage are displayed in the
|
96
|
+
report. To override this limit:
|
77
97
|
|
78
98
|
```ruby
|
79
|
-
SimpleCov::Formatter::Console.max_rows = #
|
99
|
+
SimpleCov::Formatter::Console.max_rows = 20 # integer
|
80
100
|
```
|
81
101
|
|
82
|
-
Setting a value of `-1` or `nil` will show all
|
102
|
+
Setting a value of `-1` or `nil` (in Ruby) will show all files.
|
83
103
|
|
84
|
-
|
104
|
+
#### Maximum lines displayed
|
85
105
|
|
86
|
-
|
87
|
-
|
106
|
+
By default, all missing lines will be included for each displayed file. For
|
107
|
+
large source files with poor coverage, this may become unwieldy. To show fewer
|
108
|
+
groups of lines:
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
SimpleCov::Formatter::Console.max_lines = 5 # integer
|
112
|
+
```
|
113
|
+
|
114
|
+
#### Maximum length of missing lines
|
115
|
+
|
116
|
+
As an alternative to the above `max_lines` option, you may limit the missing
|
117
|
+
lines output by number of characters:
|
118
|
+
|
119
|
+
```ruby
|
120
|
+
SimpleCov::Formatter::Console.missing_len = 20 # integer
|
121
|
+
```
|
122
|
+
|
123
|
+
#### Table options
|
124
|
+
|
125
|
+
In some cases, you may need to pass some options to `TerminalTable.new`. For
|
126
|
+
example, if the filenames truncate so much that you can't read them, try
|
127
|
+
increasing the table width:
|
88
128
|
|
89
129
|
```ruby
|
90
130
|
SimpleCov::Formatter::Console.table_options = {:style => {:width => 200}}
|
91
|
-
SimpleCov.formatter = SimpleCov::Formatter::Console
|
92
131
|
```
|
93
132
|
|
94
|
-
|
133
|
+
#### Block output style
|
95
134
|
|
96
|
-
As an alternative to the default table output format,
|
97
|
-
|
135
|
+
As an alternative to the default table output format, a simpler block format is
|
136
|
+
also available:
|
98
137
|
|
99
138
|
```ruby
|
100
139
|
SimpleCov::Formatter::Console.output_style = 'block'
|
101
|
-
SimpleCov.formatter = SimpleCov::Formatter::Console
|
102
140
|
```
|
103
141
|
|
104
142
|
Example output:
|
@@ -133,7 +171,9 @@ coverage: 44.00% (28/50 lines)
|
|
133
171
|
|
134
172
|
### Branch Coverage Support
|
135
173
|
|
136
|
-
When branch coverage is [enabled in
|
174
|
+
When branch coverage is [enabled in
|
175
|
+
simplecov](https://github.com/simplecov-ruby/simplecov/tree/818bc2547842a90c607b4fec834320766a8686de#branch-coverage-ruby--25),
|
176
|
+
branch info will automatically be displayed in the output:
|
137
177
|
|
138
178
|
```text
|
139
179
|
COVERAGE: 78.26% -- 18/23 lines in 2 files
|
@@ -148,6 +188,10 @@ BRANCH COVERAGE: 83.33% -- 5/6 branches in 2 branches
|
|
148
188
|
|
149
189
|
## History
|
150
190
|
|
191
|
+
### 0.9 (2021.01.21)
|
192
|
+
|
193
|
+
- Added support for limiting number of lines shown
|
194
|
+
|
151
195
|
### 0.8 (2020.11.11)
|
152
196
|
|
153
197
|
- Added support for branch coverage - thanks [@robotdana!](https://github.com/robotdana) ([#19](https://github.com/chetan/simplecov-console/pull/19))
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.9.0
|
data/lib/simplecov-console.rb
CHANGED
@@ -4,7 +4,9 @@ class SimpleCov::Formatter::Console
|
|
4
4
|
|
5
5
|
VERSION = IO.read(File.expand_path("../../VERSION", __FILE__)).strip
|
6
6
|
|
7
|
-
ATTRIBUTES = [:table_options, :use_colors, :max_rows, :
|
7
|
+
ATTRIBUTES = [:table_options, :use_colors, :max_rows, :max_lines,
|
8
|
+
:missing_len, :show_covered, :sort, :output_style]
|
9
|
+
|
8
10
|
class << self
|
9
11
|
attr_accessor(*ATTRIBUTES)
|
10
12
|
end
|
@@ -16,6 +18,10 @@ class SimpleCov::Formatter::Console
|
|
16
18
|
# configure max rows from MAX_ROWS env var
|
17
19
|
SimpleCov::Formatter::Console.max_rows = ENV.fetch('MAX_ROWS', 15).to_i
|
18
20
|
|
21
|
+
# configure max lines per row and missing len
|
22
|
+
SimpleCov::Formatter::Console.max_lines = ENV.fetch('MAX_LINES', 0).to_i
|
23
|
+
SimpleCov::Formatter::Console.missing_len = ENV.fetch('MISSING_LEN', 0).to_i
|
24
|
+
|
19
25
|
# configure show_covered from SHOW_COVERED env var
|
20
26
|
SimpleCov::Formatter::Console.show_covered = ENV.fetch('SHOW_COVERED', 'false') == 'true'
|
21
27
|
|
@@ -77,7 +83,7 @@ class SimpleCov::Formatter::Console
|
|
77
83
|
files = result.files.sort_by(&:covered_percent)
|
78
84
|
end
|
79
85
|
else
|
80
|
-
files = result.files
|
86
|
+
files = result.files.to_a
|
81
87
|
end
|
82
88
|
|
83
89
|
covered_files = 0
|
@@ -117,6 +123,11 @@ class SimpleCov::Formatter::Console
|
|
117
123
|
end
|
118
124
|
end
|
119
125
|
|
126
|
+
# Group missed lines for better display
|
127
|
+
#
|
128
|
+
# @param [Array<SimpleCov::SourceFile::Line>] missed array of missed lines reported by SimpleCov
|
129
|
+
#
|
130
|
+
# @return [Array<String>] Missing groups of lines
|
120
131
|
def missed(missed_lines)
|
121
132
|
groups = {}
|
122
133
|
base = nil
|
@@ -142,9 +153,25 @@ class SimpleCov::Formatter::Console
|
|
142
153
|
end
|
143
154
|
end
|
144
155
|
|
156
|
+
if SimpleCov::Formatter::Console.max_lines > 0 then
|
157
|
+
# show at most N missing groups of lines
|
158
|
+
group_str = group_str[0, SimpleCov::Formatter::Console.max_lines] << "..."
|
159
|
+
end
|
160
|
+
|
145
161
|
group_str
|
146
162
|
end
|
147
163
|
|
164
|
+
# Truncate string to at most N chars (as defined by missing_len)
|
165
|
+
def trunc(str)
|
166
|
+
return str if str.include?("...") # already truncated, skip
|
167
|
+
|
168
|
+
len = SimpleCov::Formatter::Console.missing_len
|
169
|
+
if len > 0 && str.size > len then
|
170
|
+
str = str[0, len].gsub(/,(\s+)?$/, '') + ' ...'
|
171
|
+
end
|
172
|
+
str
|
173
|
+
end
|
174
|
+
|
148
175
|
def pct(number)
|
149
176
|
sprintf("%6.2f%%", number)
|
150
177
|
end
|
@@ -11,7 +11,7 @@ class SimpleCov::Formatter::Console
|
|
11
11
|
block << sprintf("%8.8s: %s (%d/%d lines)", 'coverage',
|
12
12
|
colorize(sprintf("%.2f%%", f.covered_percent)),
|
13
13
|
f.covered_lines.count, f.lines_of_code)
|
14
|
-
block << sprintf("%8.8s: %s", 'missed', missed(f.missed_lines).join(", "))
|
14
|
+
block << sprintf("%8.8s: %s", 'missed', trunc(missed(f.missed_lines).join(", ")))
|
15
15
|
if show_branch
|
16
16
|
block << sprintf("%8.8s: %s (%d/%d branches)", 'branches',
|
17
17
|
colorize(sprintf("%.2f%%", f.coverage_statistics[:branch].percent)),
|
data/simplecov-console.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: simplecov-console 0.
|
5
|
+
# stub: simplecov-console 0.9.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "simplecov-console".freeze
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.9.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Chetan Sarva".freeze]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2021-01-21"
|
15
15
|
s.description = "Simple console output formatter for SimpleCov".freeze
|
16
16
|
s.email = "chetan@pixelcop.net".freeze
|
17
17
|
s.extra_rdoc_files = [
|
@@ -40,6 +40,7 @@ class TestSimplecovConsole < MiniTest::Test
|
|
40
40
|
|
41
41
|
def teardown
|
42
42
|
SimpleCov::Formatter::Console.output_style = 'table'
|
43
|
+
SimpleCov::Formatter::Console.max_lines = 0
|
43
44
|
end
|
44
45
|
|
45
46
|
def test_defined
|
@@ -51,7 +52,15 @@ class TestSimplecovConsole < MiniTest::Test
|
|
51
52
|
missed_lines = [Line.new(1), Line.new(2),
|
52
53
|
Line.new(3), Line.new(5)]
|
53
54
|
expected_result = ["1-3", "5"]
|
54
|
-
assert_equal @console.missed(missed_lines)
|
55
|
+
assert_equal expected_result, @console.missed(missed_lines)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_max_missed
|
59
|
+
SimpleCov::Formatter::Console.max_lines = 1
|
60
|
+
missed_lines = [Line.new(1), Line.new(2),
|
61
|
+
Line.new(3), Line.new(5)]
|
62
|
+
expected_result = ["1-3", "..."]
|
63
|
+
assert_equal expected_result, @console.missed(missed_lines)
|
55
64
|
end
|
56
65
|
|
57
66
|
def test_table_output
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simplecov-console
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chetan Sarva
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simplecov
|