relevance-rcov 0.8.4.1 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,7 +1,3 @@
1
- # This Rakefile serves as an example of how to use Rcov::RcovTask.
2
- # Take a look at the RDoc documentation (or readme_for_rake) for further
3
- # information.
4
-
5
1
  $:.unshift "lib" if File.directory? "lib"
6
2
  require 'rcov/rcovtask'
7
3
  require 'rcov/version'
@@ -10,9 +6,6 @@ require 'rake/rdoctask'
10
6
  require 'rake/gempackagetask'
11
7
  require 'rake/clean'
12
8
 
13
- puts "************\n#{ENV["PATH"]}\n************\n"
14
- puts "************\n#{RUBY_VERSION}\n************"
15
-
16
9
  # Use the specified rcov executable instead of the one in $PATH
17
10
  # (this way we get a sort of informal functional test).
18
11
  # This could also be specified from the command like, e.g.
data/bin/rcov CHANGED
@@ -36,6 +36,7 @@ options.spec_only = false
36
36
  options.sort = :name
37
37
  options.sort_reverse = false
38
38
  options.output_threshold = 101
39
+ options.failure_threshold = nil
39
40
  options.replace_prog_name = false
40
41
  options.callsites = false
41
42
  options.crossrefs = false
@@ -76,216 +77,221 @@ opts = OptionParser.new do |opts|
76
77
  rcov #{Rcov::VERSION} #{Rcov::RELEASE_DATE}
77
78
  Usage: rcov [options] <script1.rb> [script2.rb] [-- --extra-options]
78
79
  EOF
79
- opts.separator ""
80
- opts.separator "Options:"
80
+ opts.separator ""
81
+ opts.separator "Options:"
81
82
 
82
- opts.on("-o", "--output PATH", "Destination directory.") do |dir|
83
- options.destdir = dir
84
- end
85
-
86
- opts.on("-I", "--include PATHS", "Prepend PATHS to $: (colon separated list)") do |paths|
87
- options.loadpaths = paths.split(/:/)
88
- end
89
-
90
- opts.on("--[no-]comments", "Mark all comments by default.", "(default: --no-comments)") do |comments_run_p|
91
- options.comments_run_by_default = comments_run_p
92
- end
93
-
94
- opts.on("--test-unit-only", "Only trace code executed inside TestCases.") do
95
- deprecated("--test-unit-only")
96
- end
97
-
98
- opts.on("--spec-only", "Only trace code executed inside RSpec specs.") do
99
- deprecated("--spec-only")
100
- end
101
-
102
- opts.on("-n", "--no-color", "Create colorblind-safe output.") do
103
- options.color = false
83
+ opts.on("-o", "--output PATH", "Destination directory.") do |dir|
84
+ options.destdir = dir
85
+ end
86
+
87
+ opts.on("-I", "--include PATHS", "Prepend PATHS to $: (colon separated list)") do |paths|
88
+ options.loadpaths = paths.split(/:/)
89
+ end
90
+
91
+ opts.on("--[no-]comments", "Mark all comments by default.", "(default: --no-comments)") do |comments_run_p|
92
+ options.comments_run_by_default = comments_run_p
93
+ end
94
+
95
+ opts.on("--test-unit-only", "Only trace code executed inside TestCases.") do
96
+ deprecated("--test-unit-only")
97
+ end
98
+
99
+ opts.on("--spec-only", "Only trace code executed inside RSpec specs.") do
100
+ deprecated("--spec-only")
101
+ end
102
+
103
+ opts.on("-n", "--no-color", "Create colorblind-safe output.") do
104
+ options.color = false
105
+ end
106
+
107
+ opts.on("-i", "--include-file PATTERNS",
108
+ "Generate info for files matching a",
109
+ "pattern (comma-separated regexp list)") do |list|
110
+ begin
111
+ regexps = list.split(/,/).map{|x| Regexp.new(x) }
112
+ options.include += regexps
113
+ rescue RegexpError => e
114
+ raise OptionParser::InvalidArgument, e.message
104
115
  end
105
-
106
- opts.on("-i", "--include-file PATTERNS",
107
- "Generate info for files matching a",
108
- "pattern (comma-separated regexp list)") do |list|
109
- begin
110
- regexps = list.split(/,/).map{|x| Regexp.new(x) }
111
- options.include += regexps
112
- rescue RegexpError => e
113
- raise OptionParser::InvalidArgument, e.message
114
- end
115
- end
116
-
117
- opts.on("-x", "--exclude PATTERNS", "Don't generate info for files matching a","pattern (comma-separated regexp list)") do |list|
118
- begin
119
- regexps = list.split(/,/).map{|x| Regexp.new x}
116
+ end
117
+
118
+ opts.on("-x", "--exclude PATTERNS", "Don't generate info for files matching a","pattern (comma-separated regexp list)") do |list|
119
+ begin
120
+ regexps = list.split(/,/).map{|x| Regexp.new x}
120
121
  options.skip += regexps
