minitest-cc 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 848f6762978bb5db1d4bfb03e13ff466a9fc7111ee1525f5825a558863b026ae
4
- data.tar.gz: fa59d3d0887831482fb6ea9ce737f841bd326d42808d3c3b89556f914657ba8d
3
+ metadata.gz: 5f0eeacbc8612187f1e09acf48af6bbe01dc408ae645fc34baff37d469791f93
4
+ data.tar.gz: 0b8dc1f33f412392782265b63919b305d1d5f9154327242d627769225aff3d42
5
5
  SHA512:
6
- metadata.gz: ff8cc42c16e7b0baad675f64f275a3435b8f990d43dff8ccca0288888625c3480b4e20584a2dcbb58f231c996ecefcd98609431a00eeaafdeba863afab8c9b96
7
- data.tar.gz: 469ca5c033d2f4075207cd070758592b2d43248bf212eb0cd395b824b30c67b1a994a13f02d7e0078fb7e4ff12416c9ac8bcb87c1b98231fd37cbb102e844f66
6
+ metadata.gz: 5807504cf8912e3253123e166fd961cbdceb403d9e4cf7ddaf3a03620b2355070358ddf678b7d75fc8fba676ea5fa8d6072daf7cea3c91127ab7f1c4467477cb
7
+ data.tar.gz: 5e825e40992f750669825a5d823f5fcc68ceec3aa420c4d37b813c9b45f6b16062f80eb7e1e5c741785bfc5094cddcc7cd57a4f2e86c3ca50fb09e2331435bec
@@ -114,7 +114,7 @@ module Minitest
114
114
  # @return [String] contains the information ready to print
115
115
  #
116
116
  def to_s
117
- return "#{relative_path} : Not executed during the tests." unless tested
117
+ return "#{relative_path} : Not executed or tracked by cov." unless tested
118
118
 
119
119
  "#{relative_path}:\n" + to_s_lines + to_s_branches + to_s_methods
120
120
  end
@@ -126,7 +126,7 @@ module Minitest
126
126
  def to_s_lines
127
127
  return '' unless lines
128
128
 
129
- "\tlines: #{lines_executed}/#{lines} #{lines_percent.to_s_color}%"
129
+ " - l: #{lines_executed}/#{lines} #{lines_percent.to_s_color}%"
130
130
  end
131
131
 
132
132
  ##
@@ -136,7 +136,7 @@ module Minitest
136
136
  def to_s_branches
137
137
  return '' unless branches
138
138
 
139
- "\tbranches: #{branches_executed}/#{branches} #{branches_percent.to_s_color}%"
139
+ " - b: #{branches_executed}/#{branches} #{branches_percent.to_s_color}%"
140
140
  end
141
141
 
142
142
  ##
@@ -146,7 +146,7 @@ module Minitest
146
146
  def to_s_methods
147
147
  return '' unless methods
148
148
 
149
- "\tmethods: #{methods_executed}/#{methods} #{methods_percent.to_s_color}%"
149
+ " - m: #{methods_executed}/#{methods} #{methods_percent.to_s_color}%"
150
150
  end
151
151
 
152
152
  ##
@@ -7,7 +7,10 @@ module Minitest
7
7
  ##
8
8
  # Executed in the final of the minitest run
9
9
  def report
10
+ Cc.peek_result
10
11
  Cc.summary
12
+ rescue StandardError => e
13
+ puts "\n\n[!] cc extension has problem for generate the report: #{e}"
11
14
  end
12
15
  end
13
16
  end
@@ -3,6 +3,6 @@
3
3
  module Minitest
4
4
  module Cc
5
5
  # plugin version
6
- VERSION = '0.1.2'
6
+ VERSION = '0.2.0'
7
7
  end
8
8
  end
data/lib/minitest/cc.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'coverage'
3
4
  require 'minitest'
4
5
 
5
6
  require_relative 'cc/version'
@@ -11,6 +12,8 @@ module Minitest
11
12
  # Main module of the plugin
12
13
  # @author Andres
13
14
  module Cc
15
+ MODES = %i[lines branches methods].freeze
16
+
14
17
  @results = []
15
18
  @files = FileArray.new
16
19
 
@@ -32,38 +35,46 @@ module Minitest
32
35
  # @return [Array] mode of the coverage, this array could contain:
33
36
  # :lines, :branches, :methods
