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 +4 -4
- data/lib/minitest/cc/file_coverage.rb +4 -4
- data/lib/minitest/cc/reporter.rb +3 -0
- data/lib/minitest/cc/version.rb +1 -1
- data/lib/minitest/cc.rb +28 -17
- data/lib/minitest/cc_plugin.rb +1 -3
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f0eeacbc8612187f1e09acf48af6bbe01dc408ae645fc34baff37d469791f93
|
4
|
+
data.tar.gz: 0b8dc1f33f412392782265b63919b305d1d5f9154327242d627769225aff3d42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
"
|
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
|
-
"
|
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
|
-
"
|
149
|
+
" - m: #{methods_executed}/#{methods} #{methods_percent.to_s_color}%"
|
150
150
|
end
|
151
151
|
|
152
152
|
##
|
data/lib/minitest/cc/reporter.rb
CHANGED
data/lib/minitest/cc/version.rb
CHANGED
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 =
|
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
|
-
|
48
|
-
|
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
|
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
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
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
|
96
|
+
# compose the string with resume of cc
|
86
97
|
# @return [String] String with averages
|
87
98
|
def resume
|
88
99
|
str = ''
|
data/lib/minitest/cc_plugin.rb
CHANGED
@@ -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
|
-
|
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.
|
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-
|
11
|
+
date: 2022-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: 'Plugin for minitest
|
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.
|
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.
|
50
|
+
rubygems_version: 3.2.33
|
52
51
|
signing_key:
|
53
52
|
specification_version: 4
|
54
53
|
summary: Minitest plugin, add code coverage metrics.
|