121
- rescue RegexpError => e
122
+ rescue RegexpError => e
122
123
  raise OptionParser::InvalidArgument, e.message
123
- end
124
- end
125
-
126
- opts.on("--exclude-only PATTERNS", "Skip info only for files matching the", "given patterns.") do |list|
127
- begin
128
- options.skip = list.split(/,/).map{|x| Regexp.new(x) }
129
- rescue RegexpError => e
130
- raise OptionParser::InvalidArgument, e.message
131
- end
132
- end
133
-
134
- opts.on("--rails", "Skip config/, environment/ and vendor/.") do
135
- options.skip.concat [%r{\bvendor/},%r{\bconfig/},%r{\benvironment/}]
136
- end
137
-
138
- opts.on("--[no-]callsites", "Show callsites in generated XHTML report.", "(somewhat slower; disabled by default)") do |val|
139
- options.callsites = val
140
- end
141
-
142
- opts.on("--[no-]xrefs", "Generate fully cross-referenced report.", "(includes --callsites)") do |val|
143
- options.crossrefs = val
144
- options.callsites ||= val
145
124
  end
146
-
147
- opts.on("-p", "--profile", "Generate bogo-profiling info.") do
148
- options.profiling = true
149
- options.destdir ||= "profiling"
125
+ end
126
+
127
+ opts.on("--exclude-only PATTERNS", "Skip info only for files matching the", "given patterns.") do |list|
128
+ begin
129
+ options.skip = list.split(/,/).map{|x| Regexp.new(x) }
130
+ rescue RegexpError => e
131
+ raise OptionParser::InvalidArgument, e.message
150
132
  end
151
-
152
- opts.on("-r", "--range RANGE", Float, "Color scale range for profiling info (dB).") do |val|
133
+ end
134
+
135
+ opts.on("--rails", "Skip config/, environment/ and vendor/.") do
136
+ options.skip.concat [%r{\bvendor/},%r{\bconfig/},%r{\benvironment/}]
137
+ end
138
+
139
+ opts.on("--[no-]callsites", "Show callsites in generated XHTML report.", "(somewhat slower; disabled by default)") do |val|
140
+ options.callsites = val
141
+ end
142
+
143
+ opts.on("--[no-]xrefs", "Generate fully cross-referenced report.", "(includes --callsites)") do |val|
144
+ options.crossrefs = val
145
+ options.callsites ||= val
146
+ end
147
+
148
+ opts.on("-p", "--profile", "Generate bogo-profiling info.") do
149
+ options.profiling = true
150
+ options.destdir ||= "profiling"
151
+ end
152
+
153
+ opts.on("-r", "--range RANGE", Float, "Color scale range for profiling info (dB).") do |val|
153
154
  options.range = val
