simplecov 0.8.0.pre2 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7768d38b9aeb395f607dda4c66716e0d2666e16a
4
- data.tar.gz: 3cf5925dbcaf7506be09faaad38edca5bad8f488
3
+ metadata.gz: 61f56fdda1d314c0237f6838847332be44bb24cf
4
+ data.tar.gz: 8774f7ed6c24a12d78c8ae14cf4281f9ce8e8552
5
5
  SHA512:
6
- metadata.gz: bd3a2f25dc14d3cc3b65309aa06ea37563929d0951fa7d6ec90f9b1b6868ea8a670764230cbb5e7cbf0807c8b04d22a16d051204159a56d8231af909aa4b67f1
7
- data.tar.gz: 27f202f8386e4478fed7a746e7e464106220ffcf716f506e3dac4914cd7f186fda21b794637ff9b7b52381fcdacfce3bd6af24c14a998d98047888d33ebfdf01
6
+ metadata.gz: 164e46798ecc467c0affb93de2619573efff67f900897f11c96fa2404e40784134387698ab38cddc6c9c8df418b16d5511e233ae5b9f2d4a51e0e6d3fc4ba030
7
+ data.tar.gz: 07cabbfba38dc665fe26180cb66abcb1449d199c41c43dbe3db80a669d881ed459e017b03176d66d2200dbfbd25b2843943450bbb29c93d91bc8256e57439c68
@@ -1,25 +1,87 @@
1
- Unreleased ([changes](https://github.com/colszowka/simplecov/compare/v0.7.1...master))
2
- -------------------
1
+ Unreleased ([changes](https://github.com/colszowka/simplecov/compare/v0.8.1...master))
2
+ ====================
3
3
 
4
- * [FEATURE] Adds support for Rails 4 command guessing.
5
- See [#181](https://github.com/colszowka/simplecov/pull/181) (thanks to @semanticart)
6
- * [REFACTORING] Rename adapters to "profiles" given that they are bundles of settings. The old adapter methods are
4
+ v0.8.1, 2013-11-10 ([changes](https://github.com/colszowka/simplecov/compare/v0.8.0...v0.8.1))
5
+ =====================
6
+
7
+ ## Bugfixes
8
+
9
+ * Fixed a regression introduced in 0.8.0 - the Forwardable STDLIB module is now required explicitly.
10
+ See [#256](https://github.com/colszowka/simplecov/pull/256) (thanks to @kylev)
11
+
12
+ v0.8.0, 2013-11-10 ([changes](https://github.com/colszowka/simplecov/compare/v0.7.1...v0.8.0))
13
+ =====================
14
+
15
+ ## TL;DR
16
+
17
+ It's been way too long since the last official release 0.7.1, but this was partly due to it proving itself
18
+ quite stable in most circumstances. This release brings various further stability improvements to result set merging
19
+ (especially when working with parallel_tests), the configuration, source file encodings, and command name guessing.
20
+
21
+ The 0.8 line is the last one to cooperate with Ruby < 1.9. Starting with 0.9, SimpleCov will assume to be running in
22
+ Ruby 1.9+, and will not try to detect or bail silently on older Ruby versions. An appropriate deprecation warning
23
+ has been added.
24
+
25
+ ## Features
26
+
27
+ * Configuration blocks now have access to variables and methods outside of the block's scope.
28
+ See [#238](https://github.com/colszowka/simplecov/pull/238) (thanks to @ms-tg)
29
+ * You can now have a global `~/.simplecov` configuration file.
30
+ See [#195](https://github.com/colszowka/simplecov/pull/195) (thanks to @spagalloco)
31
+ * simplecov-html now uses the MIT-licensed colorbox plugin. Some adjustments when viewing source files,
32
+ including retaining the currently open file on refresh have been added.
33
+ See [simplecov-html #15](https://github.com/colszowka/simplecov-html/pull/15) (thanks to @chetan)
34
+ * Adds support for Rails 4 command guessing, removes default group `vendor/plugins`.
35
+ See [#181](https://github.com/colszowka/simplecov/pull/181) and
36
+ [#203](https://github.com/colszowka/simplecov/pull/203) (thanks to @semanticart and @phallstrom)
37
+ * You can now load simplecov without the default settings by doing `require 'simplecov/no_defaults'`
38
+ or setting `ENV['SIMPLECOV_NO_DEFAULTS']`. Check `simplecov/defaults` to see what preconfigurations are getting
39
+ dropped by using this. See [#209](https://github.com/colszowka/simplecov/pull/209) (thanks to @ileitch)
40
+ * The result set merging now uses the `lockfile` gem to avoid race conditions.
41
+ See [#185](https://github.com/colszowka/simplecov/pull/185) (thanks to @jshraibman-mdsol).
42
+ * Automatically detect the usage of parallel_tests and adjust the command name with the test env number accordingly,
43
+ See [#64](https://github.com/colszowka/simplecov/issues/64) and
44
+ [#185](https://github.com/colszowka/simplecov/pull/185) (thanks to @jshraibman-mdsol).
45
+
46
+ ## Enhancements
47
+
48
+ * Rename adapters to "profiles" given that they are bundles of settings. The old adapter methods are
7
49
  deprecated, but remain available for now.
8
50
  See [#207](https://github.com/colszowka/simplecov/pull/207) (thanks to @mikerobe)
9
- * [FEATURE] You can now load simplecov without the default settings by doing `require 'simplecov/no_defaults'
10
- or setting `ENV['SIMPLECOV_NO_DEFAULTS']`. Check `simplecov/defaults` to see what preconfigurations are getting
11
- dropped by using this.
12
- See [#209](https://github.com/colszowka/simplecov/pull/209) (thanks to @ileitch)
13
- * [REFACTORING] Tweaks to the automatic test suite naming. In particular, `rspec/features` should now
51
+ * Tweaks to the automatic test suite naming. In particular, `rspec/features` should now
14
52
  be correctly attributed to RSpec, not Cucumber.
15
53
  See [#212](https://github.com/colszowka/simplecov/pull/212) (thanks to @ersatzryan and @betelgeuse)
16
- * [REFACTORING] The internal cucumber test suite now uses Capybara 2.
54
+ * MiniTest should now be identified correctly by the command name guesser.
55
+ See [#244](https://github.com/colszowka/simplecov/pull/244) (thanks to @envygeeks)
56
+ * Makes SimpleCov resilient to inclusion of mathn library.
57
+ See [#175](https://github.com/colszowka/simplecov/pull/175) and
58
+ [#140](https://github.com/colszowka/simplecov/issues/140) (thanks to @scotje)
59
+ * Allow coverage_dir to be an absolute path.
60
+ * See [#190](https://github.com/colszowka/simplecov/pull/190) (thanks to @jshraibman-mdsol)
61
+ * The internal cucumber test suite now uses Capybara 2.
17
62
  See [#206](https://github.com/colszowka/simplecov/pull/206) (thanks to @infertux)
18
- * [FEATURE] Automatically detect the usage of parallel_tests.
19
- See https://github.com/colszowka/simplecov/issues/64
63
+ * Work-arounds for the Coverage library shipped in JRuby 1.6 to behave in line with MRI.
64
+ See [#174](https://github.com/colszowka/simplecov/pull/174) (thanks to @grddev)
65
+ * Fix warning: instance variable @exit_status not initialized.
66
+ See [#242](https://github.com/colszowka/simplecov/pull/242) and
67
+ [#213](https://github.com/colszowka/simplecov/pull/213) (thanks to @sferik and @infertux)
68
+
69
+ ## Bugfixes
70
+
71
+ * Correct result calculations for people using :nocov: tags.
72
+ See [#215](https://github.com/colszowka/simplecov/pull/215) (thanks to @aokolish)
73
+ * Average hits per line for groups of files is now computed correctly.
74
+ See [#192](http://github.com/colszowka/simplecov/pull/192) and
75
+ [#179](http://github.com/colszowka/simplecov/issues/179) (thanks to @graysonwright)
76
+ * Compatability with BINARY internal encoding.
77
+ See [#194](https://github.com/colszowka/simplecov/pull/194) and
78
+ [#127](https://github.com/colszowka/simplecov/issues/127) (thanks to @justfalter)
79
+ * Special characters in `SimpleCov.root` are now correctly escaped before being used as a RegExp.
80
+ See [#204](https://github.com/colszowka/simplecov/issues/204) and
81
+ [#237](https://github.com/colszowka/simplecov/pull/237) (thanks to @rli9)
20
82
 
21
83
  v0.7.1, 2012-10-12 ([changes](https://github.com/colszowka/simplecov/compare/v0.7.0...v0.7.1))
22
- -------------------
84
+ =====================
23
85
 
24
86
  * [BUGFIX] The gem packages of 0.7.0 (both simplecov and simplecov-html) pushed to Rubygems had some file
25
87
  permission issues, leading to problems when installing SimpleCov in a root/system Rubygems install and then
@@ -29,7 +91,7 @@ v0.7.1, 2012-10-12 ([changes](https://github.com/colszowka/simplecov/compare/v0.
29
91
 
30
92
 
31
93
  v0.7.0, 2012-10-10 ([changes](https://github.com/colszowka/simplecov/compare/v0.6.4...v0.7.0))
32
- -------------------
94
+ =====================
33
95
 
34
96
  * [FEATURE] The new `maximum_coverage_drop` and `minimum_coverage` now allow you to fail your build when the
35
97
  coverage dropped by more than what you allowed or is below a minimum value required. Also, `refuse_coverage_drop` disallows
@@ -48,7 +110,7 @@ v0.7.0, 2012-10-10 ([changes](https://github.com/colszowka/simplecov/compare/v0.
48
110
  * The usual bunch of README fixes and documentation tweaks. Thanks to everyone who contributed those!
49
111
 
50
112
  v0.6.4, 2012-05-10 ([changes](https://github.com/colszowka/simplecov/compare/v0.6.3...v0.6.4))
51
- -------------------
113
+ =====================
52
114
 
53
115
  * [BUGFIX] Encoding issues with ISO-8859-encoded source files fixed.
54
116
  See https://github.com/colszowka/simplecov/pull/117. (thanks to @Deradon)
@@ -60,7 +122,7 @@ v0.6.4, 2012-05-10 ([changes](https://github.com/colszowka/simplecov/compare/v0.
60
122
 
61
123
 
62
124
  v0.6.3, 2012-05-10 ([changes](https://github.com/colszowka/simplecov/compare/v0.6.2...v0.6.3))
63
- -------------------
125
+ =====================
64
126
 
65
127
  * [BUGFIX] Modified the API-changes for newer multi_json versions introduced with #122 and v0.6.2 so
66
128
  they are backwards-compatible with older multi_json gems in order to avoid simplecov polluting
@@ -70,19 +132,19 @@ v0.6.3, 2012-05-10 ([changes](https://github.com/colszowka/simplecov/compare/v0.
70
132
  multi_json gems and ensure the above actually works :)
71
133
 
72
134
  v0.6.2, 2012-04-20 ([changes](https://github.com/colszowka/simplecov/compare/v0.6.1...v0.6.2))
73
- -------------------
135
+ =====================
74
136
 
75
137
  * [Updated to latest version of MultiJSON and its new API (thanks to @sferik and @ronen).
76
138
  See https://github.com/colszowka/simplecov/pull/122
77
139
 
78
140
  v0.6.1, 2012-02-24 ([changes](https://github.com/colszowka/simplecov/compare/v0.6.0...v0.6.1))
79
- -------------------
141
+ =====================
80
142
 
81
143
  * [BUGFIX] Don't force-load Railtie on Rails < 3. Fixes regression introduced with
82
144
  #83. See https://github.com/colszowka/simplecov/issues/113
83
145
 
84
146
  v0.6.0, 2012-02-22 ([changes](https://github.com/colszowka/simplecov/compare/v0.5.4...v0.6.0))
85
- -------------------
147
+ =====================
86
148
 
87
149
  * [FEATURE] Auto-magic `rake simplecov` task for rails
88
150
  (see https://github.com/colszowka/simplecov/pull/83, thanks @sunaku)
@@ -98,7 +160,7 @@ v0.6.0, 2012-02-22 ([changes](https://github.com/colszowka/simplecov/compare/v0.
98
160
  list of changes: https://github.com/colszowka/simplecov/compare/v0.5.4...v0.6.0
99
161
 
100
162
  v0.5.4, 2011-10-12 ([changes](https://github.com/colszowka/simplecov/compare/v0.5.3...v0.5.4))
101
- -------------------
163
+ =====================
102
164
 
103
165
  * Do not give exit code 0 when there are exceptions prior to tests
104
166
  (see https://github.com/colszowka/simplecov/issues/41, thanks @nbogie)
@@ -111,7 +173,7 @@ v0.5.4, 2011-10-12 ([changes](https://github.com/colszowka/simplecov/compare/v0.
111
173
  * Readme formatted in Markdown :)
112
174
 
113
175
  v0.5.3, 2011-09-13 ([changes](https://github.com/colszowka/simplecov/compare/v0.5.2...v0.5.3))
114
- -------------------
176
+ =====================
115
177
 
116
178
  * Fix for encoding issues that came from the nocov processing mechanism
117
179
  (see https://github.com/colszowka/simplecov/issues/71)
@@ -126,13 +188,13 @@ v0.5.3, 2011-09-13 ([changes](https://github.com/colszowka/simplecov/compare/v0.
126
188
  alias SimpleCov.skip_token)
127
189
 
128
190
  v0.5.2, 2011-09-12 ([changes](https://github.com/colszowka/simplecov/compare/v0.5.1...v0.5.2))
129
- -------------------
191
+ =====================
130
192
 
131
193
  * Another fix for a bug in JSON processing introduced with MultiJSON in 0.5.1
132
194
  (see https://github.com/colszowka/simplecov/pull/75, thanks @sferik)
133
195
 
134
196
  v0.5.1, 2011-09-12 ([changes](https://github.com/colszowka/simplecov/compare/v0.5.0...v0.5.1))
135
- -------------------
197
+ =====================
136
198
  **Note: Yanked 2011-09-12 because the MultiJSON-patch had a crucial bug**
137
199
 
138
200
  * Fix for invalid gemspec dependency string (see https://github.com/colszowka/simplecov/pull/70,
@@ -143,7 +205,7 @@ v0.5.1, 2011-09-12 ([changes](https://github.com/colszowka/simplecov/compare/v0.
143
205
  and https://github.com/colszowka/simplecov/pull/74, thanks @sferik)
144
206
 
145
207
  v0.5.0, 2011-09-09 ([changes](https://github.com/colszowka/simplecov/compare/v0.4.2...v0.5.4))
146
- -------------------
208
+ =====================
147
209
  **Note: Yanked 2011-09-09 because of trouble with the gemspec.**
148
210
 
149
211
  * JSON is now used instead of YAML for resultset caching (used for merging). Should resolve
@@ -18,3 +18,11 @@ If you want to contribute, please:
18
18
  * Add tests for it. This is important so I don't break it in a future version unintentionally.
19
19
  * **Bonus Points** go out to anyone who also updates `CHANGELOG.md` :)
20
20
  * Send me a pull request on Github.
21
+
22
+ ## Running Individual Tests
23
+
24
+ This project uses Test::Unit. Individual tests can be run like this:
25
+
26
+ ```bash
27
+ ruby -I test path/to/test.rb
28
+ ```
data/Gemfile CHANGED
@@ -9,6 +9,10 @@ if 'Integration test (cucumber) suite is 1.9+ only'.respond_to? :encoding
9
9
  gem 'cucumber', '>= 1.1.0'
10
10
  end
11
11
 
12
+ # shoulda-matchers depends on rails >= 4, but that does not work with Ruby < 1.9. So, to allow CI builds on those versions,
13
+ # we gotta stick with the 3.x line.
14
+ gem 'activesupport', '~> 3.2.0'
15
+
12
16
  # Uncomment this to use local copy of simplecov-html in development when checked out
13
17
  # gem 'simplecov-html', :path => ::File.dirname(__FILE__) + '/../simplecov-html'
14
18
 
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2012 Christoph Olszowka
1
+ Copyright (c) 2010-2013 Christoph Olszowka
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -21,7 +21,7 @@ SimpleCov [![Build Status](https://secure.travis-ci.org/colszowka/simplecov.png)
21
21
  [Mailing List]: https://groups.google.com/forum/#!forum/simplecov "Open mailing list for discussion and announcements on Google Groups"
22
22
  [Pledgie]: http://www.pledgie.com/campaigns/18379
23
23
 
24
- [![You can support the development of SimpleCov via Pledgie - thanks for your help](http://www.pledgie.com/campaigns/18379.png?skin_name=chrome)][Pledgie]
24
+ [![You can support the development of SimpleCov via Pledgie - thanks for your help](https://pledgie.com/campaigns/18379.png?skin_name=chrome)][Pledgie]
25
25
 
26
26
  SimpleCov is a code coverage analysis tool for Ruby 1.9. It uses [1.9's built-in Coverage][Coverage] library to gather code
27
27
  coverage data, but makes processing its results much easier by providing a clean API to filter, group, merge, format
@@ -155,11 +155,13 @@ to use SimpleCov with them. Here's an overview of the known ones:
155
155
  <b>parallel_tests</b>
156
156
  </td>
157
157
  <td>
158
- SimpleCov does not detect parallel_test automatically yet but can be taught to do so
159
- with a simple workaround explained at Issue #64.
158
+ As of 0.8.0, SimpleCov should correctly recognize parallel_tests and supplement your test suite names
159
+ with their corresponding test env numbers. Locking of the resultset cache should ensure no race conditions
160
+ occur when results are merged.
160
161
  </td>
161
162
  <td>
162
163
  <a href="https://github.com/colszowka/simplecov/issues/64">SimpleCov #64</a>
164
+ <a href="https://github.com/colszowka/simplecov/pull/185">SimpleCov #185</a>
163
165
  </td>
164
166
  </tr>
165
167
  <tr>
@@ -296,7 +298,7 @@ is being set in the SimpleCov::Filter initialize method and thus is set to 5 in
296
298
  ## Groups
297
299
 
298
300
  You can separate your source files into groups. For example, in a rails app, you'll want to have separate listings for
299
- Models, Controllers, Helpers, Libs and Plugins. Group definition works similar to Filters (and indeed also accepts custom
301
+ Models, Controllers, Helpers, and Libs. Group definition works similar to Filters (and indeed also accepts custom
300
302
  filter classes), but source files end up in a group when the filter passes (returns true), as opposed to filtering results,
301
303
  which exclude files from results when the filter results in a true value.
302
304
 
@@ -406,7 +408,6 @@ SimpleCov.profiles.define 'rails' do
406
408
  add_group 'Models', 'app/models'
407
409
  add_group 'Helpers', 'app/helpers'
408
410
  add_group 'Libraries', 'lib'
409
- add_group 'Plugins', 'vendor/plugins'
410
411
  end
411
412
  ```
412
413
 
@@ -521,10 +522,10 @@ available:
521
522
 
522
523
  CSV formatter for SimpleCov code coverage tool for ruby 1.9+
523
524
 
524
- #### [simplecov-vim](https://github.com/nyarly/Simplecov-Vim)
525
+ #### [cadre](https://github.com/nyarly/cadre)
525
526
  *by Judson Lester*
526
527
 
527
- A formatter for Simplecov that emits a Vim script to mark up code files with coverage information.
528
+ Includes a formatter for Simplecov that emits a Vim script to mark up code files with coverage information.
528
529
 
529
530
  #### [simplecov-single_file_reporter](https://github.com/grosser/simplecov-single_file_reporter)
530
531
  *by [Michael Grosser](http://grosser.it)*
@@ -562,4 +563,4 @@ Thanks to Aaron Patterson for the original idea for this!
562
563
 
563
564
  ## Copyright
564
565
 
565
- Copyright (c) 2010-2012 Christoph Olszowka. See MIT-LICENSE for details.
566
+ Copyright (c) 2010-2013 Christoph Olszowka. See MIT-LICENSE for details.
@@ -116,7 +116,7 @@ module SimpleCov
116
116
 
117
117
  @usable = begin
118
118
  require 'coverage'
119
- require 'simplecov/jruby16_fix'
119
+ require 'simplecov/jruby_fix'
120
120
  true
121
121
  rescue LoadError
122
122
  false
@@ -48,6 +48,8 @@ module SimpleCov::CommandGuesser
48
48
  "RSpec"
49
49
  elsif defined?(Test::Unit)
50
50
  "Unit Tests"
51
+ elsif defined?(MiniTest)
52
+ "MiniTest"
51
53
  else
52
54
  # TODO: Provide link to docs/wiki article
53
55
  warn "SimpleCov failed to recognize the test framework and/or suite used. Please specify manually using SimpleCov.command_name 'Unit Tests'."
@@ -27,7 +27,6 @@ SimpleCov.profiles.define 'rails' do
27
27
  add_group 'Mailers', 'app/mailers'
28
28
  add_group 'Helpers', 'app/helpers'
29
29
  add_group 'Libraries', 'lib'
30
- add_group 'Plugins', 'vendor/plugins'
31
30
  end
32
31
 
33
32
  # Default configuration
@@ -41,14 +40,15 @@ end
41
40
  SimpleCov::CommandGuesser.original_run_command = "#{$0} #{ARGV.join(" ")}"
42
41
 
43
42
  at_exit do
44
- # Store the exit status of the test run since it goes away after calling the at_exit proc...
45
- if $! #was an exception thrown?
46
- #if it was a SystemExit, use the accompanying status
47
- #otherwise set a non-zero status representing termination by some other exception
48
- #(see github issue 41)
43
+
44
+ if $! # was an exception thrown?
45
+ # if it was a SystemExit, use the accompanying status
46
+ # otherwise set a non-zero status representing termination by some other exception
47
+ # (see github issue 41)
49
48
  @exit_status = $!.is_a?(SystemExit) ? $!.status : SimpleCov::ExitCodes::EXCEPTION
50
49
  else
51
- @exit_status = 0
50
+ # Store the exit status of the test run since it goes away after calling the at_exit proc...
51
+ @exit_status = SimpleCov::ExitCodes::SUCCESS
52
52
  end
53
53
 
54
54
  SimpleCov.at_exit.call
@@ -56,12 +56,12 @@ at_exit do
56
56
  if SimpleCov.result? # Result has been computed
57
57
  covered_percent = SimpleCov.result.covered_percent.round(2)
58
58
 
59
- if @exit_status == 0 # No other errors
60
- @exit_status = if covered_percent < SimpleCov.minimum_coverage
59
+ if @exit_status == SimpleCov::ExitCodes::SUCCESS # No other errors
60
+ if covered_percent < SimpleCov.minimum_coverage
61
61
  $stderr.puts "Coverage (%.2f%%) is below the expected minimum coverage (%.2f%%)." % \
62
62
  [covered_percent, SimpleCov.minimum_coverage]
63
63
 
64
- SimpleCov::ExitCodes::MINIMUM_COVERAGE
64
+ @exit_status = SimpleCov::ExitCodes::MINIMUM_COVERAGE
65
65
 
66
66
  elsif (last_run = SimpleCov::LastRun.read)
67
67
  diff = last_run['result']['covered_percent'] - covered_percent
@@ -69,18 +69,15 @@ at_exit do
69
69
  $stderr.puts "Coverage has dropped by %.2f%% since the last time (maximum allowed: %.2f%%)." % \
70
70
  [diff, SimpleCov.maximum_coverage_drop]
71
71
 
72
- SimpleCov::ExitCodes::MAXIMUM_COVERAGE_DROP
72
+ @exit_status = SimpleCov::ExitCodes::MAXIMUM_COVERAGE_DROP
73
73
  end
74
74
  end
75
75
  end
76
76
 
77
- metrics = {
78
- :result => { :covered_percent => covered_percent }
79
- }
80
- SimpleCov::LastRun.write(metrics)
77
+ SimpleCov::LastRun.write(:result => {:covered_percent => covered_percent})
81
78
  end
82
79
 
83
- exit @exit_status if @exit_status # Force exit with stored status (see github issue #5)
80
+ exit @exit_status # Force exit with stored status (see github issue #5)
84
81
  end
85
82
 
86
83
  # Autoload config from ~/.simplecov if present
@@ -1,4 +1,5 @@
1
1
  module SimpleCov::ExitCodes
2
+ SUCCESS = 0
2
3
  EXCEPTION = 1
3
4
  MINIMUM_COVERAGE = 2
4
5
  MAXIMUM_COVERAGE_DROP = 3
@@ -39,6 +39,6 @@ class SimpleCov::FileList < Array
39
39
  # Computes the strength (hits / line) based upon lines covered and lines missed
40
40
  def covered_strength
41
41
  return 0 if empty? or lines_of_code == 0
42
- map {|f| f.covered_strength }.inject(&:+).to_f / size
42
+ map {|f| f.covered_strength * f.lines_of_code }.inject(&:+) / lines_of_code
43
43
  end
44
44
  end
@@ -16,6 +16,8 @@ if defined?(JRUBY_VERSION) && JRUBY_VERSION.to_f < 1.7
16
16
  def result
17
17
  fixed = {}
18
18
  __broken_result__.each do |path, executed_lines|
19
+ next unless File.file? path
20
+
19
21
  covered_lines = executed_lines.dup
20
22
 
21
23
  process = lambda do |node|
@@ -26,10 +28,7 @@ if defined?(JRUBY_VERSION) && JRUBY_VERSION.to_f < 1.7
26
28
  node.child_nodes.each(&process)
27
29
  end
28
30
 
29
- begin
30
- process[JRuby.parse(File.read(path), path)]
31
- rescue => e
32
- end
31
+ process[JRuby.parse(File.read(path), path)]
33
32
 
34
33
  if (first = covered_lines.detect { |x| x }) && first > 0
35
34
  fixed[File.expand_path(path)] = covered_lines
@@ -1,4 +1,5 @@
1
1
  require 'digest/sha1'
2
+ require 'forwardable'
2
3
 
3
4
  module SimpleCov
4
5
  #
@@ -6,6 +7,7 @@ module SimpleCov
6
7
  # library generates (Coverage.result).
7
8
  #
8
9
  class Result
10
+ extend Forwardable
9
11
  # Returns the original Coverage.result used for this instance of SimpleCov::Result
10
12
  attr_reader :original_result
11
13
  # Returns all files that are applicable to this result (sans filters!) as instances of SimpleCov::SourceFile. Aliased as :source_files
@@ -16,21 +18,16 @@ module SimpleCov
16
18
  # Explicitly set the command name that was used for this coverage result. Defaults to SimpleCov.command_name
17
19
  attr_writer :command_name
18
20
 
21
+ def_delegators :files, :covered_percent, :covered_strength, :covered_lines, :missed_lines
22
+ def_delegator :files, :lines_of_code, :total_lines
23
+
19
24
  # Initialize a new SimpleCov::Result from given Coverage.result (a Hash of filenames each containing an array of
20
25
  # coverage data)
21
26
  def initialize(original_result)
22
- @original_result = original_result.dup
23
-
24
- # Squeeze filepaths (i.e. "/a/b/../c" becomes "/a/c")
25
- @original_result.keys.each do |filename|
26
- expanded_filename = File.expand_path filename
27
- @original_result[expanded_filename] = @original_result.delete filename
28
- end
29
-
30
- @files = SimpleCov::FileList.new(@original_result.map do |filename, coverage|
27
+ @original_result = original_result.freeze
28
+ @files = SimpleCov::FileList.new(original_result.map do |filename, coverage|
31
29
  SimpleCov::SourceFile.new(filename, coverage) if File.file?(filename)
32
30
  end.compact.sort_by(&:filename))
33
-
34
31
  filter!
35
32
  end
36
33
 
@@ -44,56 +41,6 @@ module SimpleCov
44
41
  @groups ||= SimpleCov.grouped(files)
45
42
  end
46
43
 
47
- # The overall percentual coverage for this result
48
- def covered_percent
49
- # Make sure that weird rounding error from #15, #23 and #24 does not occur again!
50
- total_lines.zero? ? 0 : 100.0 * covered_lines / total_lines
51
- end
52
-
53
- # The multiple of coverage for this result
54
- def covered_strength
55
- return 0 if total_lines.zero?
56
- return @covered_strength if @covered_strength
57
- m = 0
58
- @files.each do |file|
59
- original_result[file.filename].each do |line_result|
60
- if line_result
61
- m += line_result
62
- end
63
- end
64
- end
65
- @covered_strength = m.to_f / total_lines
66
- end
67
-
68
- # Returns the count of lines that are covered
69
- def covered_lines
70
- return @covered_lines if defined? @covered_lines
71
- @covered_lines = 0
72
- @files.each do |file|
73
- original_result[file.filename].each do |line_result|
74
- @covered_lines += 1 if line_result and line_result > 0
75
- end
76
- end
77
- @covered_lines
78
- end
79
-
80
- # Returns the count of missed lines
81
- def missed_lines
82
- return @missed_lines if defined? @missed_lines
83
- @missed_lines = 0
84
- @files.each do |file|
85
- original_result[file.filename].each do |line_result|
86
- @missed_lines += 1 if line_result == 0
87
- end
88
- end
89
- @missed_lines
90
- end
91
-
92
- # Total count of relevant lines (covered + missed)
93
- def total_lines
94
- @total_lines ||= (covered_lines + missed_lines)
95
- end
96
-
97
44
  # Applies the configured SimpleCov.formatter on this result
98
45
  def format!
99
46
  SimpleCov.formatter.new.format(self)
@@ -1,3 +1,3 @@
1
1
  module SimpleCov
2
- VERSION = "0.8.0.pre2"
2
+ VERSION = "0.8.1"
3
3
  end
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
15
15
 
16
16
  gem.add_dependency 'multi_json'
17
17
  gem.add_dependency 'lockfile', '>= 2.1.0'
18
- gem.add_dependency 'simplecov-html', '~> 0.7.1'
18
+ gem.add_dependency 'simplecov-html', '~> 0.8.0'
19
19
  gem.add_dependency 'docile', '~> 1.1.0'
20
20
 
21
21
  gem.add_development_dependency 'appraisal', '~> 0.5.1'
@@ -5,18 +5,17 @@ class TestFileList < Test::Unit::TestCase
5
5
  setup do
6
6
  original_result = {source_fixture('sample.rb') => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil],
7
7
  source_fixture('app/models/user.rb') => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
8
- source_fixture('app/controllers/sample_controller.rb') => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil]}
8
+ source_fixture('app/controllers/sample_controller.rb') => [nil, 2, 2, 0, nil, nil, 0, nil, nil, nil]}
9
9
  @file_list = SimpleCov::Result.new(original_result).files
10
10
  end
11
11
 
12
- should("have 13 covered_lines") { assert_equal 13, @file_list.covered_lines }
13
- should("have 2 missed_lines") { assert_equal 2, @file_list.missed_lines }
14
- should("have 18 never_lines") { assert_equal 18, @file_list.never_lines }
15
- should("have 15 lines_of_code") { assert_equal 15, @file_list.lines_of_code }
12
+ should("have 11 covered_lines") { assert_equal 11, @file_list.covered_lines }
13
+ should("have 3 missed_lines") { assert_equal 3, @file_list.missed_lines }
14
+ should("have 19 never_lines") { assert_equal 19, @file_list.never_lines }
15
+ should("have 14 lines_of_code") { assert_equal 14, @file_list.lines_of_code }
16
16
  should("have 3 skipped_lines") { assert_equal 3, @file_list.skipped_lines }
17
17
 
18
- should "have correct covered_percent" do
19
- assert_equal 100.0*13/15, @file_list.covered_percent
20
- end
18
+ should("have correct covered_percent") { assert_equal 100.0*11/14, @file_list.covered_percent }
19
+ should("have correct covered_strength") { assert_equal 13.to_f/14, @file_list.covered_strength }
21
20
  end
22
21
  end if SimpleCov.usable?
@@ -37,6 +37,12 @@ class TestResult < Test::Unit::TestCase
37
37
  assert_equal 100.0*13/15, @result.covered_percent
38
38
  end
39
39
 
40
+ [:covered_percent, :covered_strength, :covered_lines, :missed_lines, :total_lines].each do |msg|
41
+ should "respond to #{msg}" do
42
+ assert @result.respond_to? msg
43
+ end
44
+ end
45
+
40
46
  context "dumped with to_hash" do
41
47
  setup { @hash = @result.to_hash }
42
48
  should("be a hash") { assert_equal Hash, @hash.class }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplecov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0.pre2
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christoph Olszowka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-11 00:00:00.000000000 Z
11
+ date: 2013-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: 0.7.1
47
+ version: 0.8.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: 0.7.1
54
+ version: 0.8.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: docile
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -186,7 +186,7 @@ files:
186
186
  - lib/simplecov/formatter.rb
187
187
  - lib/simplecov/formatter/multi_formatter.rb
188
188
  - lib/simplecov/formatter/simple_formatter.rb
189
- - lib/simplecov/jruby16_fix.rb
189
+ - lib/simplecov/jruby_fix.rb
190
190
  - lib/simplecov/json.rb
191
191
  - lib/simplecov/last_run.rb
192
192
  - lib/simplecov/merge_helpers.rb
@@ -256,9 +256,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
256
256
  version: '0'
257
257
  required_rubygems_version: !ruby/object:Gem::Requirement
258
258
  requirements:
259
- - - '>'
259
+ - - '>='
260
260
  - !ruby/object:Gem::Version
261
- version: 1.3.1
261
+ version: '0'
262
262
  requirements: []
263
263
  rubyforge_project:
264
264
  rubygems_version: 2.0.3