simplecov-console 0.7.2 → 0.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2102089eb7f589999a74c0f72b6f9108f1f065f61e63afe53dd58b79ae74ff34
4
- data.tar.gz: b54f26ebe5bbcc86835867cd7cd00c0d62877b4441aa3a7a47d5df969a11ffe6
3
+ metadata.gz: c972c40225a8d1890e1a1b9d9e6cda1d55c9b7ec6e07e504dbd01e24ff834a10
4
+ data.tar.gz: b3ae36a6ee1500cceb6a7ee53f3d3d56246c143836ef8cc76169f8e51dd5a87a
5
5
  SHA512:
6
- metadata.gz: 72c7fec2486cc4ec729032363d1c193e6dbb305c6159844d8816e6861c9cacb8fb0ce5994d2def99d596887b65426088f6f000e92e74fbbfce40868e511f1161
7
- data.tar.gz: c66e0da4016b7a407b65b4553ed07e0fb06ec4a3ac5731fb3921bb87cc69612195afca285163f47f21de5c96de6371d4bdd32a53c285e52619cac25698ce820f
6
+ metadata.gz: 0eefb3cffa6fe189951d47c978ae6a728fb5919a0f9eaaef62bedea886721379c470d81f9c0c57f4e5b87a0b6b14f31693a74e98c3a2fd016ea8364bed76b8b6
7
+ data.tar.gz: 7415cb6326ec3cbd80de5b34a068acffc1220f4e2c9def4b6e230adc660cf1ad8486e2febe92e1e5e0ea7eea6467622fdd26eba2a2f2e4d1a9d3361ba3674fde
@@ -0,0 +1,26 @@
1
+ # Changelog
2
+
3
+ ## 0.8 (2020.11.11)
4
+
5
+ - Added support for branch coverage - thanks [@robotdana!](https://github.com/robotdana) ([#19](https://github.com/chetan/simplecov-console/pull/19))
6
+
7
+ ## 0.7.2 (2020.03.05)
8
+
9
+ - Fix: table output include ([#17](https://github.com/chetan/simplecov-console/issues/17))
10
+
11
+ ## 0.7.1 (2020.03.05)
12
+
13
+ - Fix: block output doesn't work with frozen string literal ([#16](https://github.com/chetan/simplecov-console/issues/16))
14
+
15
+ ## 0.7 (2020.03.04)
16
+
17
+ - Added new 'block' style output option - thanks [@hpainter](https://github.com/hpainter)! ([#15](https://github.com/chetan/simplecov-console/issues/15))
18
+
19
+ ## 0.6 (2019.11.08)
20
+
21
+ - Added new config options: `sort`, `show_covered`, and `max_rows`
22
+
23
+ ## 0.5 (2019.05.24)
24
+
25
+ - Replaced `hirb` gem with `terminal-table` due to multiple warnings thrown ([#11](https://github.com/chetan/simplecov-console/issues/11))
26
+ - Support [disabling colorized](https://no-color.org/) output via `NO_COLOR` env var
data/Gemfile CHANGED
@@ -7,6 +7,6 @@ gem "ansi"
7
7
  group :development do
8
8
  gem "minitest"
9
9
  gem "yard"
10
- gem "bundler", "~> 1.2"
10
+ gem "bundler", "~> 2.1"
11
11
  gem "juwelier"
12
12
  end
data/README.md CHANGED
@@ -131,8 +131,27 @@ coverage: 44.00% (28/50 lines)
131
131
  42 file(s) with 100% coverage not shown
132
132
  ```
133
133
 
134
+ ### Branch Coverage Support
135
+
136
+ When branch coverage is [enabled in simplecov](https://github.com/simplecov-ruby/simplecov/tree/818bc2547842a90c607b4fec834320766a8686de#branch-coverage-ruby--25), branch info will automatically be displayed in the output:
137
+
138
+ ```text
139
+ COVERAGE: 78.26% -- 18/23 lines in 2 files
140
+ BRANCH COVERAGE: 83.33% -- 5/6 branches in 2 branches
141
+
142
+ +----------+-------------------------------+-------+--------+---------------+-----------------+----------+-----------------+------------------+
143
+ | coverage | file | lines | missed | missing | branch coverage | branches | branches missed | branches missing |
144
+ +----------+-------------------------------+-------+--------+---------------+-----------------+----------+-----------------+------------------+
145
+ | 72.22% | lib/simplecov-console-test.rb | 18 | 5 | 10-12, 16, 25 | 83.33% | 6 | 1 | 25[then] |
146
+ +----------+-------------------------------+-------+--------+---------------+-----------------+----------+-----------------+------------------+
147
+ ```
148
+
134
149
  ## History
135
150
 
151
+ ### 0.8 (2020.11.11)
152
+
153
+ - Added support for branch coverage - thanks [@robotdana!](https://github.com/robotdana) ([#19](https://github.com/chetan/simplecov-console/pull/19))
154
+
136
155
  ### 0.7.2 (2020.03.05)
137
156
 
138
157
  - Fix: table output include ([#17](https://github.com/chetan/simplecov-console/issues/17))
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.2
1
+ 0.8.0
@@ -36,6 +36,11 @@ class SimpleCov::Formatter::Console
36
36
  end
37
37
  end
38
38
 
39
+ def show_branch_coverage?(result)
40
+ Gem::Version.new(SimpleCov::VERSION) >= Gem::Version.new('0.18.5') &&
41
+ result.coverage_statistics[:branch]
42
+ end
43
+
39
44
  def format(result)
40
45
  include_output_style
41
46
 
@@ -51,7 +56,11 @@ class SimpleCov::Formatter::Console
51
56
  end
52
57
 
53
58
  puts
54
- puts "COVERAGE: #{colorize(pct(result))} -- #{result.covered_lines}/#{result.total_lines} lines in #{result.files.size} files"
59
+ puts "COVERAGE: #{colorize(pct(result.covered_percent))} -- #{result.covered_lines}/#{result.total_lines} lines in #{result.files.size} files"
60
+ show_branch_coverage = show_branch_coverage?(result)
61
+ if show_branch_coverage
62
+ puts "BRANCH COVERAGE: #{colorize(pct(result.coverage_statistics[:branch].percent))} -- #{result.covered_branches}/#{result.total_branches} branches in #{result.files.size} branches"
63
+ end
55
64
  puts
56
65
 
57
66
  if root.nil? then
@@ -59,7 +68,14 @@ class SimpleCov::Formatter::Console
59
68
  end
60
69
 
61
70
  if SimpleCov::Formatter::Console.sort == 'coverage'
62
- files = result.files.sort{ |a,b| a.covered_percent <=> b.covered_percent }
71
+ if show_branch_coverage
72
+ files = result.files.sort do |a,b|
73
+ (a.covered_percent <=> b.covered_percent).nonzero? ||
74
+ (a.coverage_statistics[:branch].percent <=> b.coverage_statistics[:branch].percent)
75
+ end
76
+ else
77
+ files = result.files.sort_by(&:covered_percent)
78
+ end
63
79
  else
64
80
  files = result.files
65
81
  end
@@ -68,7 +84,7 @@ class SimpleCov::Formatter::Console
68
84
 
69
85
  unless SimpleCov::Formatter::Console.show_covered
70
86
  files.select!{ |file|
71
- if file.covered_percent == 100 then
87
+ if file.covered_percent == 100 && (!show_branch_coverage || file.coverage_statistics[:branch].percent == 100) then
72
88
  covered_files += 1
73
89
  false
74
90
  else
@@ -87,7 +103,7 @@ class SimpleCov::Formatter::Console
87
103
  files = files.slice(0, max_rows)
88
104
  end
89
105
 
90
- puts output(files,root)
106
+ puts output(files, root, show_branch_coverage)
91
107
 
92
108
  if covered_files > 0 then
93
109
  puts "#{covered_files} file(s) with 100% coverage not shown"
@@ -95,6 +111,12 @@ class SimpleCov::Formatter::Console
95
111
 
96
112
  end
97
113
 
114
+ def branches_missed(missed_branches)
115
+ missed_branches.group_by(&:start_line).map do |line_number, branches|
116
+ "#{line_number}[#{branches.map(&:type).join(',')}]"
117
+ end
118
+ end
119
+
98
120
  def missed(missed_lines)
99
121
  groups = {}
100
122
  base = nil
@@ -123,8 +145,8 @@ class SimpleCov::Formatter::Console
123
145
  group_str
124
146
  end
125
147
 
126
- def pct(obj)
127
- sprintf("%6.2f%%", obj.covered_percent)
148
+ def pct(number)
149
+ sprintf("%6.2f%%", number)
128
150
  end
129
151
 
130
152
  def use_colors?
@@ -144,5 +166,4 @@ class SimpleCov::Formatter::Console
144
166
  ANSI.red { s }
145
167
  end
146
168
  end
147
-
148
169
  end
@@ -3,7 +3,7 @@ class SimpleCov::Formatter::Console
3
3
  module BlockOutput
4
4
 
5
5
  # format per-file results output as plain text blocks
6
- def output(files, root)
6
+ def output(files, root, show_branch)
7
7
  blocks = []
8
8
  files.each do |f|
9
9
  block = []
@@ -12,6 +12,12 @@ class SimpleCov::Formatter::Console
12
12
  colorize(sprintf("%.2f%%", f.covered_percent)),
13
13
  f.covered_lines.count, f.lines_of_code)
14
14
  block << sprintf("%8.8s: %s", 'missed', missed(f.missed_lines).join(", "))
15
+ if show_branch
16
+ block << sprintf("%8.8s: %s (%d/%d branches)", 'branches',
17
+ colorize(sprintf("%.2f%%", f.coverage_statistics[:branch].percent)),
18
+ (f.total_branches.count - f.missed_branches.count), f.total_branches.count)
19
+ block << sprintf("%8.8s: %s", 'missed', branches_missed(f.missed_branches).join(", "))
20
+ end
15
21
  blocks << block.join("\n")
16
22
  end
17
23
 
@@ -4,15 +4,25 @@ class SimpleCov::Formatter::Console
4
4
  module TableOutput
5
5
 
6
6
  # format per-file results output using Terminal::Table
7
- def output(files, root)
7
+ def output(files, root,show_branch)
8
8
  table = files.map do |f|
9
- [
10
- colorize(pct(f)),
9
+ row = [
10
+ colorize(pct(f.covered_percent)),
11
11
  f.filename.gsub(root + "/", ''),
12
12
  f.lines_of_code,
13
13
  f.missed_lines.count,
14
- missed(f.missed_lines).join(", ")
14
+ missed(f.missed_lines).join(", "),
15
15
  ]
16
+ if show_branch
17
+ row += [
18
+ colorize(pct(f.coverage_statistics[:branch].percent)),
19
+ f.total_branches.count,
20
+ f.missed_branches.count,
21
+ branches_missed(f.missed_branches).join(", ")
22
+ ]
23
+ end
24
+
25
+ row
16
26
  end
17
27
 
18
28
  table_options = SimpleCov::Formatter::Console.table_options || {}
@@ -21,6 +31,14 @@ class SimpleCov::Formatter::Console
21
31
  end
22
32
 
23
33
  headings = %w{ coverage file lines missed missing }
34
+ if show_branch
35
+ headings += [
36
+ 'branch coverage',
37
+ 'branches',
38
+ 'branches missed',
39
+ 'branches missing'
40
+ ]
41
+ end
24
42
 
25
43
  opts = table_options.merge({:headings => headings, :rows => table})
26
44
  Terminal::Table.new(opts)
@@ -2,24 +2,26 @@
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.7.2 ruby lib
5
+ # stub: simplecov-console 0.8.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "simplecov-console".freeze
9
- s.version = "0.7.2"
9
+ s.version = "0.8.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 = "2020-03-04"
14
+ s.date = "2020-11-11"
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 = [
18
+ "CHANGELOG.md",
18
19
  "LICENSE.txt",
19
20
  "README.md"
20
21
  ]
21
22
  s.files = [
22
23
  ".document",
24
+ "CHANGELOG.md",
23
25
  "Gemfile",
24
26
  "LICENSE.txt",
25
27
  "README.md",
@@ -34,36 +36,28 @@ Gem::Specification.new do |s|
34
36
  ]
35
37
  s.homepage = "http://github.com/chetan/simplecov-console".freeze
36
38
  s.licenses = ["MIT".freeze]
37
- s.rubygems_version = "3.0.2".freeze
39
+ s.rubygems_version = "3.1.4".freeze
38
40
  s.summary = "Simple console output formatter".freeze
39
41
 
40
42
  if s.respond_to? :specification_version then
41
43
  s.specification_version = 4
44
+ end
42
45
 
43
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
44
- s.add_runtime_dependency(%q<simplecov>.freeze, [">= 0"])
45
- s.add_runtime_dependency(%q<terminal-table>.freeze, [">= 0"])
46
- s.add_runtime_dependency(%q<ansi>.freeze, [">= 0"])
47
- s.add_development_dependency(%q<minitest>.freeze, [">= 0"])
48
- s.add_development_dependency(%q<yard>.freeze, [">= 0"])
49
- s.add_development_dependency(%q<bundler>.freeze, ["~> 1.2"])
50
- s.add_development_dependency(%q<juwelier>.freeze, [">= 0"])
51
- else
52
- s.add_dependency(%q<simplecov>.freeze, [">= 0"])
53
- s.add_dependency(%q<terminal-table>.freeze, [">= 0"])
54
- s.add_dependency(%q<ansi>.freeze, [">= 0"])
55
- s.add_dependency(%q<minitest>.freeze, [">= 0"])
56
- s.add_dependency(%q<yard>.freeze, [">= 0"])
57
- s.add_dependency(%q<bundler>.freeze, ["~> 1.2"])
58
- s.add_dependency(%q<juwelier>.freeze, [">= 0"])
59
- end
46
+ if s.respond_to? :add_runtime_dependency then
47
+ s.add_runtime_dependency(%q<simplecov>.freeze, [">= 0"])
48
+ s.add_runtime_dependency(%q<terminal-table>.freeze, [">= 0"])
49
+ s.add_runtime_dependency(%q<ansi>.freeze, [">= 0"])
50
+ s.add_development_dependency(%q<minitest>.freeze, [">= 0"])
51
+ s.add_development_dependency(%q<yard>.freeze, [">= 0"])
52
+ s.add_development_dependency(%q<bundler>.freeze, ["~> 2.1"])
53
+ s.add_development_dependency(%q<juwelier>.freeze, [">= 0"])
60
54
  else
61
55
  s.add_dependency(%q<simplecov>.freeze, [">= 0"])
62
56
  s.add_dependency(%q<terminal-table>.freeze, [">= 0"])
63
57
  s.add_dependency(%q<ansi>.freeze, [">= 0"])
64
58
  s.add_dependency(%q<minitest>.freeze, [">= 0"])
65
59
  s.add_dependency(%q<yard>.freeze, [">= 0"])
66
- s.add_dependency(%q<bundler>.freeze, ["~> 1.2"])
60
+ s.add_dependency(%q<bundler>.freeze, ["~> 2.1"])
67
61
  s.add_dependency(%q<juwelier>.freeze, [">= 0"])
68
62
  end
69
63
  end
@@ -14,10 +14,34 @@ class TestSimplecovConsole < MiniTest::Test
14
14
  :covered_percent
15
15
  )
16
16
 
17
+ CoverageStatistics = Struct.new(
18
+ :percent
19
+ )
20
+
21
+ Branch = Struct.new(
22
+ :start_line,
23
+ :type
24
+ )
25
+
26
+ SourceFileWithBranches = Struct.new(
27
+ :filename,
28
+ :lines_of_code,
29
+ :covered_lines,
30
+ :missed_lines,
31
+ :covered_percent,
32
+ :coverage_statistics,
33
+ :total_branches,
34
+ :missed_branches
35
+ )
36
+
17
37
  def setup
18
38
  @console = SimpleCov::Formatter::Console.new
19
39
  end
20
40
 
41
+ def teardown
42
+ SimpleCov::Formatter::Console.output_style = 'table'
43
+ end
44
+
21
45
  def test_defined
22
46
  assert defined?(SimpleCov::Formatter::Console)
23
47
  assert defined?(SimpleCov::Formatter::Console::VERSION)
@@ -36,7 +60,22 @@ class TestSimplecovConsole < MiniTest::Test
36
60
  files = [
37
61
  SourceFile.new('foo.rb',5,[2,3],[Line.new(1), Line.new(4), Line.new(5)],40.0)
38
62
  ]
39
- actual = @console.output(files,'/')
63
+ actual = @console.output(files,'/',false)
64
+ assert actual.is_a? Terminal::Table
65
+ assert_equal 1, actual.rows.count
66
+ end
67
+
68
+ def test_table_output_with_branches
69
+ SimpleCov::Formatter::Console.output_style = 'table'
70
+ @console.include_output_style
71
+ files = [
72
+ SourceFileWithBranches.new(
73
+ 'foo.rb',5,[2,3],[Line.new(1), Line.new(4), Line.new(5)],40.0,
74
+ {branch: CoverageStatistics.new(50.0)}, [1,2],
75
+ [Branch.new(2, :then)]
76
+ )
77
+ ]
78
+ actual = @console.output(files,'/',true)
40
79
  assert actual.is_a? Terminal::Table
41
80
  assert_equal 1, actual.rows.count
42
81
  end
@@ -50,6 +89,21 @@ class TestSimplecovConsole < MiniTest::Test
50
89
  SourceFile.new('foo.rb',5,[2,3],[Line.new(1), Line.new(4), Line.new(5)],40.0)
51
90
  ]
52
91
  expected = "\n file: foo.rb\ncoverage: 40.00% (2/5 lines)\n missed: 1, 4-5\n\n"
53
- assert_equal expected, @console.output(files,'/')
92
+ assert_equal expected, @console.output(files,'/',false)
93
+ end
94
+
95
+ def test_block_output_with_branches
96
+ SimpleCov::Formatter::Console.use_colors = false
97
+ SimpleCov::Formatter::Console.output_style = 'block'
98
+ @console.include_output_style
99
+ files = [
100
+ SourceFileWithBranches.new(
101
+ 'foo.rb',5,[2,3],[Line.new(1), Line.new(4), Line.new(5)],40.0,
102
+ {branch: CoverageStatistics.new(50.0)}, [1,2],
103
+ [Branch.new(2, :then)]
104
+ )
105
+ ]
106
+ expected = "\n file: foo.rb\ncoverage: 40.00% (2/5 lines)\n missed: 1, 4-5\nbranches: 50.00% (1/2 branches)\n missed: 2[then]\n\n"
107
+ assert_equal expected, @console.output(files,'/',true)
54
108
  end
55
109
  end
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.7.2
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chetan Sarva
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-04 00:00:00.000000000 Z
11
+ date: 2020-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simplecov
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.2'
89
+ version: '2.1'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '1.2'
96
+ version: '2.1'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: juwelier
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -113,10 +113,12 @@ email: chetan@pixelcop.net
113
113
  executables: []
114
114
  extensions: []
115
115
  extra_rdoc_files:
116
+ - CHANGELOG.md
116
117
  - LICENSE.txt
117
118
  - README.md
118
119
  files:
119
120
  - ".document"
121
+ - CHANGELOG.md
120
122
  - Gemfile
121
123
  - LICENSE.txt
122
124
  - README.md
@@ -132,7 +134,7 @@ homepage: http://github.com/chetan/simplecov-console
132
134
  licenses:
133
135
  - MIT
134
136
  metadata: {}
135
- post_install_message:
137
+ post_install_message:
136
138
  rdoc_options: []
137
139
  require_paths:
138
140
  - lib
@@ -147,8 +149,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
149
  - !ruby/object:Gem::Version
148
150
  version: '0'
149
151
  requirements: []
150
- rubygems_version: 3.0.2
151
- signing_key:
152
+ rubygems_version: 3.1.4
153
+ signing_key:
152
154
  specification_version: 4
153
155
  summary: Simple console output formatter
154
156
  test_files: []