154
- end
155
-
156
- opts.on("-a", "--annotate", "Generate annotated source code.") do
157
- options.html = false
158
- options.textmode = :annotate
159
- options.crossrefs = true
160
- options.callsites = true
161
- options.skip = [ %r!/test/unit/! ]
162
- end
163
-
164
- opts.on("-T", "--text-report", "Dump detailed plain-text report to stdout.", "(filename, LoC, total lines, coverage)") do
165
- options.textmode = :report
166
- end
167
-
168
- opts.on("-t", "--text-summary", "Dump plain-text summary to stdout.") do
169
- options.textmode = :summary
170
- end
171
-
172
- opts.on("--text-counts", "Dump execution counts in plaintext.") do
173
- options.textmode = :counts
174
- end
175
-
176
- opts.on("--text-coverage", "Dump coverage info to stdout, using", "ANSI color sequences unless -n.") do
177
- options.textmode = :coverage
178
- end
179
-
180
- opts.on("--gcc", "Dump uncovered line in GCC error format.") do
181
- options.gcc_output = true
182
- end
183
-
184
- opts.on("--aggregate FILE", "Aggregate data from previous runs",
185
- "in FILE. Overwrites FILE with the",
186
- "merged data. FILE is created if",
187
- "necessary.") do |file|
188
- options.aggregate_file = file
189
- end
190
-
191
- opts.on("-D [FILE]", "--text-coverage-diff [FILE]",
192
- "Compare code coverage with saved state",
193
- "in FILE, defaults to coverage.info.",
194
- "Implies --comments.") do |file|
195
- options.textmode = :coverage_diff
196
- options.comments_run_by_default = true
197
- if options.coverage_diff_save
198
- raise "You shouldn't use --save and --text-coverage-diff at a time."
199
- end
200
- options.coverage_diff_mode = :compare
201
- options.coverage_diff_file = file if file && !file.empty?
202
- end
203
-
204
- opts.on("--save [FILE]", "Save coverage data to FILE,", "for later use with rcov -D.", "(default: coverage.info)") do |file|
205
- options.coverage_diff_save = true
206
- options.coverage_diff_mode = :record
207
- if options.textmode == :coverage_diff
208
- raise "You shouldn't use --save and --text-coverage-diff at a time."
209
- end
210
- options.coverage_diff_file = file if file && !file.empty?
211
- end
212
-
213
- opts.on("--[no-]html", "Generate HTML output.", "(default: --html)") do |val|
214
- options.html = val
215
- end
216
-
217
- opts.on("--sort CRITERION", [:name, :loc, :coverage], "Sort files in the output by the specified", "field (name, loc, coverage)") do |criterion|
218
- options.sort = criterion
219
- end
220
-
221
- opts.on("--sort-reverse", "Reverse files in the output.") do
222
- options.sort_reverse = true
223
- end
224
-
225
- opts.on("--threshold INT", "Only list files with coverage < INT %.", "(default: 101)") do |threshold|
226
- begin
227
- threshold = Integer(threshold)
228
- raise if threshold <= 0 || threshold > 101
229
- rescue Exception
230
- raise OptionParser::InvalidArgument, threshold
231
- end
232
- options.output_threshold = threshold
233
- end
234
-
235
- opts.on("--charset CHARSET", "Charset used in Content-Type declaration of HTML reports.") do |c|
236
- options.charset = c
237
- end
155
+ end
156
+
157
+ opts.on("-a", "--annotate", "Generate annotated source code.") do
158
+ options.html = false
159
+ options.textmode = :annotate
160
+ options.crossrefs = true
161
+ options.callsites = true
162
+ options.skip = [ %r!/test/unit/! ]
163
+ end
164
+
165
+ opts.on("-T", "--text-report", "Dump detailed plain-text report to stdout.", "(filename, LoC, total lines, coverage)") do
166
+ options.textmode = :report
167
+ end
168
+
169
+ opts.on("-t", "--text-summary", "Dump plain-text summary to stdout.") do
170
+ options.textmode = :summary
171
+ end
172
+
173
+ opts.on("--text-counts", "Dump execution counts in plaintext.") do
174
+ options.textmode = :counts
175
+ end
176
+
177
+ opts.on("--text-coverage", "Dump coverage info to stdout, using", "ANSI color sequences unless -n.") do
178
+ options.textmode = :coverage
179
+ end
180
+
181
+ opts.on("--gcc", "Dump uncovered line in GCC error format.") do
182
+ options.gcc_output = true
183
+ end
184
+
185
+ opts.on("--aggregate FILE", "Aggregate data from previous runs",
186
+ "in FILE. Overwrites FILE with the",
187
+ "merged data. FILE is created if",
188
+ "necessary.") do |file|
189
+ options.aggregate_file = file
190
+ end
191
+
192
+ opts.on("-D [FILE]", "--text-coverage-diff [FILE]",
193
+ "Compare code coverage with saved state",
194
+ "in FILE, defaults to coverage.info.",
195
+ "Implies --comments.") do |file|
196
+ options.textmode = :coverage_diff
197
+ options.comments_run_by_default = true
198
+ if options.coverage_diff_save
199
+ raise "You shouldn't use --save and --text-coverage-diff at a time."
200
+ end
201
+ options.coverage_diff_mode = :compare
202
+ options.coverage_diff_file = file if file && !file.empty?
203
+ end
204
+
205
+ opts.on("--save [FILE]", "Save coverage data to FILE,", "for later use with rcov -D.", "(default: coverage.info)") do |file|
206
+ options.coverage_diff_save = true
207
+ options.coverage_diff_mode = :record
208
+ if options.textmode == :coverage_diff
209
+ raise "You shouldn't use --save and --text-coverage-diff at a time."
210
+ end
211
+ options.coverage_diff_file = file if file && !file.empty?
212
+ end
213
+
214
+ opts.on("--[no-]html", "Generate HTML output.", "(default: --html)") do |val|
215
+ options.html = val
216
+ end
217
+
218
+ opts.on("--sort CRITERION", [:name, :loc, :coverage], "Sort files in the output by the specified", "field (name, loc, coverage)") do |criterion|
219
+ options.sort = criterion
220
+ end
221
+
222
+ opts.on("--sort-reverse", "Reverse files in the output.") do
223
+ options.sort_reverse = true
224
+ end
225
+
226
+ opts.on("--threshold INT", "Only list files with coverage < INT %.", "(default: 101)") do |threshold|
227
+ begin
228
+ threshold = Integer(threshold)
229
+ raise if threshold <= 0 || threshold > 101
230
+ rescue Exception
231
+ raise OptionParser::InvalidArgument, threshold
232
+ end
233
+ options.output_threshold = threshold
234
+ end
235
+
236
+ opts.on("--failure-threshold [INT]", "Fail if the coverage is below the threshold", "(default: 100)") do |threshold|
237
+ options.failure_threshold = (threshold || 100).to_i
238
+ options.textmode = :failure_report
239
+ end
238
240
 
