relevance-rcov 0.8.5.2 → 0.8.6
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.
- data/lib/rcov.rb +12 -990
- data/lib/rcov/call_site_analyzer.rb +225 -0
- data/lib/rcov/code_coverage_analyzer.rb +268 -0
- data/lib/rcov/coverage_info.rb +36 -0
- data/lib/rcov/differential_analyzer.rb +116 -0
- data/lib/rcov/file_statistics.rb +334 -0
- data/lib/rcov/formatters/base_formatter.rb +5 -6
- data/lib/rcov/formatters/full_text_report.rb +3 -10
- data/lib/rcov/formatters/html_coverage.rb +190 -201
- data/lib/rcov/formatters/html_erb_template.rb +1 -84
- data/lib/rcov/formatters/text_coverage_diff.rb +7 -13
- data/lib/rcov/formatters/text_report.rb +0 -4
- data/lib/rcov/lowlevel.rb +14 -13
- data/lib/rcov/rcovtask.rb +21 -22
- data/lib/rcov/templates/screen.css +37 -34
- data/lib/rcov/version.rb +3 -3
- metadata +6 -1
@@ -1,8 +1,7 @@
|
|
1
1
|
module Rcov
|
2
2
|
module Formatters
|
3
|
-
|
4
3
|
class HtmlErbTemplate
|
5
|
-
attr_accessor :local_variables
|
4
|
+
attr_accessor :local_variables
|
6
5
|
|
7
6
|
def initialize(template_file, locals={})
|
8
7
|
require "erb"
|
@@ -11,7 +10,6 @@ module Rcov
|
|
11
10
|
@template = ERB.new(File.read(template_path))
|
12
11
|
@local_variables = locals
|
13
12
|
@path_relativizer = Hash.new{|h,base|
|
14
|
-
# TODO: Waaaahhhhh?
|
15
13
|
h[base] = Pathname.new(base).cleanpath.to_s.gsub(%r{^\w:[/\\]}, "").gsub(/\./, "_").gsub(/[\\\/]/, "-") + ".html"
|
16
14
|
}
|
17
15
|
end
|
@@ -24,55 +22,6 @@ module Rcov
|
|
24
22
|
@path_relativizer[path]
|
25
23
|
end
|
26
24
|
|
27
|
-
#def create_cross_refs(filename, lineno, linetext)
|
28
|
-
#form = formatter
|
29
|
-
#return linetext unless @callsite_analyzer && @do_callsites
|
30
|
-
|
31
|
-
#ref_blocks = []
|
32
|
-
#form.send(:_get_defsites, ref_blocks, filename, lineno, "Calls", linetext) do |ref|
|
33
|
-
#if ref.file
|
34
|
-
#where = "at #{formatter.normalize_filename(ref.file)}:#{ref.line}"
|
35
|
-
#else
|
36
|
-
#where = "(C extension/core)"
|
37
|
-
#end
|
38
|
-
#CGI.escapeHTML("%7d %s" % [ref.count, "#{ref.klass}##{ref.mid} " + where])
|
39
|
-
#end
|
40
|
-
|
41
|
-
#form.send(:_get_callsites, ref_blocks, filename, lineno, "Called by", linetext) do |ref|
|
42
|
-
#r = "%7d %s" % [ref.count, "#{formatter.normalize_filename(ref.file||'C code')}:#{ref.line} " + "in '#{ref.klass}##{ref.mid}'"]
|
43
|
-
#CGI.escapeHTML(r)
|
44
|
-
#end
|
45
|
-
|
46
|
-
#create_cross_reference_block(linetext, ref_blocks)
|
47
|
-
#end
|
48
|
-
|
49
|
-
#def create_cross_reference_block(linetext, ref_blocks)
|
50
|
-
#return linetext if ref_blocks.empty?
|
51
|
-
#ret = ""
|
52
|
-
#@cross_ref_idx ||= 0
|
53
|
-
#@known_files ||= formatter.sorted_file_pairs.map{|fname, finfo| formatter.normalize_filename(fname)}
|
54
|
-
#ret << %[<a class="crossref-toggle" href="#" onclick="toggleCode('XREF-#{@cross_ref_idx+=1}'); return false;">#{linetext}</a>]
|
55
|
-
#ret << %[<span class="cross-ref" id="XREF-#{@cross_ref_idx}">]
|
56
|
-
#ret << "\n"
|
57
|
-
#ref_blocks.each do |refs, toplabel, label_proc|
|
58
|
-
#unless !toplabel || toplabel.empty?
|
59
|
-
#ret << %!<span class="cross-ref-title">#{toplabel}</span>\n!
|
60
|
-
#end
|
61
|
-
#refs.each do |dst|
|
62
|
-
#dstfile = formatter.normalize_filename(dst.file) if dst.file
|
63
|
-
#dstline = dst.line
|
64
|
-
#label = label_proc.call(dst)
|
65
|
-
#if dst.file && @known_files.include?(dstfile)
|
66
|
-
#ret << %[<a href="#{formatter.mangle_filename(dstfile)}#line#{dstline}">#{label}</a>]
|
67
|
-
#else
|
68
|
-
#ret << label
|
69
|
-
#end
|
70
|
-
#ret << "\n"
|
71
|
-
#end
|
72
|
-
#end
|
73
|
-
#ret << "</span>"
|
74
|
-
#end
|
75
|
-
|
76
25
|
def line_css(line_number)
|
77
26
|
case fileinfo.coverage[line_number]
|
78
27
|
when true
|
@@ -84,36 +33,6 @@ module Rcov
|
|
84
33
|
end
|
85
34
|
end
|
86
35
|
|
87
|
-
|
88
|
-
#def format_lines(file)
|
89
|
-
#result = ""
|
90
|
-
#last = nil
|
91
|
-
#end_of_span = ""
|
92
|
-
#format_line = "%#{file.num_lines.to_s.size}d"
|
93
|
-
#file.num_lines.times do |i|
|
94
|
-
#line = file.lines[i].chomp
|
95
|
-
#marked = file.coverage[i]
|
96
|
-
#count = file.counts[i]
|
97
|
-
#spanclass = span_class(file, marked, count)
|
98
|
-
#if spanclass != last
|
99
|
-
#result += end_of_span
|
100
|
-
#case spanclass
|
101
|
-
#when nil
|
102
|
-
#end_of_span = ""
|
103
|
-
#else
|
104
|
-
#result += %[<span class="#{spanclass}">]
|
105
|
-
#end_of_span = "</span>"
|
106
|
-
#end
|
107
|
-
#end
|
108
|
-
#result += %[<a name="line#{i+1}"></a>] + (format_line % (i+1)) +
|
109
|
-
#" " + create_cross_refs(file.name, i+1, CGI.escapeHTML(line)) + "\n"
|
110
|
-
#last = spanclass
|
111
|
-
#end
|
112
|
-
#result += end_of_span
|
113
|
-
#"<pre>#{result}</pre>"
|
114
|
-
#end
|
115
|
-
|
116
|
-
|
117
36
|
def method_missing(key, *args)
|
118
37
|
local_variables.has_key?(key) ? local_variables[key] : super
|
119
38
|
end
|
@@ -121,8 +40,6 @@ module Rcov
|
|
121
40
|
def get_binding
|
122
41
|
binding
|
123
42
|
end
|
124
|
-
|
125
43
|
end
|
126
|
-
|
127
44
|
end
|
128
45
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Rcov
|
2
|
-
|
3
2
|
class TextCoverageDiff < BaseFormatter # :nodoc:
|
4
3
|
FORMAT_VERSION = [0, 1, 0]
|
5
4
|
DEFAULT_OPTS = { :textmode => :coverage_diff, :coverage_diff_mode => :record,
|
6
|
-
|
5
|
+
:coverage_diff_file => "coverage.info", :diff_cmd => "diff",
|
6
|
+
:comments_run_by_default => true }
|
7
7
|
HUNK_HEADER = /@@ -\d+,\d+ \+(\d+),(\d+) @@/
|
8
8
|
|
9
9
|
def SERIALIZER
|
@@ -47,7 +47,7 @@ module Rcov
|
|
47
47
|
$stderr.puts <<-EOF
|
48
48
|
Couldn't save coverage data to #{@state_file}.
|
49
49
|
EOF
|
50
|
-
end
|
50
|
+
end # '
|
51
51
|
|
52
52
|
require 'tempfile'
|
53
53
|
def compare_state
|
@@ -58,7 +58,7 @@ module Rcov
|
|
58
58
|
$stderr.puts <<-EOF
|
59
59
|
Couldn't load coverage data from #{@state_file}.
|
60
60
|
EOF
|
61
|
-
return
|
61
|
+
return # '
|
62
62
|
end
|
63
63
|
if !(Array === format) or
|
64
64
|
FORMAT_VERSION[0] != format[0] || FORMAT_VERSION[1] < format[1]
|
@@ -67,7 +67,7 @@ module Rcov
|
|
67
67
|
The file is saved in the format #{format.inspect[0..20]}.
|
68
68
|
This rcov executable understands #{FORMAT_VERSION.inspect}.
|
69
69
|
EOF
|
70
|
-
return
|
70
|
+
return # '
|
71
71
|
end
|
72
72
|
each_file_pair_sorted do |filename, fileinfo|
|
73
73
|
old_data = Tempfile.new("#{mangle_filename(filename)}-old")
|
@@ -101,7 +101,7 @@ module Rcov
|
|
101
101
|
puts
|
102
102
|
puts "=" * 80
|
103
103
|
puts "!!!!! Uncovered code introduced in #{filename}"
|
104
|
-
|
104
|
+
|
105
105
|
hunks.each do |offset, lines|
|
106
106
|
if @gcc_output
|
107
107
|
lines.each_with_index do |line,i|
|
@@ -126,16 +126,13 @@ module Rcov
|
|
126
126
|
def verify_diff_available
|
127
127
|
old_stderr = STDERR.dup
|
128
128
|
old_stdout = STDOUT.dup
|
129
|
-
# TODO: should use /dev/null or NUL(?), but I don't want to add the
|
130
|
-
# win32 check right now
|
131
129
|
new_stderr = Tempfile.new("rcov_check_diff")
|
132
130
|
STDERR.reopen new_stderr.path
|
133
131
|
STDOUT.reopen new_stderr.path
|
134
132
|
|
135
133
|
retval = system "#{@diff_cmd} --version"
|
136
134
|
unless retval
|
137
|
-
old_stderr.puts <<EOF
|
138
|
-
|
135
|
+
old_stderr.puts <<EOF
|
139
136
|
The '#{@diff_cmd}' executable seems not to be available.
|
140
137
|
You can specify which diff executable should be used with --diff-cmd.
|
141
138
|
If your system doesn't have one, you might want to use Diff::LCS's:
|
@@ -151,7 +148,6 @@ EOF
|
|
151
148
|
new_stderr.close!
|
152
149
|
end
|
153
150
|
|
154
|
-
|
155
151
|
def process_unified_diff(filename, diff)
|
156
152
|
current_hunk = []
|
157
153
|
current_hunk_start = 0
|
@@ -193,7 +189,5 @@ EOF
|
|
193
189
|
|
194
190
|
interesting_hunks
|
195
191
|
end
|
196
|
-
|
197
192
|
end
|
198
|
-
|
199
193
|
end
|
data/lib/rcov/lowlevel.rb
CHANGED
@@ -6,15 +6,16 @@ require 'rcov/version'
|
|
6
6
|
|
7
7
|
module Rcov
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
9
|
+
# RCOV__ performs the low-level tracing of the execution, gathering code
|
10
|
+
# coverage information in the process. The C core made available through the
|
11
|
+
# rcovrt extension will be used if possible. Otherwise the functionality
|
12
|
+
# will be emulated using set_trace_func, but this is very expensive and
|
13
|
+
# will fail if other libraries (e.g. breakpoint) change the trace_func.
|
14
|
+
#
|
15
|
+
# Do not use this module; it is very low-level and subject to frequent
|
16
|
+
# changes. Rcov::CodeCoverageAnalyzer offers a much more convenient and
|
17
|
+
# stable interface.
|
18
|
+
|
18
19
|
module RCOV__
|
19
20
|
COVER = {}
|
20
21
|
CALLSITES = {}
|
@@ -59,19 +60,19 @@ One Click Installer and mswin32 builds) at http://eigenclass.org/hiki.rb?rcov .
|
|
59
60
|
(methods & sklass.instance_methods).each do |meth|
|
60
61
|
sklass.class_eval{ remove_method meth }
|
61
62
|
end
|
62
|
-
|
63
|
+
|
63
64
|
@coverage_hook_activated = @callsite_hook_activated = false
|
64
65
|
|
65
66
|
def self.install_coverage_hook # :nodoc:
|
66
67
|
install_common_hook
|
67
68
|
@coverage_hook_activated = true
|
68
69
|
end
|
69
|
-
|
70
|
+
|
70
71
|
def self.install_callsite_hook # :nodoc:
|
71
72
|
install_common_hook
|
72
73
|
@callsite_hook_activated = true
|
73
74
|
end
|
74
|
-
|
75
|
+
|
75
76
|
def self.install_common_hook # :nodoc:
|
76
77
|
set_trace_func lambda {|event, file, line, id, binding, klass|
|
77
78
|
next unless SCRIPT_LINES__.has_key? file
|
@@ -109,7 +110,7 @@ One Click Installer and mswin32 builds) at http://eigenclass.org/hiki.rb?rcov .
|
|
109
110
|
@coverage_hook_activated = false
|
110
111
|
set_trace_func(nil) if !@callsite_hook_activated
|
111
112
|
end
|
112
|
-
|
113
|
+
|
113
114
|
def self.remove_callsite_hook # :nodoc:
|
114
115
|
@callsite_hook_activated = false
|
115
116
|
set_trace_func(nil) if !@coverage_hook_activated
|
data/lib/rcov/rcovtask.rb
CHANGED
@@ -12,9 +12,9 @@ module Rcov
|
|
12
12
|
# coverage reports.
|
13
13
|
#
|
14
14
|
# Example:
|
15
|
-
#
|
15
|
+
#
|
16
16
|
# require 'rcov/rcovtask'
|
17
|
-
#
|
17
|
+
#
|
18
18
|
# Rcov::RcovTask.new do |t|
|
19
19
|
# t.libs << "test"
|
20
20
|
# t.test_files = FileList['test/test*.rb']
|
@@ -103,27 +103,27 @@ module Rcov
|
|
103
103
|
(@name==:rcov ? "" : " for #{actual_name}")
|
104
104
|
end
|
105
105
|
task @name do
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
106
|
+
run_code = ''
|
107
|
+
RakeFileUtils.verbose(@verbose) do
|
108
|
+
run_code =
|
109
|
+
case rcov_path
|
110
|
+
when nil, ''
|
111
|
+
"-S rcov"
|
112
|
+
else %!"#{rcov_path}"!
|
113
|
+
end
|
114
114
|
ruby_opts = @ruby_opts.clone
|
115
115
|
ruby_opts.push( "-I#{lib_path}" )
|
116
116
|
ruby_opts.push run_code
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
117
|
+
ruby_opts.push( "-w" ) if @warning
|
118
|
+
ruby ruby_opts.join(" ") + " " + option_list +
|
119
|
+
%[ -o "#{@output_dir}" ] +
|
120
|
+
file_list.collect { |fn| %["#{fn}"] }.join(' ')
|
121
|
+
end
|
122
122
|
end
|
123
123
|
|
124
124
|
desc "Remove rcov products for #{actual_name}"
|
125
125
|
task paste("clobber_", actual_name) do
|
126
|
-
|
126
|
+
rm_r @output_dir rescue nil
|
127
127
|
end
|
128
128
|
|
129
129
|
clobber_task = paste("clobber_", actual_name)
|
@@ -143,14 +143,13 @@ module Rcov
|
|
143
143
|
|
144
144
|
def file_list # :nodoc:
|
145
145
|
if ENV['TEST']
|
146
|
-
|
146
|
+
FileList[ ENV['TEST'] ]
|
147
147
|
else
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
148
|
+
result = []
|
149
|
+
result += @test_files.to_a if @test_files
|
150
|
+
result += FileList[ @pattern ].to_a if @pattern
|
151
|
+
FileList[result]
|
152
152
|
end
|
153
153
|
end
|
154
154
|
end
|
155
155
|
end
|
156
|
-
|
@@ -1,23 +1,25 @@
|
|
1
1
|
body {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
font: 62.5%/1.4em Helvetica, Arial, Sans-Serif;
|
3
|
+
color: #4C4C4C;
|
4
|
+
background-color: #F4F2ED;
|
5
|
+
padding: 1em;
|
6
|
+
margin: 8px 0 0 0;
|
7
7
|
}
|
8
8
|
|
9
9
|
a {
|
10
10
|
color:#191919;
|
11
11
|
font-weight:bold;
|
12
12
|
outline: none;
|
13
|
-
}
|
13
|
+
}
|
14
14
|
|
15
15
|
span.cross-ref-title {
|
16
16
|
font-size: 140%;
|
17
17
|
}
|
18
|
+
|
18
19
|
span.cross-ref a {
|
19
20
|
text-decoration: none;
|
20
21
|
}
|
22
|
+
|
21
23
|
span.cross-ref {
|
22
24
|
background-color:#f3f7fa;
|
23
25
|
border: 1px dashed #333;
|
@@ -29,6 +31,7 @@ span.cross-ref {
|
|
29
31
|
a.crossref-toggle {
|
30
32
|
text-decoration: none;
|
31
33
|
}
|
34
|
+
|
32
35
|
pre, code {
|
33
36
|
color: #000000;
|
34
37
|
font-family: "Bitstream Vera Sans Mono","Monaco","Courier New",monospace;
|
@@ -77,12 +80,12 @@ div.overview {
|
|
77
80
|
}
|
78
81
|
|
79
82
|
div.footer {
|
80
|
-
|
81
|
-
|
83
|
+
font-size: 68%;
|
84
|
+
margin-top: 1.5em;
|
82
85
|
}
|
83
86
|
|
84
87
|
h1, h2, h3, h4, h5, h6 {
|
85
|
-
|
88
|
+
margin-bottom: 0.5em;
|
86
89
|
}
|
87
90
|
|
88
91
|
h3 {
|
@@ -95,71 +98,71 @@ h3 {
|
|
95
98
|
}
|
96
99
|
|
97
100
|
h5 {
|
98
|
-
|
101
|
+
margin-top: 0.5em;
|
99
102
|
}
|
100
103
|
|
101
104
|
.hidden {
|
102
|
-
|
105
|
+
display: none;
|
103
106
|
}
|
104
107
|
|
105
108
|
div.separator {
|
106
|
-
|
109
|
+
height: 10px;
|
107
110
|
}
|
108
111
|
|
109
112
|
table.percent_graph {
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
+
height: 12px;
|
114
|
+
border: #808080 1px solid;
|
115
|
+
empty-cells: show;
|
113
116
|
}
|
114
117
|
|
115
118
|
table.percent_graph td.covered {
|
116
|
-
|
117
|
-
|
119
|
+
height: 10px;
|
120
|
+
background: #00f000;
|
118
121
|
}
|
119
122
|
|
120
123
|
table.percent_graph td.uncovered {
|
121
|
-
|
122
|
-
|
124
|
+
height: 10px;
|
125
|
+
background: #e00000;
|
123
126
|
}
|
124
127
|
|
125
128
|
table.percent_graph td.NA {
|
126
|
-
|
127
|
-
|
129
|
+
height: 10px;
|
130
|
+
background: #eaeaea;
|
128
131
|
}
|
129
132
|
|
130
133
|
table.report {
|
131
|
-
|
132
|
-
|
134
|
+
border-collapse: collapse;
|
135
|
+
width: 100%;
|
133
136
|
}
|
134
137
|
|
135
138
|
table.report td.heading {
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
139
|
+
background: #dcecff;
|
140
|
+
border: #d0d0d0 1px solid;
|
141
|
+
font-weight: bold;
|
142
|
+
text-align: center;
|
140
143
|
}
|
141
144
|
|
142
145
|
table.report td.heading:hover {
|
143
|
-
|
146
|
+
background: #c0ffc0;
|
144
147
|
}
|
145
148
|
|
146
149
|
table.report td.text {
|
147
|
-
|
150
|
+
border: #d0d0d0 1px solid;
|
148
151
|
}
|
149
152
|
|
150
153
|
table.report td {
|
151
|
-
|
154
|
+
font-size: 125%;
|
152
155
|
}
|
153
156
|
|
154
157
|
table.report td.value,
|
155
158
|
table.report td.lines_total,
|
156
159
|
table.report td.lines_code {
|
157
|
-
|
158
|
-
|
160
|
+
text-align: right;
|
161
|
+
border: #d0d0d0 1px solid;
|
159
162
|
}
|
160
163
|
table.report tr.light {
|
161
|
-
|
164
|
+
background-color: rgb(240, 240, 245);
|
162
165
|
}
|
163
166
|
table.report tr.dark {
|
164
|
-
|
167
|
+
background-color: rgb(230, 230, 235);
|
165
168
|
}
|