covered 0.10.5 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/coverage/covered.rb +11 -0
- data/examples/coverage/parser.rb +23 -0
- data/examples/coverage/simplecov.rb +7 -0
- data/examples/coverage/test.rb +8 -0
- data/examples/coverage/tracepoint.rb +9 -0
- data/lib/covered/capture.rb +1 -1
- data/lib/covered/persist.rb +3 -1
- data/lib/covered/policy/default.rb +5 -3
- data/lib/covered/source.rb +14 -12
- data/lib/covered/version.rb +1 -1
- metadata +7 -3
- data/lib/covered/eval.rb +0 -78
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58f32d0b3917b373713212f99cec0a6d205ce16c46f744169a202d284eb413e7
|
4
|
+
data.tar.gz: b66f5175e13cacaed2a454f5d3e8449c04971fbbdfdf15fa28cf3ab46486ae0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb761996f33000c60701075e727573303710ec5fde4639021788860c38942c899f889b4d6c8f05124dc7b1b3e1320c0bb59b4ce048695e87ca885b90d917404b
|
7
|
+
data.tar.gz: 2b3efafdd32173f24d8b4b57ca26ce2b1cad85a800be76ae79af319da680efb08c6fcadef795b5db8baa002fb6344001556878954745c7ed8fa2fc0a179206cb
|
@@ -0,0 +1,23 @@
|
|
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/lib/covered/capture.rb
CHANGED
data/lib/covered/persist.rb
CHANGED
@@ -18,17 +18,19 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
|
+
require_relative '../policy'
|
22
|
+
|
21
23
|
$covered = Covered.policy do
|
22
24
|
cache!
|
23
25
|
|
24
26
|
# Only files in the root would be tracked:
|
25
|
-
root
|
27
|
+
root(Dir.pwd)
|
26
28
|
|
27
29
|
# We will ignore any files in the test or spec directory:
|
28
|
-
skip
|
30
|
+
skip(/^.*\/(test|spec|vendor)\//)
|
29
31
|
|
30
32
|
# We will include all files under lib, even if they aren't loaded:
|
31
|
-
include
|
33
|
+
include("lib/**/*.rb")
|
32
34
|
|
33
35
|
persist!
|
34
36
|
|
data/lib/covered/source.rb
CHANGED
@@ -18,11 +18,9 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
|
-
require_relative 'eval'
|
22
21
|
require_relative 'wrapper'
|
23
22
|
|
24
23
|
require 'thread'
|
25
|
-
|
26
24
|
require 'parser/current'
|
27
25
|
|
28
26
|
module Covered
|
@@ -35,30 +33,34 @@ module Covered
|
|
35
33
|
@mutex = Mutex.new
|
36
34
|
|
37
35
|
@annotations = {}
|
36
|
+
|
37
|
+
begin
|
38
|
+
@trace = TracePoint.new(:script_compiled) do |event|
|
39
|
+
if path = event.instruction_sequence&.path and source = event.eval_script
|
40
|
+
@mutex.synchronize do
|
41
|
+
@paths[path] = source
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
rescue ArgumentError
|
46
|
+
@trace = nil
|
47
|
+
end
|
38
48
|
end
|
39
49
|
|
40
50
|
def enable
|
41
51
|
super
|
42
52
|
|
43
|
-
|
53
|
+
@trace&.enable
|
44
54
|
end
|
45
55
|
|
46
56
|
def disable
|
47
|
-
|
57
|
+
@trace&.disable
|
48
58
|
|
49
59
|
super
|
50
60
|
end
|
51
61
|
|
52
62
|
attr :paths
|
53
63
|
|
54
|
-
def intercept_eval(string, binding = nil, filename = nil, lineno = 1)
|
55
|
-
return unless filename
|
56
|
-
|
57
|
-
@mutex.synchronize do
|
58
|
-
@paths[filename] = string
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
64
|
def executable?(node)
|
63
65
|
node.type == :send
|
64
66
|
end
|
data/lib/covered/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: covered
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rainbow
|
@@ -151,11 +151,15 @@ files:
|
|
151
151
|
- README.md
|
152
152
|
- Rakefile
|
153
153
|
- covered.gemspec
|
154
|
+
- examples/coverage/covered.rb
|
155
|
+
- examples/coverage/parser.rb
|
156
|
+
- examples/coverage/simplecov.rb
|
157
|
+
- examples/coverage/test.rb
|
158
|
+
- examples/coverage/tracepoint.rb
|
154
159
|
- lib/covered.rb
|
155
160
|
- lib/covered/capture.rb
|
156
161
|
- lib/covered/coverage.rb
|
157
162
|
- lib/covered/coveralls.rb
|
158
|
-
- lib/covered/eval.rb
|
159
163
|
- lib/covered/files.rb
|
160
164
|
- lib/covered/minitest.rb
|
161
165
|
- lib/covered/persist.rb
|
data/lib/covered/eval.rb
DELETED
@@ -1,78 +0,0 @@
|
|
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 'thread'
|
22
|
-
|
23
|
-
module Covered
|
24
|
-
module Eval
|
25
|
-
@mutex = Mutex.new
|
26
|
-
@handler = nil
|
27
|
-
|
28
|
-
def self.enable(handler)
|
29
|
-
@mutex.synchronize do
|
30
|
-
@handler = handler
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.disable(handler)
|
35
|
-
@mutex.synchronize do
|
36
|
-
@handler = nil
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.intercept_eval(*args)
|
41
|
-
@mutex.synchronize do
|
42
|
-
@handler.intercept_eval(*args) if @handler
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
module Kernel
|
49
|
-
class << self
|
50
|
-
alias_method :__eval__, :eval
|
51
|
-
|
52
|
-
def eval(*args)
|
53
|
-
Covered::Eval.intercept_eval(*args)
|
54
|
-
|
55
|
-
__eval__(*args)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
private
|
60
|
-
|
61
|
-
alias_method :__eval__, :eval
|
62
|
-
|
63
|
-
def eval(*args)
|
64
|
-
Covered::Eval.intercept_eval(*args)
|
65
|
-
|
66
|
-
__eval__(*args)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
class Binding
|
71
|
-
alias_method :__eval__, :eval
|
72
|
-
|
73
|
-
def eval(*args)
|
74
|
-
Covered::Eval.intercept_eval(*args)
|
75
|
-
|
76
|
-
__eval__(*args)
|
77
|
-
end
|
78
|
-
end
|