239
- opts.on("--only-uncovered", "Same as --threshold 100") do
240
- options.output_threshold = 100
241
- end
242
-
243
- opts.on("--replace-progname", "Replace $0 when loading the .rb files.") do
244
- options.replace_prog_name = true
245
- end
246
-
247
- opts.on("-w", "Turn warnings on (like ruby).") do
248
- $VERBOSE = true
249
- end
250
-
251
- opts.on("--no-rcovrt", "Do not use the optimized C runtime.", "(will run 30-300 times slower)") do
252
- $rcov_do_not_use_rcovrt = true
253
- end
254
-
255
- opts.on("--diff-cmd PROGNAME", "Use PROGNAME for --text-coverage-diff.",
256
- "(default: diff)") do |cmd|
257
- options.diff_cmd = cmd
258
- end
259
-
260
- opts.separator ""
261
-
262
- opts.on_tail("-h", "--help", "Show extended help message") do
263
- require 'pp'
264
- puts opts
265
- puts <<EOF
241
+ opts.on("--charset CHARSET", "Charset used in Content-Type declaration of HTML reports.") do |c|
242
+ options.charset = c
243
+ end
244
+
245
+ opts.on("--only-uncovered", "Same as --threshold 100") do
246
+ options.output_threshold = 100
247
+ end
248
+
249
+ opts.on("--replace-progname", "Replace $0 when loading the .rb files.") do
250
+ options.replace_prog_name = true
251
+ end
252
+
253
+ opts.on("-w", "Turn warnings on (like ruby).") do
254
+ $VERBOSE = true
255
+ end
256
+
257
+ opts.on("--no-rcovrt", "Do not use the optimized C runtime.", "(will run 30-300 times slower)") do
258
+ $rcov_do_not_use_rcovrt = true
259
+ end
260
+
261
+ opts.on("--diff-cmd PROGNAME", "Use PROGNAME for --text-coverage-diff.",
262
+ "(default: diff)") do |cmd|
263
+ options.diff_cmd = cmd
264
+ end
265
+
266
+ opts.separator ""
267
+
268
+ opts.on_tail("-h", "--help", "Show extended help message") do
269
+ require 'pp'
270
+ puts opts
271
+ puts <<EOF
266
272
 
267
273
  Files matching any of the following regexps will be omitted in the report(s):
268
274
  #{PP.pp(options.skip, "").chomp}
269
275
  EOF
