relevance-rcov 0.8.3.2 → 0.8.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/BLURB +0 -38
- data/LICENSE +2 -5
- data/Rakefile +3 -0
- data/bin/rcov +164 -218
- data/ext/rcovrt/1.8/callsite.c +122 -148
- data/ext/rcovrt/1.8/rcovrt.c +187 -231
- data/ext/rcovrt/1.9/callsite.c +83 -107
- data/ext/rcovrt/1.9/rcovrt.c +174 -225
- data/lib/rcov/templates/screen.css +54 -34
- metadata +3 -2
- data/LEGAL +0 -36
data/BLURB
CHANGED
@@ -1,10 +1,3 @@
|
|
1
|
-
|
2
|
-
Source code, additional information, screenshots... available at
|
3
|
-
http://eigenclass.org/hiki/rcov
|
4
|
-
|
5
|
-
If you're on win32, you can also find a pre-built rcovrt.so (which makes
|
6
|
-
code coverage analysis >100 times faster) in the above-mentioned pages.
|
7
|
-
|
8
1
|
Overview
|
9
2
|
========
|
10
3
|
rcov is a code coverage tool for Ruby. It is commonly used for viewing overall
|
@@ -48,8 +41,6 @@ description of the available options.
|
|
48
41
|
Sample output
|
49
42
|
=============
|
50
43
|
|
51
|
-
See http://eigenclass.org/hiki.rb?rcov (once again) for screenshots.
|
52
|
-
|
53
44
|
The text report (also used by default in RcovTasks) resembles
|
54
45
|
|
55
46
|
|
@@ -118,32 +109,3 @@ tests:
|
|
118
109
|
License
|
119
110
|
-------
|
120
111
|
rcov is released under the terms of Ruby's license.
|
121
|
-
rcov includes xx 0.1.0, which is subject to the following conditions:
|
122
|
-
|
123
|
-
ePark Labs Public License version 1
|
124
|
-
Copyright (c) 2005, ePark Labs, Inc. and contributors
|
125
|
-
All rights reserved.
|
126
|
-
|
127
|
-
Redistribution and use in source and binary forms, with or without modification,
|
128
|
-
are permitted provided that the following conditions are met:
|
129
|
-
|
130
|
-
1. Redistributions of source code must retain the above copyright notice, this
|
131
|
-
list of conditions and the following disclaimer.
|
132
|
-
2. Redistributions in binary form must reproduce the above copyright notice,
|
133
|
-
this list of conditions and the following disclaimer in the documentation
|
134
|
-
and/or other materials provided with the distribution.
|
135
|
-
3. Neither the name of ePark Labs nor the names of its contributors may be
|
136
|
-
used to endorse or promote products derived from this software without
|
137
|
-
specific prior written permission.
|
138
|
-
|
139
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
140
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
141
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
142
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
143
|
-
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
144
|
-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
145
|
-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
146
|
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
147
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
148
|
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
149
|
-
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
rcov is copyrighted free software by Mauricio Fernandez <mfp@acm.org>.
|
2
|
-
You can redistribute it and/or modify it under either the terms of the GPL
|
3
|
-
|
2
|
+
You can redistribute it and/or modify it under either the terms of the GPL,
|
3
|
+
or the conditions below:
|
4
4
|
|
5
5
|
1. You may make and give away verbatim copies of the source form of the
|
6
6
|
software without restriction, provided that you duplicate all of the
|
@@ -41,9 +41,6 @@ You can redistribute it and/or modify it under either the terms of the GPL
|
|
41
41
|
software (possibly commercial). But some files in the distribution
|
42
42
|
are not written by the author, so that they are not under these terms.
|
43
43
|
|
44
|
-
For the list of those files and their copying conditions, see the
|
45
|
-
file LEGAL.
|
46
|
-
|
47
44
|
5. The scripts and library files supplied as input to or produced as
|
48
45
|
output from the software do not automatically fall under the
|
49
46
|
copyright of the software, but belong to whomever generated them,
|
data/Rakefile
CHANGED
@@ -10,6 +10,9 @@ require 'rake/rdoctask'
|
|
10
10
|
require 'rake/gempackagetask'
|
11
11
|
require 'rake/clean'
|
12
12
|
|
13
|
+
puts "************\n#{ENV["PATH"]}\n************\n"
|
14
|
+
puts "************\n#{RUBY_VERSION}\n************"
|
15
|
+
|
13
16
|
# Use the specified rcov executable instead of the one in $PATH
|
14
17
|
# (this way we get a sort of informal functional test).
|
15
18
|
# This could also be specified from the command like, e.g.
|
data/bin/rcov
CHANGED
@@ -65,6 +65,10 @@ $PROGRAM_NAME (aka. $0) will be set before each file is load()ed if
|
|
65
65
|
--replace-progname is used.
|
66
66
|
EOF
|
67
67
|
|
68
|
+
def deprecated(opt)
|
69
|
+
puts "#{opt} is now depricated. Please remove it from you Rakefile or scripts. It will be removed in the next release."
|
70
|
+
end
|
71
|
+
|
68
72
|
#{{{ OptionParser
|
69
73
|
opts = OptionParser.new do |opts|
|
70
74
|
opts.banner = <<-EOF
|
@@ -73,29 +77,31 @@ Usage: rcov [options] <script1.rb> [script2.rb] [-- --extra-options]
|
|
73
77
|
EOF
|
74
78
|
opts.separator ""
|
75
79
|
opts.separator "Options:"
|
80
|
+
|
76
81
|
opts.on("-o", "--output PATH", "Destination directory.") do |dir|
|
77
|
-
|
82
|
+
options.destdir = dir
|
78
83
|
end
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
end
|
83
|
-
opts.on("--[no-]comments",
|
84
|
-
"Mark all comments by default.",
|
85
|
-
"(default: --no-comments)") do |comments_run_p|
|
86
|
-
options.comments_run_by_default = comments_run_p
|
84
|
+
|
85
|
+
opts.on("-I", "--include PATHS", "Prepend PATHS to $: (colon separated list)") do |paths|
|
86
|
+
options.loadpaths = paths.split(/:/)
|
87
87
|
end
|
88
|
-
|
89
|
-
|
90
|
-
|
88
|
+
|
89
|
+
opts.on("--[no-]comments", "Mark all comments by default.", "(default: --no-comments)") do |comments_run_p|
|
90
|
+
options.comments_run_by_default = comments_run_p
|
91
91
|
end
|
92
|
-
|
93
|
-
|
94
|
-
|
92
|
+
|
93
|
+
opts.on("--test-unit-only", "Only trace code executed inside TestCases.") do
|
94
|
+
deprecated("--test-unit-only")
|
95
95
|
end
|
96
|
+
|
97
|
+
opts.on("--spec-only", "Only trace code executed inside RSpec specs.") do
|
98
|
+
deprecated("--spec-only")
|
99
|
+
end
|
100
|
+
|
96
101
|
opts.on("-n", "--no-color", "Create colorblind-safe output.") do
|
97
|
-
|
102
|
+
options.color = false
|
98
103
|
end
|
104
|
+
|
99
105
|
opts.on("-i", "--include-file PATTERNS",
|
100
106
|
"Generate info for files matching a",
|
101
107
|
"pattern (comma-separated regexp list)") do |list|
|
@@ -106,77 +112,81 @@ EOF
|
|
106
112
|
raise OptionParser::InvalidArgument, e.message
|
107
113
|
end
|
108
114
|
end
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
opts.on("--exclude-only PATTERNS",
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
end
|
115
|
+
|
116
|
+
opts.on("-x", "--exclude PATTERNS", "Don't generate info for files matching a","pattern (comma-separated regexp list)") do |list|
|
117
|
+
begin
|
118
|
+
regexps = list.split(/,/).map{|x| Regexp.new x}
|
119
|
+
options.skip += regexps
|
120
|
+
rescue RegexpError => e
|
121
|
+
raise OptionParser::InvalidArgument, e.message
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
opts.on("--exclude-only PATTERNS", "Skip info only for files matching the", "given patterns.") do |list|
|
126
|
+
begin
|
127
|
+
options.skip = list.split(/,/).map{|x| Regexp.new(x) }
|
128
|
+
rescue RegexpError => e
|
129
|
+
raise OptionParser::InvalidArgument, e.message
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
128
133
|
opts.on("--rails", "Skip config/, environment/ and vendor/.") do
|
129
|
-
|
134
|
+
options.skip.concat [%r{\bvendor/},%r{\bconfig/},%r{\benvironment/}]
|
130
135
|
end
|
131
|
-
|
132
|
-
|
133
|
-
|
136
|
+
|
137
|
+
opts.on("--[no-]callsites", "Show callsites in generated XHTML report.", "(somewhat slower; disabled by default)") do |val|
|
138
|
+
options.callsites = val
|
134
139
|
end
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
140
|
+
|
141
|
+
opts.on("--[no-]xrefs", "Generate fully cross-referenced report.", "(includes --callsites)") do |val|
|
142
|
+
options.crossrefs = val
|
143
|
+
options.callsites ||= val
|
139
144
|
end
|
145
|
+
|
140
146
|
opts.on("-p", "--profile", "Generate bogo-profiling info.") do
|
141
|
-
|
142
|
-
|
147
|
+
options.profiling = true
|
148
|
+
options.destdir ||= "profiling"
|
143
149
|
end
|
144
|
-
|
145
|
-
|
146
|
-
|
150
|
+
|
151
|
+
opts.on("-r", "--range RANGE", Float, "Color scale range for profiling info (dB).") do |val|
|
152
|
+
options.range = val
|
147
153
|
end
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
154
|
+
|
155
|
+
opts.on("-a", "--annotate", "Generate annotated source code.") do
|
156
|
+
options.html = false
|
157
|
+
options.textmode = :annotate
|
158
|
+
options.crossrefs = true
|
159
|
+
options.callsites = true
|
160
|
+
options.skip = [ %r!/test/unit/! ]
|
155
161
|
end
|
156
162
|
|
157
|
-
opts.on("-T", "--text-report", "Dump detailed plain-text report to stdout.",
|
158
|
-
|
159
|
-
options.textmode = :report
|
163
|
+
opts.on("-T", "--text-report", "Dump detailed plain-text report to stdout.", "(filename, LoC, total lines, coverage)") do
|
164
|
+
options.textmode = :report
|
160
165
|
end
|
166
|
+
|
161
167
|
opts.on("-t", "--text-summary", "Dump plain-text summary to stdout.") do
|
162
|
-
|
168
|
+
options.textmode = :summary
|
163
169
|
end
|
170
|
+
|
164
171
|
opts.on("--text-counts", "Dump execution counts in plaintext.") do
|
165
|
-
|
172
|
+
options.textmode = :counts
|
166
173
|
end
|
167
|
-
|
168
|
-
|
169
|
-
|
174
|
+
|
175
|
+
opts.on("--text-coverage", "Dump coverage info to stdout, using", "ANSI color sequences unless -n.") do
|
176
|
+
options.textmode = :coverage
|
170
177
|
end
|
178
|
+
|
171
179
|
opts.on("--gcc", "Dump uncovered line in GCC error format.") do
|
172
|
-
|
180
|
+
options.gcc_output = true
|
173
181
|
end
|
182
|
+
|
174
183
|
opts.on("--aggregate FILE", "Aggregate data from previous runs",
|
175
184
|
"in FILE. Overwrites FILE with the",
|
176
185
|
"merged data. FILE is created if",
|
177
186
|
"necessary.") do |file|
|
178
187
|
options.aggregate_file = file
|
179
188
|
end
|
189
|
+
|
180
190
|
opts.on("-D [FILE]", "--text-coverage-diff [FILE]",
|
181
191
|
"Compare code coverage with saved state",
|
182
192
|
"in FILE, defaults to coverage.info.",
|
@@ -189,77 +199,79 @@ EOF
|
|
189
199
|
options.coverage_diff_mode = :compare
|
190
200
|
options.coverage_diff_file = file if file && !file.empty?
|
191
201
|
end
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
options.coverage_diff_file = file if file && !file.empty?
|
202
|
+
|
203
|
+
opts.on("--save [FILE]", "Save coverage data to FILE,", "for later use with rcov -D.", "(default: coverage.info)") do |file|
|
204
|
+
options.coverage_diff_save = true
|
205
|
+
options.coverage_diff_mode = :record
|
206
|
+
if options.textmode == :coverage_diff
|
207
|
+
raise "You shouldn't use --save and --text-coverage-diff at a time."
|
208
|
+
end
|
209
|
+
options.coverage_diff_file = file if file && !file.empty?
|
201
210
|
end
|
202
|
-
|
203
|
-
|
204
|
-
|
211
|
+
|
212
|
+
opts.on("--[no-]html", "Generate HTML output.", "(default: --html)") do |val|
|
213
|
+
options.html = val
|
205
214
|
end
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
options.sort = criterion
|
215
|
+
|
216
|
+
opts.on("--sort CRITERION", [:name, :loc, :coverage], "Sort files in the output by the specified", "field (name, loc, coverage)") do |criterion|
|
217
|
+
options.sort = criterion
|
210
218
|
end
|
219
|
+
|
211
220
|
opts.on("--sort-reverse", "Reverse files in the output.") do
|
212
|
-
|
213
|
-
end
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
221
|
+
options.sort_reverse = true
|
222
|
+
end
|
223
|
+
|
224
|
+
opts.on("--threshold INT", "Only list files with coverage < INT %.", "(default: 101)") do |threshold|
|
225
|
+
begin
|
226
|
+
threshold = Integer(threshold)
|
227
|
+
raise if threshold <= 0 || threshold > 101
|
228
|
+
rescue Exception
|
229
|
+
raise OptionParser::InvalidArgument, threshold
|
230
|
+
end
|
231
|
+
options.output_threshold = threshold
|
223
232
|
end
|
224
233
|
|
225
|
-
opts.on("--charset CHARSET",
|
226
|
-
"Charset used in Content-Type declaration of HTML reports.") do |c|
|
234
|
+
opts.on("--charset CHARSET", "Charset used in Content-Type declaration of HTML reports.") do |c|
|
227
235
|
options.charset = c
|
228
236
|
end
|
229
237
|
|
230
238
|
opts.on("--only-uncovered", "Same as --threshold 100") do
|
231
239
|
options.output_threshold = 100
|
232
240
|
end
|
241
|
+
|
233
242
|
opts.on("--replace-progname", "Replace $0 when loading the .rb files.") do
|
234
243
|
options.replace_prog_name = true
|
235
244
|
end
|
245
|
+
|
236
246
|
opts.on("-w", "Turn warnings on (like ruby).") do
|
237
247
|
$VERBOSE = true
|
238
248
|
end
|
239
|
-
|
240
|
-
|
249
|
+
|
250
|
+
opts.on("--no-rcovrt", "Do not use the optimized C runtime.", "(will run 30-300 times slower)") do
|
241
251
|
$rcov_do_not_use_rcovrt = true
|
242
252
|
end
|
253
|
+
|
243
254
|
opts.on("--diff-cmd PROGNAME", "Use PROGNAME for --text-coverage-diff.",
|
244
255
|
"(default: diff)") do |cmd|
|
245
256
|
options.diff_cmd = cmd
|
246
257
|
end
|
258
|
+
|
247
259
|
opts.separator ""
|
260
|
+
|
248
261
|
opts.on_tail("-h", "--help", "Show extended help message") do
|
249
|
-
|
250
|
-
|
262
|
+
require 'pp'
|
263
|
+
puts opts
|
251
264
|
puts <<EOF
|
252
265
|
|
253
266
|
Files matching any of the following regexps will be omitted in the report(s):
|
254
267
|
#{PP.pp(options.skip, "").chomp}
|
255
268
|
EOF
|
256
|
-
|
257
|
-
|
269
|
+
puts EXTRA_HELP
|
270
|
+
exit
|
258
271
|
end
|
259
|
-
|
260
|
-
|
261
|
-
"method specified by SELECTOR",
|
262
|
-
"(format: Foo::Bar#method, A::B.method)") do |selector|
|
272
|
+
|
273
|
+
opts.on_tail("--report-cov-bug SELECTOR", "Report coverage analysis bug for the",
|
274
|
+
"method specified by SELECTOR", "(format: Foo::Bar#method, A::B.method)") do |selector|
|
263
275
|
case selector
|
264
276
|
when /([^.]+)(#|\.)(.*)/ then options.report_cov_bug_for = selector
|
265
277
|
else
|
@@ -277,25 +289,25 @@ end
|
|
277
289
|
|
278
290
|
$ORIGINAL_ARGV = ARGV.clone
|
279
291
|
if (idx = ARGV.index("--"))
|
280
|
-
|
281
|
-
|
292
|
+
extra_args = ARGV[idx+1..-1]
|
293
|
+
ARGV.replace(ARGV[0,idx])
|
282
294
|
else
|
283
|
-
|
295
|
+
extra_args = []
|
284
296
|
end
|
285
297
|
|
286
298
|
begin
|
287
|
-
|
288
|
-
rescue OptionParser::InvalidOption, OptionParser::InvalidArgument,
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
exit(-1)
|
299
|
+
opts.parse! ARGV
|
300
|
+
rescue OptionParser::InvalidOption, OptionParser::InvalidArgument, OptionParser::MissingArgument => e
|
301
|
+
puts opts
|
302
|
+
puts
|
303
|
+
puts e.message
|
304
|
+
exit(-1)
|
294
305
|
end
|
306
|
+
|
295
307
|
options.destdir ||= "coverage"
|
296
308
|
unless ARGV[0] or options.aggregate_file && File.file?(options.aggregate_file)
|
297
|
-
|
298
|
-
|
309
|
+
puts opts
|
310
|
+
exit
|
299
311
|
end
|
300
312
|
|
301
313
|
# {{{ set loadpath
|
@@ -310,14 +322,14 @@ options.callsites = true if options.report_cov_bug_for
|
|
310
322
|
options.textmode = :gcc if !options.textmode and options.gcc_output
|
311
323
|
|
312
324
|
def rcov_load_aggregate_data(file)
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
325
|
+
require 'zlib'
|
326
|
+
begin
|
327
|
+
old_data = nil
|
328
|
+
Zlib::GzipReader.open(file){|gz| old_data = Marshal.load(gz) }
|
329
|
+
rescue
|
330
|
+
old_data = {}
|
331
|
+
end
|
332
|
+
old_data || {}
|
321
333
|
end
|
322
334
|
|
323
335
|
def rcov_save_aggregate_data(file)
|
@@ -328,16 +340,16 @@ def rcov_save_aggregate_data(file)
|
|
328
340
|
end
|
329
341
|
|
330
342
|
if options.callsites
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
end
|
343
|
+
if options.aggregate_file
|
344
|
+
saved_aggregate_data = rcov_load_aggregate_data(options.aggregate_file)
|
345
|
+
if saved_aggregate_data[:callsites]
|
346
|
+
$rcov_callsite_analyzer = saved_aggregate_data[:callsites]
|
336
347
|
end
|
337
|
-
|
338
|
-
|
348
|
+
end
|
349
|
+
$rcov_callsite_analyzer ||= Rcov::CallSiteAnalyzer.new
|
350
|
+
$rcov_callsite_analyzer.install_hook
|
339
351
|
else
|
340
|
-
|
352
|
+
$rcov_callsite_analyzer = nil
|
341
353
|
end
|
342
354
|
|
343
355
|
# {{{ create formatters
|
@@ -362,31 +374,31 @@ make_formatter = lambda do |klass|
|
|
362
374
|
end
|
363
375
|
|
364
376
|
if options.html
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
377
|
+
if options.profiling
|
378
|
+
formatters << make_formatter[Rcov::HTMLProfiling]
|
379
|
+
else
|
380
|
+
formatters << make_formatter[Rcov::HTMLCoverage]
|
381
|
+
end
|
370
382
|
end
|
371
|
-
|
372
|
-
|
373
|
-
:gcc => Rcov::FullTextReport,
|
374
|
-
:annotate => Rcov::RubyAnnotation,
|
383
|
+
|
384
|
+
textual_formatters = { :counts => Rcov::FullTextReport, :coverage => Rcov::FullTextReport,
|
385
|
+
:gcc => Rcov::FullTextReport, :annotate => Rcov::RubyAnnotation,
|
375
386
|
:summary => Rcov::TextSummary, :report => Rcov::TextReport,
|
376
|
-
:coverage_diff => Rcov::TextCoverageDiff}
|
387
|
+
:coverage_diff => Rcov::TextCoverageDiff }
|
377
388
|
|
378
389
|
if textual_formatters[options.textmode]
|
379
|
-
|
390
|
+
formatters << make_formatter[textual_formatters[options.textmode]]
|
380
391
|
end
|
381
392
|
|
382
393
|
formatters << make_formatter[Rcov::TextCoverageDiff] if options.coverage_diff_save
|
383
394
|
|
384
395
|
if options.aggregate_file
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
396
|
+
saved_aggregate_data ||= rcov_load_aggregate_data(options.aggregate_file)
|
397
|
+
if saved_aggregate_data[:coverage]
|
398
|
+
$rcov_code_coverage_analyzer = saved_aggregate_data[:coverage]
|
399
|
+
end
|
389
400
|
end
|
401
|
+
|
390
402
|
$rcov_code_coverage_analyzer ||= Rcov::CodeCoverageAnalyzer.new
|
391
403
|
|
392
404
|
# must be registered before test/unit puts its own
|
@@ -468,87 +480,21 @@ EOF
|
|
468
480
|
raise $__rcov_exit_exception if $__rcov_exit_exception
|
469
481
|
}
|
470
482
|
|
471
|
-
|
472
|
-
require 'test/unit'
|
473
|
-
module Test::Unit
|
474
|
-
class TestCase
|
475
|
-
remove_method(:run) if instance_methods.include? "run"
|
476
|
-
def run(result)
|
477
|
-
yield(STARTED, name)
|
478
|
-
@_result = result
|
479
|
-
begin
|
480
|
-
$rcov_code_coverage_analyzer.run_hooked do
|
481
|
-
setup
|
482
|
-
__send__(@method_name)
|
483
|
-
end
|
484
|
-
rescue AssertionFailedError => e
|
485
|
-
add_failure(e.message, e.backtrace)
|
486
|
-
rescue StandardError, ScriptError
|
487
|
-
add_error($!)
|
488
|
-
ensure
|
489
|
-
begin
|
490
|
-
$rcov_code_coverage_analyzer.run_hooked { teardown }
|
491
|
-
rescue AssertionFailedError => e
|
492
|
-
add_failure(e.message, e.backtrace)
|
493
|
-
rescue StandardError, ScriptError
|
494
|
-
add_error($!)
|
495
|
-
end
|
496
|
-
end
|
497
|
-
result.add_run
|
498
|
-
yield(FINISHED, name)
|
499
|
-
end
|
500
|
-
end
|
501
|
-
end
|
502
|
-
elsif options.spec_only
|
503
|
-
require 'spec'
|
504
|
-
override_run = lambda do
|
505
|
-
oldrun = instance_method(:run)
|
506
|
-
define_method(:run) do |*args|
|
507
|
-
$rcov_code_coverage_analyzer.run_hooked { oldrun.bind(self).call(*args) }
|
508
|
-
end
|
509
|
-
end
|
510
|
-
|
511
|
-
if defined?(Spec::DSL::Example)
|
512
|
-
Spec::DSL::Example.instance_eval(&override_run)
|
513
|
-
elsif defined?(Spec::Example::ExampleMethods)
|
514
|
-
override_run = lambda do
|
515
|
-
oldexecute = instance_method(:execute)
|
516
|
-
define_method(:execute) do |*args|
|
517
|
-
$rcov_code_coverage_analyzer.run_hooked { oldexecute.bind(self).call(*args) }
|
518
|
-
end
|
519
|
-
end
|
520
|
-
Spec::Example::ExampleMethods.instance_eval(&override_run)
|
521
|
-
elsif defined?(Spec::Example::ExampleGroup)
|
522
|
-
Spec::Example::ExampleGroup.instance_eval(&override_run)
|
523
|
-
else
|
524
|
-
$stderr.puts <<-EOF
|
525
|
-
Your RSpec version isn't supported. If it's a old one, consider upgrading;
|
526
|
-
otherwise, please report the problem.
|
527
|
-
EOF
|
528
|
-
exit(-1)
|
529
|
-
end
|
530
|
-
else
|
531
|
-
$rcov_code_coverage_analyzer.install_hook
|
532
|
-
end
|
483
|
+
$rcov_code_coverage_analyzer.install_hook
|
533
484
|
|
534
485
|
#{{{ Load scripts
|
535
486
|
begin
|
536
|
-
pending_scripts = ARGV.clone
|
537
|
-
ARGV.replace extra_args
|
538
|
-
until pending_scripts.empty?
|
487
|
+
pending_scripts = ARGV.clone
|
488
|
+
ARGV.replace extra_args
|
489
|
+
until pending_scripts.empty?
|
539
490
|
prog = pending_scripts.shift
|
540
491
|
if options.replace_prog_name
|
541
|
-
|
492
|
+
$0 = File.basename(File.expand_path(prog))
|
542
493
|
end
|
543
494
|
load prog
|
544
|
-
end
|
495
|
+
end
|
545
496
|
rescue Object => err
|
546
497
|
$__rcov_exit_exception = err
|
547
498
|
end
|
548
499
|
|
549
500
|
__END__
|
550
|
-
# vi: set sw=4:
|
551
|
-
# Here is Emacs setting. DO NOT REMOVE!
|
552
|
-
# Local Variables:
|
553
|
-
# ruby-indent-level: 4
|
554
|
-
# End:
|