covered 0.14.2 → 0.15.2
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
- checksums.yaml.gz.sig +3 -3
- data/bake/covered/validate.rb +26 -0
- data/lib/covered/cache.rb +65 -0
- data/lib/covered/capture.rb +0 -29
- data/lib/covered/persist.rb +30 -8
- data/lib/covered/policy/default.rb +21 -17
- data/lib/covered/policy.rb +7 -0
- data/lib/covered/statistics.rb +9 -0
- data/lib/covered/version.rb +1 -1
- data/lib/covered/wrapper.rb +7 -0
- data.tar.gz.sig +0 -0
- metadata +4 -12
- metadata.gz.sig +0 -0
- data/.github/workflows/development.yml +0 -45
- data/.github/workflows/documentation.yml +0 -34
- data/examples/coverage/covered.rb +0 -11
- data/examples/coverage/erb/coverage.rb +0 -21
- data/examples/coverage/erb/template.erb +0 -7
- data/examples/coverage/parser.rb +0 -23
- data/examples/coverage/simplecov.rb +0 -7
- data/examples/coverage/test.rb +0 -16
- data/examples/coverage/tracepoint.rb +0 -8
- data/media/example.png +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 112c85633150c4f05435b29a2867a51a711a9f216fdbe850c0356b0371ab4e49
|
4
|
+
data.tar.gz: 2efa0d7a7d07ca3125237c55b4e1d34fd4835e5f9d963344f1c7b4b9405d37eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 054c6dca966431d180da1ff4e98afadea19400ec2ea28a2f7b4a3096ae6affdcc0082f939bb612cc3440861b4e1bd55e1b88dc03b7a93205ec19d2e3935fb5fd
|
7
|
+
data.tar.gz: f9ea6aacbb0993749c4e808f09c8b6bcccfa5d7f6c640fcdf83a79a7432fffd893008ccb6aed9314801f1c79446dcb82bdfc919e55c1564ca5691920a6371073
|
checksums.yaml.gz.sig
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
q�dq������y��7�'��e�&ep)0��b�?[��WØjK%�-� a�I�GS�`��fK�|C���5�[��/�^i��V�#r���I��}���y����
|
2
|
+
�L���{�.�}���{��.0R���+�p�?
|
3
|
+
$��Y��g��:��4�����%G�k��Ћ�%�2��a�B��2
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
def initialize(context)
|
3
|
+
super
|
4
|
+
|
5
|
+
require_relative '../../lib/covered/policy/default'
|
6
|
+
end
|
7
|
+
|
8
|
+
# Validate the coverage of multiple test runs.
|
9
|
+
# @parameter paths [Array(String)] The coverage database paths.
|
10
|
+
# @parameter minumum [Float] The minimum required coverage in order to pass.
|
11
|
+
def validate(paths: nil, minimum: 1.0)
|
12
|
+
paths&.each do |path|
|
13
|
+
# It would be nice to have a better algorithm here than just ignoring mtime - perhaps using checksums?
|
14
|
+
Covered::Persist.new($covered.output, path).load!(ignore_mtime: true)
|
15
|
+
end
|
16
|
+
|
17
|
+
$covered.flush
|
18
|
+
|
19
|
+
statistics = Covered::Statistics.new
|
20
|
+
|
21
|
+
$covered.each do |coverage|
|
22
|
+
statistics << coverage
|
23
|
+
end
|
24
|
+
|
25
|
+
statistics.validate!(minimum)
|
26
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
require_relative 'wrapper'
|
22
|
+
|
23
|
+
require 'coverage'
|
24
|
+
|
25
|
+
module Covered
|
26
|
+
class Cache < Wrapper
|
27
|
+
def initialize(output)
|
28
|
+
super(output)
|
29
|
+
|
30
|
+
@marks = nil
|
31
|
+
end
|
32
|
+
|
33
|
+
def mark(path, lineno, count = 1)
|
34
|
+
if @marks
|
35
|
+
@marks << path << lineno << count
|
36
|
+
else
|
37
|
+
super
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def enable
|
42
|
+
@marks = []
|
43
|
+
|
44
|
+
super
|
45
|
+
end
|
46
|
+
|
47
|
+
def flush
|
48
|
+
if @marks
|
49
|
+
@marks.each_slice(3) do |path, lineno, count|
|
50
|
+
@output.mark(path, lineno, count)
|
51
|
+
end
|
52
|
+
|
53
|
+
@marks = nil
|
54
|
+
end
|
55
|
+
|
56
|
+
super
|
57
|
+
end
|
58
|
+
|
59
|
+
def disable
|
60
|
+
super
|
61
|
+
|
62
|
+
flush
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/lib/covered/capture.rb
CHANGED
@@ -59,35 +59,6 @@ module Covered
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
class Cache < Wrapper
|
63
|
-
def initialize(output)
|
64
|
-
super(output)
|
65
|
-
@marks = []
|
66
|
-
end
|
67
|
-
|
68
|
-
def mark(path, lineno, count = 1)
|
69
|
-
@marks << path << lineno << count
|
70
|
-
end
|
71
|
-
|
72
|
-
def enable
|
73
|
-
super
|
74
|
-
end
|
75
|
-
|
76
|
-
def flush
|
77
|
-
@marks.each_slice(3) do |path, lineno, count|
|
78
|
-
@output.mark(path, lineno, count)
|
79
|
-
end
|
80
|
-
|
81
|
-
@marks.clear
|
82
|
-
end
|
83
|
-
|
84
|
-
def disable
|
85
|
-
super
|
86
|
-
|
87
|
-
flush
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
62
|
# class Capture < Wrapper
|
92
63
|
# def enable
|
93
64
|
# super
|
data/lib/covered/persist.rb
CHANGED
@@ -23,6 +23,7 @@ require_relative 'wrapper'
|
|
23
23
|
require 'msgpack'
|
24
24
|
require 'time'
|
25
25
|
require 'set'
|
26
|
+
require 'console'
|
26
27
|
|
27
28
|
module Covered
|
28
29
|
class Persist < Wrapper
|
@@ -32,18 +33,27 @@ module Covered
|
|
32
33
|
super(output)
|
33
34
|
|
34
35
|
@path = path
|
35
|
-
|
36
36
|
@touched = Set.new
|
37
37
|
end
|
38
38
|
|
39
|
-
def apply(record)
|
39
|
+
def apply(record, ignore_mtime: false)
|
40
40
|
# The file must still exist:
|
41
41
|
return unless path = expand_path(record[:path])
|
42
|
-
|
42
|
+
|
43
|
+
unless File.exist?(path)
|
44
|
+
Console.logger.debug(self) {"Ignoring coverage, path #{path} does not exist!"}
|
45
|
+
return
|
46
|
+
end
|
43
47
|
|
44
48
|
# If the file has been modified since... we can't use the coverage.
|
45
49
|
return unless mtime = record[:mtime]
|
46
|
-
|
50
|
+
|
51
|
+
unless ignore_mtime
|
52
|
+
if File.mtime(path).to_f > record[:mtime]
|
53
|
+
Console.logger.debug(self) {"Ignoring coverage, path #{path} has been updated: #{File.mtime(path).to_f} > #{record[:mtime]}!"}
|
54
|
+
return
|
55
|
+
end
|
56
|
+
end
|
47
57
|
|
48
58
|
record[:coverage].each_with_index do |count, index|
|
49
59
|
@output.mark(path, index, count) if count
|
@@ -59,22 +69,28 @@ module Covered
|
|
59
69
|
}
|
60
70
|
end
|
61
71
|
|
62
|
-
def load!(
|
72
|
+
def load!(**options)
|
63
73
|
return unless File.exist?(@path)
|
64
74
|
|
65
75
|
# Load existing coverage information and mark all files:
|
66
76
|
File.open(@path, "rb") do |file|
|
67
77
|
file.flock(File::LOCK_SH)
|
68
78
|
|
69
|
-
|
79
|
+
Console.logger.debug(self) {"Loading from #{@path} with #{options}..."}
|
80
|
+
|
81
|
+
make_unpacker(file).each do |record|
|
82
|
+
self.apply(record, **options)
|
83
|
+
end
|
70
84
|
end
|
71
85
|
end
|
72
86
|
|
73
|
-
def save!
|
87
|
+
def save!
|
74
88
|
# Dump all coverage:
|
75
89
|
File.open(@path, "wb") do |file|
|
76
90
|
file.flock(File::LOCK_EX)
|
77
91
|
|
92
|
+
Console.logger.debug(self) {"Saving to #{@path}..."}
|
93
|
+
|
78
94
|
packer = make_packer(file)
|
79
95
|
|
80
96
|
self.each do |coverage|
|
@@ -87,7 +103,7 @@ module Covered
|
|
87
103
|
|
88
104
|
def mark(file, line, count)
|
89
105
|
@touched << file
|
90
|
-
|
106
|
+
|
91
107
|
super
|
92
108
|
end
|
93
109
|
|
@@ -97,6 +113,12 @@ module Covered
|
|
97
113
|
load!
|
98
114
|
end
|
99
115
|
|
116
|
+
def flush
|
117
|
+
load!
|
118
|
+
|
119
|
+
super
|
120
|
+
end
|
121
|
+
|
100
122
|
def disable
|
101
123
|
super
|
102
124
|
|
@@ -20,21 +20,25 @@
|
|
20
20
|
|
21
21
|
require_relative '../policy'
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
23
|
+
if File.exist?("config/coverage.rb")
|
24
|
+
load("config/coverage.rb")
|
25
|
+
else
|
26
|
+
$covered = Covered.policy do
|
27
|
+
cache!
|
28
|
+
|
29
|
+
# Only files in the root would be tracked:
|
30
|
+
root(Dir.pwd)
|
31
|
+
|
32
|
+
# We will ignore any files in the test or spec directory:
|
33
|
+
skip(/^.*\/(test|spec|vendor)\//)
|
34
|
+
|
35
|
+
# We will include all files under lib, even if they aren't loaded:
|
36
|
+
include("lib/**/*.rb")
|
37
|
+
|
38
|
+
persist!
|
39
|
+
|
40
|
+
source
|
41
|
+
|
42
|
+
reports!
|
43
|
+
end
|
40
44
|
end
|
data/lib/covered/policy.rb
CHANGED
@@ -22,6 +22,7 @@ require_relative "summary"
|
|
22
22
|
require_relative "files"
|
23
23
|
require_relative "source"
|
24
24
|
require_relative "capture"
|
25
|
+
require_relative "cache"
|
25
26
|
require_relative "persist"
|
26
27
|
|
27
28
|
module Covered
|
@@ -42,6 +43,8 @@ module Covered
|
|
42
43
|
@reports = []
|
43
44
|
end
|
44
45
|
|
46
|
+
attr :output
|
47
|
+
|
45
48
|
def freeze
|
46
49
|
return self if frozen?
|
47
50
|
|
@@ -91,6 +94,10 @@ module Covered
|
|
91
94
|
capture.disable
|
92
95
|
end
|
93
96
|
|
97
|
+
def flush
|
98
|
+
@output.flush
|
99
|
+
end
|
100
|
+
|
94
101
|
attr :reports
|
95
102
|
|
96
103
|
class Autoload
|
data/lib/covered/statistics.rb
CHANGED
@@ -22,6 +22,9 @@ require_relative 'wrapper'
|
|
22
22
|
require_relative 'coverage'
|
23
23
|
|
24
24
|
module Covered
|
25
|
+
class CoverageError < StandardError
|
26
|
+
end
|
27
|
+
|
25
28
|
class Statistics < Wrapper
|
26
29
|
def initialize
|
27
30
|
@count = 0
|
@@ -51,5 +54,11 @@ module Covered
|
|
51
54
|
|
52
55
|
# Could output funny message here, especially for 100% coverage.
|
53
56
|
end
|
57
|
+
|
58
|
+
def validate!(minimum = 1.0)
|
59
|
+
if self.ratio < minimum
|
60
|
+
raise CoverageError, "Coverage of #{self.percentage.to_f.round(2)}% is less than required minimum of #{(minimum * 100.0).round(2)}%!"
|
61
|
+
end
|
62
|
+
end
|
54
63
|
end
|
55
64
|
end
|
data/lib/covered/version.rb
CHANGED
data/lib/covered/wrapper.rb
CHANGED
@@ -26,6 +26,9 @@ module Covered
|
|
26
26
|
def disable
|
27
27
|
end
|
28
28
|
|
29
|
+
def flush
|
30
|
+
end
|
31
|
+
|
29
32
|
def accept?(path)
|
30
33
|
true
|
31
34
|
end
|
@@ -60,6 +63,10 @@ module Covered
|
|
60
63
|
@output.disable
|
61
64
|
end
|
62
65
|
|
66
|
+
def flush
|
67
|
+
@output.flush
|
68
|
+
end
|
69
|
+
|
63
70
|
def accept?(path)
|
64
71
|
@output.accept?(path)
|
65
72
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: covered
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -39,7 +39,7 @@ cert_chain:
|
|
39
39
|
RAOsIl+HOBTb252nx1kIRN5hqQx272AJCbCjKx8egcUQKffFVVCI0nye09v5CK+a
|
40
40
|
HiLJ8VOFx6w=
|
41
41
|
-----END CERTIFICATE-----
|
42
|
-
date: 2022-06-
|
42
|
+
date: 2022-06-13 00:00:00.000000000 Z
|
43
43
|
dependencies:
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
45
|
name: async-rest
|
@@ -159,16 +159,9 @@ executables: []
|
|
159
159
|
extensions: []
|
160
160
|
extra_rdoc_files: []
|
161
161
|
files:
|
162
|
-
-
|
163
|
-
- ".github/workflows/documentation.yml"
|
164
|
-
- examples/coverage/covered.rb
|
165
|
-
- examples/coverage/erb/coverage.rb
|
166
|
-
- examples/coverage/erb/template.erb
|
167
|
-
- examples/coverage/parser.rb
|
168
|
-
- examples/coverage/simplecov.rb
|
169
|
-
- examples/coverage/test.rb
|
170
|
-
- examples/coverage/tracepoint.rb
|
162
|
+
- bake/covered/validate.rb
|
171
163
|
- lib/covered.rb
|
164
|
+
- lib/covered/cache.rb
|
172
165
|
- lib/covered/capture.rb
|
173
166
|
- lib/covered/coverage.rb
|
174
167
|
- lib/covered/coveralls.rb
|
@@ -184,7 +177,6 @@ files:
|
|
184
177
|
- lib/covered/summary.rb
|
185
178
|
- lib/covered/version.rb
|
186
179
|
- lib/covered/wrapper.rb
|
187
|
-
- media/example.png
|
188
180
|
homepage: https://github.com/ioquatix/covered
|
189
181
|
licenses:
|
190
182
|
- MIT
|
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,45 +0,0 @@
|
|
1
|
-
name: Development
|
2
|
-
|
3
|
-
on: [push, pull_request]
|
4
|
-
|
5
|
-
jobs:
|
6
|
-
test:
|
7
|
-
name: ${{matrix.ruby}} on ${{matrix.os}}
|
8
|
-
runs-on: ${{matrix.os}}-latest
|
9
|
-
continue-on-error: ${{matrix.experimental}}
|
10
|
-
|
11
|
-
strategy:
|
12
|
-
matrix:
|
13
|
-
os:
|
14
|
-
- ubuntu
|
15
|
-
- macos
|
16
|
-
|
17
|
-
ruby:
|
18
|
-
- "2.6"
|
19
|
-
- "2.7"
|
20
|
-
- "3.0"
|
21
|
-
|
22
|
-
experimental: [false]
|
23
|
-
env: [""]
|
24
|
-
|
25
|
-
include:
|
26
|
-
- os: ubuntu
|
27
|
-
ruby: truffleruby
|
28
|
-
experimental: true
|
29
|
-
- os: ubuntu
|
30
|
-
ruby: jruby
|
31
|
-
experimental: true
|
32
|
-
- os: ubuntu
|
33
|
-
ruby: head
|
34
|
-
experimental: true
|
35
|
-
|
36
|
-
steps:
|
37
|
-
- uses: actions/checkout@v2
|
38
|
-
- uses: ruby/setup-ruby@v1
|
39
|
-
with:
|
40
|
-
ruby-version: ${{matrix.ruby}}
|
41
|
-
bundler-cache: true
|
42
|
-
|
43
|
-
- name: Run tests
|
44
|
-
timeout-minutes: 5
|
45
|
-
run: ${{matrix.env}} bundle exec rspec
|
@@ -1,34 +0,0 @@
|
|
1
|
-
name: Documentation
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches:
|
6
|
-
- main
|
7
|
-
|
8
|
-
env:
|
9
|
-
BUNDLE_WITH: maintenance
|
10
|
-
|
11
|
-
jobs:
|
12
|
-
deploy:
|
13
|
-
runs-on: ubuntu-latest
|
14
|
-
|
15
|
-
steps:
|
16
|
-
- uses: actions/checkout@v3
|
17
|
-
|
18
|
-
- uses: ruby/setup-ruby@v1
|
19
|
-
with:
|
20
|
-
ruby-version: 3.1
|
21
|
-
bundler-cache: true
|
22
|
-
|
23
|
-
- name: Installing packages
|
24
|
-
run: sudo apt-get install wget
|
25
|
-
|
26
|
-
- name: Prepare GitHub Pages
|
27
|
-
run: bundle exec bake github:pages:prepare --directory docs
|
28
|
-
|
29
|
-
- name: Generate documentation
|
30
|
-
timeout-minutes: 5
|
31
|
-
run: bundle exec bake utopia:project:static --force no
|
32
|
-
|
33
|
-
- name: Deploy GitHub Pages
|
34
|
-
run: bundle exec bake github:pages:commit --directory docs
|
@@ -1,21 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'erb'
|
3
|
-
$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
|
4
|
-
|
5
|
-
template_path = File.expand_path("template.erb", __dir__)
|
6
|
-
|
7
|
-
ENV['COVERAGE'] ||= 'PartialSummary'
|
8
|
-
require 'covered/policy/default'
|
9
|
-
|
10
|
-
$covered.enable
|
11
|
-
|
12
|
-
template = ERB.new(File.read(template_path)).tap do |template|
|
13
|
-
template.filename = template_path
|
14
|
-
end
|
15
|
-
|
16
|
-
@items = ["Cats", "Dogs", "Chickens"]
|
17
|
-
puts template.result(binding)
|
18
|
-
|
19
|
-
$covered.disable
|
20
|
-
|
21
|
-
$covered.call($stdout)
|
data/examples/coverage/parser.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'pry'
|
4
|
-
require 'parser/current'
|
5
|
-
|
6
|
-
ast = Parser::CurrentRuby.parse_file('test.rb')
|
7
|
-
# ast.location.expression.source
|
8
|
-
|
9
|
-
def print_methods(ast)
|
10
|
-
if ast.is_a? Parser::AST::Node
|
11
|
-
if ast.type == :send
|
12
|
-
puts "Calling #{ast.children[1]} on #{ast.location.line}"
|
13
|
-
end
|
14
|
-
|
15
|
-
ast.children.each do |child|
|
16
|
-
print_methods(child)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
print_methods(ast)
|
22
|
-
|
23
|
-
binding.pry
|
data/examples/coverage/test.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
trace_point = TracePoint.new(:call, :return, :line, :c_call, :c_return, :b_call, :b_return) do |trace|
|
2
|
-
puts [trace.path, trace.lineno].join(":")
|
3
|
-
end
|
4
|
-
|
5
|
-
trace_point.enable
|
6
|
-
|
7
|
-
values = {foo: 10}
|
8
|
-
|
9
|
-
def shell_escape(x)
|
10
|
-
x
|
11
|
-
end
|
12
|
-
|
13
|
-
values.map{|key, value| [
|
14
|
-
key.to_s.upcase,
|
15
|
-
shell_escape(value) # TracePoint is never triggered for this line.
|
16
|
-
]}
|
data/media/example.png
DELETED
Binary file
|