34
37
  cattr_accessor :coverage_mode
35
- self.coverage_mode = %i[
36
- lines
37
- branches
38
- methods
39
- ]
38
+ self.coverage_mode = MODES
40
39
 
41
40
  class << self
42
41
  ##
43
42
  # Start the coverage process
44
43
  # @see https://runebook.dev/en/docs/ruby/coverage Coverage blog post explaining the use
45
44
  # @see https://ruby-doc.org/stdlib-2.7.6/libdoc/coverage/rdoc/Coverage.html Documentation of the module
45
+ # @deprecated Use {#self.start(*args)} instead.
46
46
  def start_coverage
47
- require 'coverage'
48
- Coverage.start(coverage_mode.collect { |m| [m, true] }.to_h)
47
+ Coverage.start(@coverage_mode.collect { |m| [m, true] }.to_h)
48
+ end
49
+
50
+ ##
51
+ # start coverage process
52
+ # this method recive the arguments direct and not depend on set coverage mode before start
53
+ # @see https://runebook.dev/en/docs/ruby/coverage Coverage blog post explaining the use
54
+ # @see https://ruby-doc.org/stdlib-2.7.6/libdoc/coverage/rdoc/Coverage.html Documentation of the module
55
+ #
56
+ def start(*args)
57
+ @coverage_mode = args.collect(&:to_sym).select { |a| MODES.include? a } unless args.empty?
58
+ Coverage.start(@coverage_mode.collect { |m| [m, true] }.to_h)
49
59
  end
50
60
 
51
61
  ##
52
- # Print the results after the runs
62
+ # Print results after the runs
63
+ #
53
64
  def summary
54
- @results = Coverage.peek_result
55
- list_files
56
65
  puts "\n\n# Coverage:\n\n"
57
- @files.each { |f| puts f.to_s } if cc_mode == :per_file
58
- puts resume if cc_mode == :resume
59
- puts
60
- rescue NameError
61
- puts "\n\n[!] cc extension is installed but was not started."
66
+ case cc_mode
67
+ when :per_file
68
+ @files.each { |f| puts f.to_s }
69
+ else
70
+ puts resume
71
+ end
62
72
  end
63
73
 
64
74
  ##
65
75
  # This method populate the FileArray variable with results
66
- def list_files
76
+ def peek_result
77
+ @results = Coverage.result
67
78
  Dir.glob(tracked_files.each { |f| File.expand_path(f) }).each do |d|
68
79
  full_path = File.expand_path(d)
69
80
  @files << FileCoverage.new(full_path, d, result_for_file(full_path))
@@ -82,7 +93,7 @@ module Minitest
82
93
  end
83
94
 
84
95
  ##
85
- # compose the string with resume of averages
96
+ # compose the string with resume of cc
86
97
  # @return [String] String with averages
87
98
  def resume
88
99
  str = ''
@@ -5,9 +5,7 @@ require 'minitest/cc'
5
5
  # Minitest module
6
6
  module Minitest
7
7
  # Init method called from minitest
8
- # it start the plugin
9
8
  def self.plugin_cc_init(_options)
10
- # insert ower reporter to minitest reporters
11
- reporter << Minitest::Cc::Reporter.new
9
+ reporter << Minitest::Cc::Reporter.new if Coverage.running?
12
10
  end
13
11
  end
metadata CHANGED
@@ -1,17 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-cc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - a-chacon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-01 00:00:00.000000000 Z
11
+ date: 2022-07-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: 'Plugin for minitest, provide a minimal information of code coverage
14
- to your test output. '
13
+ description: 'Plugin for minitest. It provides minimal information about code coverage. '
15
14
  email:
16
15
  - andres.ch@protonmail.com
17
16
  executables: []
@@ -41,14 +40,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
41
40
  requirements:
42
41
  - - ">="
43
42
  - !ruby/object:Gem::Version
44
- version: 2.5.3
43
+ version: 2.5.0
45
44
  required_rubygems_version: !ruby/object:Gem::Requirement
46
45
  requirements:
47
46
  - - ">="
48
47
  - !ruby/object:Gem::Version
49
48
  version: '0'
50
49
  requirements: []
51
- rubygems_version: 3.2.22
50
+ rubygems_version: 3.2.33
52
51
  signing_key:
53
52
  specification_version: 4
54
53
  summary: Minitest plugin, add code coverage metrics.