270
- puts EXTRA_HELP
271
- exit
272
- end
273
-
274
- opts.on_tail("--report-cov-bug SELECTOR", "Report coverage analysis bug for the",
275
- "method specified by SELECTOR", "(format: Foo::Bar#method, A::B.method)") do |selector|
276
- case selector
277
- when /([^.]+)(#|\.)(.*)/ then options.report_cov_bug_for = selector
278
- else
279
- raise OptionParser::InvalidArgument, selector
280
- end
281
- options.textmode = nil
282
- options.html = false
283
- options.callsites = true
284
- end
285
- opts.on_tail("--version", "Show version") do
286
- puts "rcov " + Rcov::VERSION + " " + Rcov::RELEASE_DATE
287
- exit
288
- end
276
+ puts EXTRA_HELP
277
+ exit
278
+ end
279
+
280
+ opts.on_tail("--report-cov-bug SELECTOR", "Report coverage analysis bug for the",
281
+ "method specified by SELECTOR", "(format: Foo::Bar#method, A::B.method)") do |selector|
282
+ case selector
283
+ when /([^.]+)(#|\.)(.*)/ then options.report_cov_bug_for = selector
284
+ else
285
+ raise OptionParser::InvalidArgument, selector
286
+ end
287
+ options.textmode = nil
288
+ options.html = false
289
+ options.callsites = true
290
+ end
291
+ opts.on_tail("--version", "Show version") do
292
+ puts "rcov " + Rcov::VERSION + " " + Rcov::RELEASE_DATE
293
+ exit
294
+ end
289
295
  end
290
296
 
291
297
  $ORIGINAL_ARGV = ARGV.clone
@@ -370,7 +376,8 @@ make_formatter = lambda do |klass|
370
376
  :diff_cmd => options.diff_cmd,
371
377
  :comments_run_by_default => options.comments_run_by_default,
372
378
  :gcc_output => options.gcc_output,
373
- :charset => options.charset
379
+ :charset => options.charset,
380
+ :failure_threshold => options.failure_threshold
374
381
  )
375
382
  end
376
383
 
@@ -385,7 +392,7 @@ end
385
392
  textual_formatters = { :counts => Rcov::FullTextReport, :coverage => Rcov::FullTextReport,
386
393
  :gcc => Rcov::FullTextReport, :annotate => Rcov::RubyAnnotation,
387
394
  :summary => Rcov::TextSummary, :report => Rcov::TextReport,
388
- :coverage_diff => Rcov::TextCoverageDiff }
395
+ :coverage_diff => Rcov::TextCoverageDiff, :failure_report => Rcov::FailureReport }
389
396
 
390
397
  if textual_formatters[options.textmode]
391
398
  formatters << make_formatter[textual_formatters[options.textmode]]
@@ -10,6 +10,7 @@ module Rcov
10
10
 
11
11
  def initialize(opts = {})
12
12
  options = DEFAULT_OPTS.clone.update(opts)
13
+ @failure_threshold = options[:failure_threshold]
13
14
  @files = {}
14
15
  @ignore_files = options[:ignore]
15
16
  @dont_ignore_files = options[:dont_ignore]
@@ -0,0 +1,12 @@
1
+ module Rcov
2
+ class FailureReport < TextSummary # :nodoc:
3
+ def execute
4
+ puts summary
5
+ coverage = code_coverage * 100
6
+ if coverage < @failure_threshold
7
+ puts "You failed to satisfy the coverage theshold of #{@failure_threshold}%"
8
+ exit(1)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,7 +1,5 @@
1
1
  module Rcov
2
-
3
2
  class TextSummary < BaseFormatter # :nodoc:
4
-
5
3
  def execute
6
4
  puts summary
7
5
  end
@@ -9,7 +7,5 @@ module Rcov
9
7
  def summary
10
8
  "%.1f%% %d file(s) %d Lines %d LOC" % [code_coverage * 100, @files.size, num_lines, num_code_lines]
11
9
  end
12
-
13
10
  end
14
-
15
- end
11
+ end
@@ -5,11 +5,9 @@ require 'rcov/formatters/text_report'
5
5
  require 'rcov/formatters/text_coverage_diff'
6
6
  require 'rcov/formatters/full_text_report'
7
7
  require 'rcov/formatters/html_coverage'
8
+ require 'rcov/formatters/failure_report'
8
9
 
9
10
  module Rcov
10
-
11
11
  module Formatters
12
-
13
12
  end
14
-
15
- end
13
+ end
data/lib/rcov/version.rb CHANGED
@@ -3,8 +3,8 @@
3
3
  # See LEGAL and LICENSE for licensing information.
4
4
 
5
5
  module Rcov
6
- VERSION = "0.8.4.1"
7
- RELEASE_DATE = "2009-07-31"
6
+ VERSION = "0.8.5"
7
+ RELEASE_DATE = "2009-08-07"
8
8
  RCOVRT_ABI = [2,0,0]
9
9
  UPSTREAM_URL = "http://github.com/relevance/rcov"
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relevance-rcov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4.1
4
+ version: 0.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Relevance
@@ -37,6 +37,7 @@ files:
37
37
  - lib/rcov/formatters/text_coverage_diff.rb
38
38
  - lib/rcov/formatters/text_report.rb
39
39
  - lib/rcov/formatters/text_summary.rb
40
+ - lib/rcov/formatters/failure_report.rb
40
41
  - lib/rcov/templates/index.html.erb
41
42
  - lib/rcov/templates/detail.html.erb
42
43
  - lib/rcov/templates/screen.css