rcov 0.5.0.1 → 0.6.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/BLURB +35 -1
- data/CHANGES +28 -0
- data/README.en +2 -0
- data/README.vim +47 -0
- data/Rakefile +6 -5
- data/Rantfile +2 -1
- data/THANKS +14 -0
- data/bin/rcov +124 -743
- data/ext/rcovrt/extconf.rb +9 -1
- data/ext/rcovrt/rcov.c +115 -32
- data/lib/rcov.rb +67 -42
- data/lib/rcov/lowlevel.rb +9 -1
- data/lib/rcov/rant.rb +5 -3
- data/lib/rcov/rcovtask.rb +3 -3
- data/lib/rcov/report.rb +1005 -0
- data/lib/rcov/version.rb +3 -3
- data/test/test_CallSiteAnalyzer.rb +41 -18
- data/test/test_CodeCoverageAnalyzer.rb +2 -2
- data/test/test_FileStatistics.rb +72 -2
- metadata +6 -2
data/lib/rcov/version.rb
CHANGED
@@ -14,8 +14,11 @@ class Test_CallSiteAnalyzer < Test::Unit::TestCase
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def verify_callsites_equal(expected, actual)
|
17
|
-
callsites = expected.inject({}) do |s,(
|
18
|
-
|
17
|
+
callsites = expected.inject({}) do |s,(backtrace, count)|
|
18
|
+
unless $".any?{|x| %r{\brcovrt\b} =~ x}
|
19
|
+
backtrace = backtrace.map{|_, mid, file, line| [nil, mid, file, line] }
|
20
|
+
end
|
21
|
+
s[Rcov::CallSiteAnalyzer::CallSite.new(backtrace)] = count
|
19
22
|
s
|
20
23
|
end
|
21
24
|
assert_equal(callsites, actual)
|
@@ -71,32 +74,42 @@ class Test_CallSiteAnalyzer < Test::Unit::TestCase
|
|
71
74
|
@a.run_hooked{ @o.f1 }
|
72
75
|
assert(@a.analyzed_classes.include?("Rcov::Test::Temporary::Sample03"))
|
73
76
|
assert_equal(%w[f1 f2], @a.analyzed_methods("Rcov::Test::Temporary::Sample03"))
|
74
|
-
verify_callsites_equal({["./test/sample_03.rb
|
77
|
+
verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1, "./test/sample_03.rb", 4]] => 10},
|
75
78
|
@a.callsites("Rcov::Test::Temporary::Sample03", "f2"))
|
76
|
-
verify_callsites_equal({["./test/sample_03.rb
|
79
|
+
verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1, "./test/sample_03.rb", 4]] => 10},
|
77
80
|
@a.callsites("Rcov::Test::Temporary::Sample03#f2"))
|
81
|
+
#verify_callsites_equal({["./test/sample_03.rb:4:in `f1'"] => 10},
|
82
|
+
# @a.callsites("Rcov::Test::Temporary::Sample03", "f2"))
|
83
|
+
#verify_callsites_equal({["./test/sample_03.rb:4:in `f1'"] => 10},
|
84
|
+
# @a.callsites("Rcov::Test::Temporary::Sample03#f2"))
|
78
85
|
end
|
79
86
|
|
80
87
|
def test_basic_callsite_recording_API
|
81
88
|
@a.run_hooked{ @o.f1 }
|
82
89
|
assert(@a.analyzed_classes.include?("Rcov::Test::Temporary::Sample03"))
|
83
90
|
assert_equal(%w[f1 f2], @a.analyzed_methods("Rcov::Test::Temporary::Sample03"))
|
84
|
-
verify_callsites_equal({[
|
91
|
+
verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1,
|
92
|
+
"./test/sample_03.rb", 4]] => 10},
|
93
|
+
@a.callsites("Rcov::Test::Temporary::Sample03", "f2"))
|
94
|
+
verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1, "./test/sample_03.rb", 4]] => 10},
|
85
95
|
@a.callsites("Rcov::Test::Temporary::Sample03", "f2"))
|
86
96
|
callsites = @a.callsites("Rcov::Test::Temporary::Sample03", "f2")
|
87
97
|
callsite = callsites.keys[0]
|
88
98
|
assert_equal("./test/sample_03.rb", callsite.file)
|
89
99
|
assert_equal(4, callsite.line)
|
90
|
-
assert_equal(
|
100
|
+
assert_equal(:f1, callsite.calling_method)
|
91
101
|
end
|
92
102
|
|
103
|
+
|
93
104
|
def test_basic_callsite_recording_with_singleton_classes
|
94
105
|
@a.run_hooked{ @o.class.g1 }
|
95
106
|
assert(@a.analyzed_classes.include?("#<Class:Rcov::Test::Temporary::Sample03>"))
|
96
107
|
assert_equal(%w[g1 g2], @a.analyzed_methods("#<Class:Rcov::Test::Temporary::Sample03>"))
|
97
|
-
verify_callsites_equal({[
|
108
|
+
verify_callsites_equal({[[class << Rcov::Test::Temporary::Sample03; self end,
|
109
|
+
:g1, "./test/sample_03.rb", 15]] => 10},
|
98
110
|
@a.callsites("Rcov::Test::Temporary::Sample03.g2"))
|
99
|
-
verify_callsites_equal({[
|
111
|
+
verify_callsites_equal({[[class << Rcov::Test::Temporary::Sample03; self end,
|
112
|
+
:g1, "./test/sample_03.rb", 15]] => 10},
|
100
113
|
@a.callsites("#<Class:Rcov::Test::Temporary::Sample03>","g2"))
|
101
114
|
end
|
102
115
|
|
@@ -105,19 +118,23 @@ class Test_CallSiteAnalyzer < Test::Unit::TestCase
|
|
105
118
|
@a.run_hooked{ @o.f1 }
|
106
119
|
assert(@a.analyzed_classes.include?("Rcov::Test::Temporary::Sample03"))
|
107
120
|
assert_equal(%w[f1 f2], @a.analyzed_methods("Rcov::Test::Temporary::Sample03"))
|
108
|
-
verify_callsites_equal({[
|
121
|
+
verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1,
|
122
|
+
"./test/sample_03.rb", 4]] => 10},
|
109
123
|
@a.callsites("Rcov::Test::Temporary::Sample03", "f2"))
|
110
124
|
|
111
125
|
@a.run_hooked{ @o.f1 }
|
112
126
|
assert(@a.analyzed_classes.include?("Rcov::Test::Temporary::Sample03"))
|
113
127
|
assert_equal(%w[f1 f2], @a.analyzed_methods("Rcov::Test::Temporary::Sample03"))
|
114
|
-
verify_callsites_equal({[
|
128
|
+
verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1,
|
129
|
+
"./test/sample_03.rb", 4]] => 20},
|
115
130
|
@a.callsites("Rcov::Test::Temporary::Sample03", "f2"))
|
116
131
|
|
117
132
|
@a.run_hooked{ @o.f3 }
|
118
133
|
assert_equal(%w[f1 f2 f3], @a.analyzed_methods("Rcov::Test::Temporary::Sample03"))
|
119
|
-
verify_callsites_equal({[
|
120
|
-
|
134
|
+
verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1,
|
135
|
+
"./test/sample_03.rb", 4]] => 120,
|
136
|
+
[[Rcov::Test::Temporary::Sample03, :f3,
|
137
|
+
"./test/sample_03.rb", 11]]=>100 },
|
121
138
|
@a.callsites("Rcov::Test::Temporary::Sample03", "f2"))
|
122
139
|
end
|
123
140
|
|
@@ -129,7 +146,8 @@ class Test_CallSiteAnalyzer < Test::Unit::TestCase
|
|
129
146
|
end
|
130
147
|
assert(@a.analyzed_classes.include?("Rcov::Test::Temporary::Sample03"))
|
131
148
|
assert_equal(%w[f1 f2], @a.analyzed_methods("Rcov::Test::Temporary::Sample03"))
|
132
|
-
verify_callsites_equal({[
|
149
|
+
verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1,
|
150
|
+
"./test/sample_03.rb", 4]] => 10},
|
133
151
|
@a.callsites("Rcov::Test::Temporary::Sample03", "f2"))
|
134
152
|
|
135
153
|
end
|
@@ -141,23 +159,28 @@ class Test_CallSiteAnalyzer < Test::Unit::TestCase
|
|
141
159
|
b.run_hooked { @o.f1 }
|
142
160
|
assert(b.analyzed_classes.include?("Rcov::Test::Temporary::Sample03"))
|
143
161
|
assert_equal(%w[f1 f2], b.analyzed_methods("Rcov::Test::Temporary::Sample03"))
|
144
|
-
verify_callsites_equal({[
|
162
|
+
verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1,
|
163
|
+
"./test/sample_03.rb", 4]] => 10},
|
145
164
|
b.callsites("Rcov::Test::Temporary::Sample03", "f2"))
|
146
165
|
|
147
166
|
@o.f1
|
148
167
|
assert_equal(%w[f1 f2], b.analyzed_methods("Rcov::Test::Temporary::Sample03"))
|
149
|
-
verify_callsites_equal({[
|
168
|
+
verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1,
|
169
|
+
"./test/sample_03.rb", 4]] => 10},
|
150
170
|
b.callsites("Rcov::Test::Temporary::Sample03", "f2"))
|
151
171
|
|
152
172
|
assert(a.analyzed_classes.include?("Rcov::Test::Temporary::Sample03"))
|
153
173
|
assert_equal(%w[f1 f2], a.analyzed_methods("Rcov::Test::Temporary::Sample03"))
|
154
|
-
verify_callsites_equal({[
|
174
|
+
verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1,
|
175
|
+
"./test/sample_03.rb", 4]] => 20},
|
155
176
|
a.callsites("Rcov::Test::Temporary::Sample03", "f2"))
|
156
177
|
end
|
157
178
|
b.run_hooked{ @o.f3 }
|
158
179
|
assert_equal(%w[f1 f2 f3], b.analyzed_methods("Rcov::Test::Temporary::Sample03"))
|
159
|
-
verify_callsites_equal({[
|
160
|
-
|
180
|
+
verify_callsites_equal({[[Rcov::Test::Temporary::Sample03, :f1,
|
181
|
+
"./test/sample_03.rb", 4]] => 110,
|
182
|
+
[[Rcov::Test::Temporary::Sample03, :f3,
|
183
|
+
"./test/sample_03.rb", 11]]=>100 },
|
161
184
|
b.callsites("Rcov::Test::Temporary::Sample03", "f2"))
|
162
185
|
end
|
163
186
|
|
@@ -28,7 +28,7 @@ EOF
|
|
28
28
|
cover = [1, 1, nil, nil, 0, 5, 5, 5, 0]
|
29
29
|
line_info, marked_info,
|
30
30
|
count_info = analyzer.instance_eval{ refine_coverage_info(LINES, cover) }
|
31
|
-
assert_equal(LINES
|
31
|
+
assert_equal(LINES, line_info)
|
32
32
|
assert_equal([true] * 2 + [false] * 3 + [true] * 3 + [false], marked_info)
|
33
33
|
assert_equal([1, 1, 0, 0, 0, 5, 5, 5, 0], count_info)
|
34
34
|
end
|
@@ -47,7 +47,7 @@ EOF
|
|
47
47
|
assert_equal(lines, SCRIPT_LINES__[sample_file][0, lines.size])
|
48
48
|
assert(analyzer.analyzed_files.include?(sample_file))
|
49
49
|
line_info, cov_info, count_info = analyzer.data(sample_file)
|
50
|
-
assert_equal(lines
|
50
|
+
assert_equal(lines, line_info)
|
51
51
|
assert_equal([true, true, false, false, true, false, true], cov_info)
|
52
52
|
assert_equal([1, 2, 0, 0, 1, 0, 11], count_info)
|
53
53
|
analyzer.reset
|
data/test/test_FileStatistics.rb
CHANGED
@@ -92,7 +92,7 @@ class Test_FileStatistics < Test::Unit::TestCase
|
|
92
92
|
1 if bar
|
93
93
|
0 b = 2
|
94
94
|
0 end
|
95
|
-
|
95
|
+
1 puts <<EOF
|
96
96
|
0 bleh
|
97
97
|
0 EOF
|
98
98
|
3 c.times{ i += 1}
|
@@ -113,7 +113,33 @@ class Test_FileStatistics < Test::Unit::TestCase
|
|
113
113
|
assert_equal(expected, sf2.coverage.to_a)
|
114
114
|
sf.merge(sf2.lines, sf2.coverage, sf2.counts)
|
115
115
|
assert_equal(expected, sf.coverage.to_a)
|
116
|
-
assert_equal([2, 2, 1, 0,
|
116
|
+
assert_equal([2, 2, 1, 0, 2, 0, 0, 13], sf.counts)
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_last_comment_block_is_marked
|
120
|
+
verify_everything_marked "last comment block", <<-EOF
|
121
|
+
1 a = 1
|
122
|
+
1 b = 1
|
123
|
+
0 # foo
|
124
|
+
0 # bar baz
|
125
|
+
EOF
|
126
|
+
verify_everything_marked "last comment block, =begin/=end", <<-EOF
|
127
|
+
1 a = 1
|
128
|
+
2 b = 1
|
129
|
+
0 # fooo
|
130
|
+
0 =begin
|
131
|
+
0 bar baz
|
132
|
+
0 =end
|
133
|
+
EOF
|
134
|
+
verify_everything_marked "last comment block, __END__", <<-EOF
|
135
|
+
1 a = 1
|
136
|
+
2 b = 1
|
137
|
+
0 # fooo
|
138
|
+
0 =begin
|
139
|
+
0 bar baz
|
140
|
+
0 =end
|
141
|
+
__END__
|
142
|
+
EOF
|
117
143
|
end
|
118
144
|
|
119
145
|
def test_heredocs_basic
|
@@ -209,6 +235,19 @@ class Test_FileStatistics < Test::Unit::TestCase
|
|
209
235
|
EOF
|
210
236
|
end
|
211
237
|
|
238
|
+
def test_heredocs_with_interpolation_alone_in_method
|
239
|
+
verify_everything_marked "lonely heredocs with interpolation", <<-'EOS'
|
240
|
+
1 def to_s
|
241
|
+
0 <<-EOF
|
242
|
+
1 #{name}
|
243
|
+
0 #{street}
|
244
|
+
0 #{city}, #{state}
|
245
|
+
0 #{zip}
|
246
|
+
0 EOF
|
247
|
+
0 end
|
248
|
+
EOS
|
249
|
+
end
|
250
|
+
|
212
251
|
def test_handle_multiline_expressions
|
213
252
|
verify_everything_marked "expression", <<-EOF
|
214
253
|
1 puts 1, 2.
|
@@ -253,6 +292,37 @@ class Test_FileStatistics < Test::Unit::TestCase
|
|
253
292
|
EOF
|
254
293
|
end
|
255
294
|
|
295
|
+
def test_handle_multiline_blocks_first_not_marked
|
296
|
+
verify_everything_marked "multiline block first not marked", <<-'EOF'
|
297
|
+
1 blah = Array.new
|
298
|
+
1 10.times do
|
299
|
+
0 blah << lambda do |f|
|
300
|
+
1 puts "I should say #{f}!"
|
301
|
+
0 end
|
302
|
+
0 end
|
303
|
+
EOF
|
304
|
+
end
|
305
|
+
|
306
|
+
def test_handle_multiline_blocks_last_line_not_marked
|
307
|
+
verify_everything_marked "multiline block last not marked", <<-'EOF'
|
308
|
+
1 blee = [1, 2, 3]
|
309
|
+
0 blee.map! do |e|
|
310
|
+
1 [e, e]
|
311
|
+
0 end.flatten!
|
312
|
+
1 p blee
|
313
|
+
EOF
|
314
|
+
end
|
315
|
+
|
316
|
+
def test_handle_multiline_data_with_trailing_stuff_on_last_line
|
317
|
+
verify_everything_marked "multiline data hash", <<-'EOF'
|
318
|
+
1 @review = Review.new({
|
319
|
+
0 :product_id => params[:id],
|
320
|
+
0 :user => current_user
|
321
|
+
0 }.merge(params[:review])) #red
|
322
|
+
1 @review.save
|
323
|
+
EOF
|
324
|
+
end
|
325
|
+
|
256
326
|
def test_handle_multiline_expression_1st_line_ends_in_block_header
|
257
327
|
# excerpt taken from mongrel/handlers.rb
|
258
328
|
verify_everything_marked "multiline with block starting on 1st", <<-EOF
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rcov
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2006-
|
6
|
+
version: 0.6.0.1
|
7
|
+
date: 2006-06-12 00:00:00 +02:00
|
8
8
|
summary: Code coverage analysis tool for Ruby
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- lib/rcov/version.rb
|
35
35
|
- lib/rcov/lowlevel.rb
|
36
36
|
- lib/rcov/rant.rb
|
37
|
+
- lib/rcov/report.rb
|
37
38
|
- ext/rcovrt/extconf.rb
|
38
39
|
- ext/rcovrt/rcov.c
|
39
40
|
- LEGAL
|
@@ -43,6 +44,7 @@ files:
|
|
43
44
|
- README.en
|
44
45
|
- README.rake
|
45
46
|
- README.API
|
47
|
+
- README.vim
|
46
48
|
- README.rant
|
47
49
|
- THANKS
|
48
50
|
- test/sample_02.rb
|
@@ -68,6 +70,8 @@ rdoc_options:
|
|
68
70
|
extra_rdoc_files:
|
69
71
|
- README.API
|
70
72
|
- README.rake
|
73
|
+
- README.rant
|
74
|
+
- README.vim
|
71
75
|
executables:
|
72
76
|
- rcov
|
73
77
|
extensions:
|