simplecov 0.11.1 → 0.12.0
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -2
- data/.travis.yml +5 -4
- data/CHANGELOG.md +28 -2
- data/Gemfile +14 -12
- data/README.md +1 -21
- data/features/step_definitions/simplecov_steps.rb +1 -1
- data/features/support/env.rb +1 -1
- data/lib/simplecov/configuration.rb +12 -8
- data/lib/simplecov/defaults.rb +13 -10
- data/lib/simplecov/filter.rb +1 -1
- data/lib/simplecov/jruby_fix.rb +1 -1
- data/lib/simplecov/merge_helpers.rb +7 -11
- data/lib/simplecov/profiles.rb +2 -2
- data/lib/simplecov/result.rb +2 -1
- data/lib/simplecov/source_file.rb +11 -11
- data/lib/simplecov/version.rb +9 -6
- data/lib/simplecov.rb +27 -14
- data/simplecov.gemspec +1 -1
- data/spec/1_8_fallbacks_spec.rb +2 -2
- data/spec/faked_project/lib/faked_project/some_class.rb +1 -1
- data/spec/faked_project/spec/forking_spec.rb +2 -1
- data/spec/fixtures/deleted_source_sample.rb +1 -1
- data/spec/merge_helpers_spec.rb +7 -1
- data/spec/return_codes_spec.rb +5 -8
- data/spec/source_file_spec.rb +1 -1
- metadata +11 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c4ded95468b70d7817ca95004ac38a0b6ad2e388
|
|
4
|
+
data.tar.gz: 2bb87e0871a8daa3955049fa6e808968d479ea48
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: af959d1c396d33ac1f1f76e6108993d1e0af61e1f9059feb4dcbb598e46eceb51b930370d6e1f5f3711dc498ced9176a72ae125498f1d3b385581bba00c61466
|
|
7
|
+
data.tar.gz: fd27be25b4cca08be020931d330cc2a958559a49c61c8058b6433a55d75252b263502c74445efa21ee7a7683aceee6a4650501fe00a07ee25dbad546aef891f5
|
data/.rubocop.yml
CHANGED
|
@@ -66,5 +66,12 @@ Style/FileName:
|
|
|
66
66
|
Exclude:
|
|
67
67
|
- 'spec/fixtures/utf-8.rb'
|
|
68
68
|
|
|
69
|
-
Style/
|
|
70
|
-
EnforcedStyleForMultiline:
|
|
69
|
+
Style/TrailingCommaInLiteral:
|
|
70
|
+
EnforcedStyleForMultiline: comma
|
|
71
|
+
|
|
72
|
+
Style/GuardClause:
|
|
73
|
+
Enabled: false
|
|
74
|
+
|
|
75
|
+
Style/MutableConstant:
|
|
76
|
+
Exclude:
|
|
77
|
+
- 'lib/simplecov/version.rb' # required for older versions of rubygems
|
data/.travis.yml
CHANGED
|
@@ -13,15 +13,16 @@ rvm:
|
|
|
13
13
|
- 1.8.7
|
|
14
14
|
- 1.9.3
|
|
15
15
|
- 2.0.0
|
|
16
|
-
- 2.1
|
|
17
|
-
- 2.2
|
|
16
|
+
- 2.1.10
|
|
17
|
+
- 2.2.5
|
|
18
|
+
- 2.3.0
|
|
18
19
|
- ruby-head
|
|
19
|
-
- jruby
|
|
20
|
+
- jruby-head
|
|
20
21
|
- rbx-2
|
|
21
22
|
|
|
22
23
|
matrix:
|
|
23
24
|
allow_failures:
|
|
24
25
|
- rvm: ruby-head
|
|
25
|
-
- rvm: jruby
|
|
26
|
+
- rvm: jruby-head
|
|
26
27
|
- rvm: rbx-2
|
|
27
28
|
fast_finish: true
|
data/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,36 @@
|
|
|
1
|
-
Unreleased ([changes](https://github.com/colszowka/simplecov/compare/v0.
|
|
1
|
+
Unreleased ([changes](https://github.com/colszowka/simplecov/compare/v0.12.0...master))
|
|
2
|
+
==========
|
|
3
|
+
|
|
4
|
+
## Enhancements
|
|
5
|
+
|
|
6
|
+
## Bugfixes
|
|
7
|
+
|
|
8
|
+
0.12.0 2016-07-02 ([changes](https://github.com/colszowka/simplecov/compare/v0.11.2...v0.12.0))
|
|
2
9
|
=================
|
|
3
10
|
|
|
4
11
|
## Enhancements
|
|
5
12
|
|
|
13
|
+
* Add support for JSON versions 2.x
|
|
14
|
+
|
|
6
15
|
## Bugfixes
|
|
7
16
|
|
|
17
|
+
* Fix coverage rate of the parallel_tests. See [#441](https://github.com/colszowka/simplecov/pull/441) (thanks @sinsoku)
|
|
18
|
+
* Fix a regression on old rubies that failed to work with the recently introduced frozen VERSION string. See [#461](https://github.com/colszowka/simplecov/pull/461) (thanks @leafle)
|
|
19
|
+
|
|
20
|
+
0.11.2 2016-02-03 ([changes](https://github.com/colszowka/simplecov/compare/v0.11.1...v0.11.2))
|
|
21
|
+
=================
|
|
22
|
+
|
|
23
|
+
## Enhancements
|
|
24
|
+
|
|
25
|
+
* Do not globally pollute Array and Hash with `merge_resultset` utility methods. See [#449](https://github.com/colszowka/simplecov/pull/449) (thanks @amatsuda)
|
|
26
|
+
* Do not `mkdir_p` the `coverage_path` on every access of the method (See [#453](https://github.com/colszowka/simplecov/pull/453) (thanks @paddor)
|
|
27
|
+
* Fixes a Ruby warning related to the `track_files` configuration. See [#447](https://github.com/colszowka/simplecov/pull/447) (thanks @craiglittle)
|
|
28
|
+
* Add a group for background jobs to default Rails profile. See [#442](https://github.com/colszowka/simplecov/pull/442) (thanks @stve)
|
|
29
|
+
|
|
30
|
+
## Bugfixes
|
|
31
|
+
|
|
32
|
+
* Fix root_filter evaluates SimpleCov.root before initialization. See [#437](https://github.com/colszowka/simplecov/pull/437) (thanks @tmtm)
|
|
33
|
+
|
|
8
34
|
0.11.1 2015-12-01 ([changes](https://github.com/colszowka/simplecov/compare/v0.11.0...v0.11.1))
|
|
9
35
|
=================
|
|
10
36
|
|
|
@@ -20,7 +46,7 @@ Unreleased ([changes](https://github.com/colszowka/simplecov/compare/v0.11.0...m
|
|
|
20
46
|
## Enhancements
|
|
21
47
|
|
|
22
48
|
* Added `SimpleCov.minimum_coverage_by_file` for per-file coverage thresholds. See [#392](https://github.com/colszowka/simplecov/pull/392) (thanks @ptashman)
|
|
23
|
-
* Added `track_files` configuration option to specify a glob to always include in coverage results, whether or not those files are required. See [#422](https://github.com/colszowka/simplecov/pull/422) (thanks @hugopeixoto)
|
|
49
|
+
* Added `track_files` configuration option to specify a glob to always include in coverage results, whether or not those files are required. By default, this is enabled in the Rails profile for common Rails directories. See [#422](https://github.com/colszowka/simplecov/pull/422) (thanks @hugopeixoto)
|
|
24
50
|
* Speed up `root_filter` by an order of magnitude. See [#396](https://github.com/colszowka/simplecov/pull/396) (thanks @raszi)
|
|
25
51
|
|
|
26
52
|
## Bugfixes
|
data/Gemfile
CHANGED
|
@@ -6,7 +6,7 @@ source "https://rubygems.org"
|
|
|
6
6
|
# Uncomment this to use development version of html formatter from github
|
|
7
7
|
# gem 'simplecov-html', :github => 'colszowka/simplecov-html'
|
|
8
8
|
|
|
9
|
-
gem "rake", ">= 10.3"
|
|
9
|
+
gem "rake", Gem::Version.new(RUBY_VERSION) < Gem::Version.new("1.9.3") ? "~>10.3" : ">= 10.3"
|
|
10
10
|
|
|
11
11
|
group :test do
|
|
12
12
|
gem "rspec", ">= 3.2"
|
|
@@ -15,19 +15,21 @@ group :test do
|
|
|
15
15
|
gem "activesupport", "~> 3.2.21"
|
|
16
16
|
gem "i18n", "~> 0.6.11"
|
|
17
17
|
end
|
|
18
|
-
platform :
|
|
18
|
+
platform :ruby_18, :ruby_19 do
|
|
19
|
+
gem "mime-types", "~> 1.25"
|
|
20
|
+
gem "json", "~> 1.8"
|
|
21
|
+
end
|
|
22
|
+
platform :ruby_18, :ruby_19, :ruby_20, :ruby_21 do
|
|
23
|
+
gem "rack", "~> 1.6"
|
|
24
|
+
end
|
|
25
|
+
platform :jruby, :ruby_19, :ruby_20, :ruby_21, :ruby_22, :ruby_23 do
|
|
19
26
|
gem "aruba", "~> 0.7.4"
|
|
20
|
-
gem "capybara"
|
|
21
|
-
|
|
22
|
-
# Hack until Capybara fixes its gemspec. 3.0 removed 1.9 support.
|
|
23
|
-
# See https://github.com/jnicklas/capybara/issues/1615
|
|
24
|
-
gem "mime-types", "~> 2.0.0"
|
|
25
|
-
|
|
26
|
-
gem "cucumber", "~> 2.0"
|
|
27
|
+
gem "capybara"
|
|
28
|
+
gem "cucumber"
|
|
27
29
|
gem "phantomjs", "~> 1.9"
|
|
28
|
-
gem "poltergeist"
|
|
29
|
-
gem "rubocop", "
|
|
30
|
-
gem "test-unit"
|
|
30
|
+
gem "poltergeist"
|
|
31
|
+
gem "rubocop", "~> 0.41.0"
|
|
32
|
+
gem "test-unit"
|
|
31
33
|
end
|
|
32
34
|
end
|
|
33
35
|
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
SimpleCov [][Continuous Integration] [][Dependencies] [](https://codeclimate.com/github/colszowka/simplecov) [](http://inch-ci.org/github/colszowka/simplecov)
|
|
2
2
|
=========
|
|
3
3
|
**Code coverage for Ruby**
|
|
4
4
|
|
|
@@ -6,11 +6,8 @@ SimpleCov [
|
|
|
6
6
|
* [API documentation]
|
|
7
7
|
* [Changelog]
|
|
8
8
|
* [Rubygem]
|
|
9
|
-
* [Mailing List]
|
|
10
9
|
* [Continuous Integration]
|
|
11
10
|
|
|
12
|
-
**Important Notice: There is a bug that affects exit code handling on the 0.8 line of SimpleCov, see [#281](https://github.com/colszowka/simplecov/issues/281). Please use versions `>= 0.9` to avoid this.**
|
|
13
|
-
|
|
14
11
|
[Coverage]: http://www.ruby-doc.org/stdlib-2.1.0/libdoc/coverage/rdoc/Coverage.html "API doc for Ruby's Coverage library"
|
|
15
12
|
[Source Code]: https://github.com/colszowka/simplecov "Source Code @ GitHub"
|
|
16
13
|
[API documentation]: http://rubydoc.info/gems/simplecov/frames "RDoc API Documentation at Rubydoc.info"
|
|
@@ -20,10 +17,6 @@ SimpleCov [
|
|
|
20
17
|
[Continuous Integration]: http://travis-ci.org/colszowka/simplecov "SimpleCov is built around the clock by travis-ci.org"
|
|
21
18
|
[Dependencies]: https://gemnasium.com/colszowka/simplecov "SimpleCov dependencies on Gemnasium"
|
|
22
19
|
[simplecov-html]: https://github.com/colszowka/simplecov-html "SimpleCov HTML Formatter Source Code @ GitHub"
|
|
23
|
-
[Mailing List]: https://groups.google.com/forum/#!forum/simplecov "Open mailing list for discussion and announcements on Google Groups"
|
|
24
|
-
[Pledgie]: http://www.pledgie.com/campaigns/18379
|
|
25
|
-
|
|
26
|
-
[][Pledgie]
|
|
27
20
|
|
|
28
21
|
SimpleCov is a code coverage analysis tool for Ruby. It uses [Ruby's built-in Coverage][Coverage] library to gather code
|
|
29
22
|
coverage data, but makes processing its results much easier by providing a clean API to filter, group, merge, format,
|
|
@@ -153,19 +146,6 @@ to use SimpleCov with them. Here's an overview of the known ones:
|
|
|
153
146
|
<a href="https://github.com/colszowka/simplecov/pull/185">#185</a>
|
|
154
147
|
</td>
|
|
155
148
|
</tr>
|
|
156
|
-
<tr>
|
|
157
|
-
<th>
|
|
158
|
-
Riot
|
|
159
|
-
</th>
|
|
160
|
-
<td>
|
|
161
|
-
A user has reported problems with the coverage report using the riot
|
|
162
|
-
framework. If you experience similar trouble please follow up on the
|
|
163
|
-
related GitHub issue.
|
|
164
|
-
</td>
|
|
165
|
-
<td>
|
|
166
|
-
<a href="https://github.com/colszowka/simplecov/issues/80">#80</a>
|
|
167
|
-
</td>
|
|
168
|
-
</tr>
|
|
169
149
|
<tr>
|
|
170
150
|
<th>
|
|
171
151
|
RubyMine
|
|
@@ -11,7 +11,7 @@ Given /^SimpleCov for (.*) is configured with:$/ do |framework, config_body|
|
|
|
11
11
|
when /Cucumber/i
|
|
12
12
|
"features/support"
|
|
13
13
|
else
|
|
14
|
-
|
|
14
|
+
raise ArgumentError, "Could not identify test framework #{framework}!"
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
|
data/features/support/env.rb
CHANGED
|
@@ -28,6 +28,7 @@ module SimpleCov
|
|
|
28
28
|
#
|
|
29
29
|
def coverage_dir(dir = nil)
|
|
30
30
|
return @coverage_dir if defined?(@coverage_dir) && dir.nil?
|
|
31
|
+
@coverage_path = nil # invalidate cache
|
|
31
32
|
@coverage_dir = (dir || "coverage")
|
|
32
33
|
end
|
|
33
34
|
|
|
@@ -37,9 +38,11 @@ module SimpleCov
|
|
|
37
38
|
# values. Will create the directory if it's missing
|
|
38
39
|
#
|
|
39
40
|
def coverage_path
|
|
40
|
-
coverage_path
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
@coverage_path ||= begin
|
|
42
|
+
coverage_path = File.expand_path(coverage_dir, root)
|
|
43
|
+
FileUtils.mkdir_p coverage_path
|
|
44
|
+
coverage_path
|
|
45
|
+
end
|
|
43
46
|
end
|
|
44
47
|
|
|
45
48
|
#
|
|
@@ -47,8 +50,9 @@ module SimpleCov
|
|
|
47
50
|
# or not they were explicitly required. Without this, un-required files
|
|
48
51
|
# will not be present in the final report.
|
|
49
52
|
#
|
|
50
|
-
def track_files(glob)
|
|
51
|
-
@
|
|
53
|
+
def track_files(glob = nil)
|
|
54
|
+
return @track_files if defined?(@track_files) && glob.nil?
|
|
55
|
+
@track_files = glob
|
|
52
56
|
end
|
|
53
57
|
|
|
54
58
|
#
|
|
@@ -81,7 +85,7 @@ module SimpleCov
|
|
|
81
85
|
def formatter(formatter = nil)
|
|
82
86
|
return @formatter if defined?(@formatter) && formatter.nil?
|
|
83
87
|
@formatter = formatter
|
|
84
|
-
|
|
88
|
+
raise "No formatter configured. Please specify a formatter using SimpleCov.formatter = SimpleCov::Formatter::SimpleFormatter" unless @formatter
|
|
85
89
|
@formatter
|
|
86
90
|
end
|
|
87
91
|
|
|
@@ -114,7 +118,7 @@ module SimpleCov
|
|
|
114
118
|
return @nocov_token if defined?(@nocov_token) && nocov_token.nil?
|
|
115
119
|
@nocov_token = (nocov_token || "nocov")
|
|
116
120
|
end
|
|
117
|
-
|
|
121
|
+
alias skip_token nocov_token
|
|
118
122
|
|
|
119
123
|
#
|
|
120
124
|
# Returns the configured groups. Add groups using SimpleCov.add_group
|
|
@@ -285,7 +289,7 @@ module SimpleCov
|
|
|
285
289
|
elsif filter_argument.is_a?(Array)
|
|
286
290
|
SimpleCov::ArrayFilter.new(filter_argument)
|
|
287
291
|
else
|
|
288
|
-
|
|
292
|
+
raise ArgumentError, "Please specify either a string or a block to filter with"
|
|
289
293
|
end
|
|
290
294
|
end
|
|
291
295
|
end
|
data/lib/simplecov/defaults.rb
CHANGED
|
@@ -4,8 +4,9 @@ require "pathname"
|
|
|
4
4
|
|
|
5
5
|
SimpleCov.profiles.define "root_filter" do
|
|
6
6
|
# Exclude all files outside of simplecov root
|
|
7
|
-
root_filter =
|
|
7
|
+
root_filter = nil
|
|
8
8
|
add_filter do |src|
|
|
9
|
+
root_filter ||= /\A#{Regexp.escape(SimpleCov.root)}/io
|
|
9
10
|
!(src.filename =~ root_filter)
|
|
10
11
|
end
|
|
11
12
|
end
|
|
@@ -31,6 +32,7 @@ SimpleCov.profiles.define "rails" do
|
|
|
31
32
|
add_group "Models", "app/models"
|
|
32
33
|
add_group "Mailers", "app/mailers"
|
|
33
34
|
add_group "Helpers", "app/helpers"
|
|
35
|
+
add_group "Jobs", %w(app/jobs app/workers)
|
|
34
36
|
add_group "Libraries", "lib"
|
|
35
37
|
|
|
36
38
|
track_files "{app,lib}/**/*.rb"
|
|
@@ -51,15 +53,16 @@ at_exit do
|
|
|
51
53
|
# If we are in a different process than called start, don't interfere.
|
|
52
54
|
next if SimpleCov.pid != Process.pid
|
|
53
55
|
|
|
54
|
-
if $! # was an exception thrown?
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
@exit_status = if $! # was an exception thrown?
|
|
57
|
+
# if it was a SystemExit, use the accompanying status
|
|
58
|
+
# otherwise set a non-zero status representing termination by
|
|
59
|
+
# some other exception (see github issue 41)
|
|
60
|
+
$!.is_a?(SystemExit) ? $!.status : SimpleCov::ExitCodes::EXCEPTION
|
|
61
|
+
else
|
|
62
|
+
# Store the exit status of the test run since it goes away
|
|
63
|
+
# after calling the at_exit proc...
|
|
64
|
+
SimpleCov::ExitCodes::SUCCESS
|
|
65
|
+
end
|
|
63
66
|
|
|
64
67
|
SimpleCov.at_exit.call
|
|
65
68
|
|
data/lib/simplecov/filter.rb
CHANGED
data/lib/simplecov/jruby_fix.rb
CHANGED
|
@@ -11,7 +11,7 @@ if defined?(JRUBY_VERSION) && JRUBY_VERSION.to_f < 1.7
|
|
|
11
11
|
# This monkey patches Coverage to address those issues
|
|
12
12
|
module Coverage
|
|
13
13
|
class << self
|
|
14
|
-
|
|
14
|
+
alias __broken_result__ result
|
|
15
15
|
|
|
16
16
|
def result # rubocop:disable Metrics/MethodLength
|
|
17
17
|
fixed = {}
|
|
@@ -4,13 +4,12 @@ module SimpleCov
|
|
|
4
4
|
def merge_resultset(array)
|
|
5
5
|
new_array = dup
|
|
6
6
|
array.each_with_index do |element, i|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
end
|
|
7
|
+
pair = [element, new_array[i]]
|
|
8
|
+
new_array[i] = if pair.any?(&:nil?) && pair.map(&:to_i).all?(&:zero?)
|
|
9
|
+
nil
|
|
10
|
+
else
|
|
11
|
+
element.to_i + new_array[i].to_i
|
|
12
|
+
end
|
|
14
13
|
end
|
|
15
14
|
new_array
|
|
16
15
|
end
|
|
@@ -27,12 +26,9 @@ module SimpleCov
|
|
|
27
26
|
end
|
|
28
27
|
|
|
29
28
|
new_resultset.each_key do |filename|
|
|
30
|
-
new_resultset[filename] = (self[filename] || []).merge_resultset(hash[filename] || [])
|
|
29
|
+
new_resultset[filename] = (self[filename] || []).extend(SimpleCov::ArrayMergeHelper).merge_resultset(hash[filename] || [])
|
|
31
30
|
end
|
|
32
31
|
new_resultset
|
|
33
32
|
end
|
|
34
33
|
end
|
|
35
34
|
end
|
|
36
|
-
|
|
37
|
-
Array.send :include, SimpleCov::ArrayMergeHelper
|
|
38
|
-
Hash.send :include, SimpleCov::HashMergeHelper
|
data/lib/simplecov/profiles.rb
CHANGED
|
@@ -15,7 +15,7 @@ module SimpleCov
|
|
|
15
15
|
#
|
|
16
16
|
def define(name, &blk)
|
|
17
17
|
name = name.to_sym
|
|
18
|
-
|
|
18
|
+
raise "SimpleCov Profile '#{name}' is already defined" unless self[name].nil?
|
|
19
19
|
self[name] = blk
|
|
20
20
|
end
|
|
21
21
|
|
|
@@ -24,7 +24,7 @@ module SimpleCov
|
|
|
24
24
|
#
|
|
25
25
|
def load(name)
|
|
26
26
|
name = name.to_sym
|
|
27
|
-
|
|
27
|
+
raise "Could not find SimpleCov Profile called '#{name}'" unless key?(name)
|
|
28
28
|
SimpleCov.configure(&self[name])
|
|
29
29
|
end
|
|
30
30
|
end
|
data/lib/simplecov/result.rb
CHANGED
|
@@ -12,7 +12,7 @@ module SimpleCov
|
|
|
12
12
|
attr_reader :original_result
|
|
13
13
|
# Returns all files that are applicable to this result (sans filters!) as instances of SimpleCov::SourceFile. Aliased as :source_files
|
|
14
14
|
attr_reader :files
|
|
15
|
-
|
|
15
|
+
alias source_files files
|
|
16
16
|
# Explicitly set the Time this result has been created
|
|
17
17
|
attr_writer :created_at
|
|
18
18
|
# Explicitly set the command name that was used for this coverage result. Defaults to SimpleCov.command_name
|
|
@@ -24,6 +24,7 @@ module SimpleCov
|
|
|
24
24
|
# Initialize a new SimpleCov::Result from given Coverage.result (a Hash of filenames each containing an array of
|
|
25
25
|
# coverage data)
|
|
26
26
|
def initialize(original_result)
|
|
27
|
+
original_result = original_result.dup.extend(SimpleCov::HashMergeHelper) unless original_result.is_a? SimpleCov::HashMergeHelper
|
|
27
28
|
@original_result = original_result.freeze
|
|
28
29
|
@files = SimpleCov::FileList.new(original_result.map do |filename, coverage|
|
|
29
30
|
SimpleCov::SourceFile.new(filename, coverage) if File.file?(filename)
|
|
@@ -20,14 +20,14 @@ module SimpleCov
|
|
|
20
20
|
attr_reader :skipped
|
|
21
21
|
|
|
22
22
|
# Lets grab some fancy aliases, shall we?
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
alias source src
|
|
24
|
+
alias line line_number
|
|
25
|
+
alias number line_number
|
|
26
26
|
|
|
27
27
|
def initialize(src, line_number, coverage)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
raise ArgumentError, "Only String accepted for source" unless src.is_a?(String)
|
|
29
|
+
raise ArgumentError, "Only Fixnum accepted for line_number" unless line_number.is_a?(Fixnum)
|
|
30
|
+
raise ArgumentError, "Only Fixnum and nil accepted for coverage" unless coverage.is_a?(Fixnum) || coverage.nil?
|
|
31
31
|
@src = src
|
|
32
32
|
@line_number = line_number
|
|
33
33
|
@coverage = coverage
|
|
@@ -76,7 +76,7 @@ module SimpleCov
|
|
|
76
76
|
attr_reader :coverage
|
|
77
77
|
# The source code for this file. Aliased as :source
|
|
78
78
|
attr_reader :src
|
|
79
|
-
|
|
79
|
+
alias source src
|
|
80
80
|
|
|
81
81
|
def initialize(filename, coverage)
|
|
82
82
|
@filename = filename
|
|
@@ -102,7 +102,7 @@ module SimpleCov
|
|
|
102
102
|
process_skipped_lines!
|
|
103
103
|
@lines
|
|
104
104
|
end
|
|
105
|
-
|
|
105
|
+
alias source_lines lines
|
|
106
106
|
|
|
107
107
|
# Access SimpleCov::SourceFile::Line source lines by line number
|
|
108
108
|
def line(number)
|
|
@@ -116,7 +116,7 @@ module SimpleCov
|
|
|
116
116
|
if relevant_lines.zero?
|
|
117
117
|
0.0
|
|
118
118
|
else
|
|
119
|
-
Float(
|
|
119
|
+
Float(covered_lines.count * 100.0 / relevant_lines.to_f)
|
|
120
120
|
end
|
|
121
121
|
end
|
|
122
122
|
|
|
@@ -172,8 +172,8 @@ module SimpleCov
|
|
|
172
172
|
lines.each do |line|
|
|
173
173
|
if line.src =~ /^([\s]*)#([\s]*)(\:#{SimpleCov.nocov_token}\:)/
|
|
174
174
|
skipping = !skipping
|
|
175
|
-
|
|
176
|
-
line.skipped!
|
|
175
|
+
elsif skipping
|
|
176
|
+
line.skipped!
|
|
177
177
|
end
|
|
178
178
|
end
|
|
179
179
|
end
|
data/lib/simplecov/version.rb
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
module SimpleCov
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
version = "0.12.0"
|
|
3
|
+
|
|
4
|
+
def version.to_a
|
|
4
5
|
split(".").map(&:to_i)
|
|
5
6
|
end
|
|
6
7
|
|
|
7
|
-
def
|
|
8
|
+
def version.major
|
|
8
9
|
to_a[0]
|
|
9
10
|
end
|
|
10
11
|
|
|
11
|
-
def
|
|
12
|
+
def version.minor
|
|
12
13
|
to_a[1]
|
|
13
14
|
end
|
|
14
15
|
|
|
15
|
-
def
|
|
16
|
+
def version.patch
|
|
16
17
|
to_a[2]
|
|
17
18
|
end
|
|
18
19
|
|
|
19
|
-
def
|
|
20
|
+
def version.pre
|
|
20
21
|
to_a[3]
|
|
21
22
|
end
|
|
23
|
+
|
|
24
|
+
VERSION = version
|
|
22
25
|
end
|
data/lib/simplecov.rb
CHANGED
|
@@ -2,13 +2,18 @@
|
|
|
2
2
|
# Code coverage for ruby 1.9. Please check out README for a full introduction.
|
|
3
3
|
#
|
|
4
4
|
# Coverage may be inaccurate under JRUBY.
|
|
5
|
-
if defined?(JRUBY_VERSION)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
if defined?(JRUBY_VERSION) && defined?(JRuby)
|
|
6
|
+
|
|
7
|
+
# @see https://github.com/jruby/jruby/issues/1196
|
|
8
|
+
# @see https://github.com/metricfu/metric_fu/pull/226
|
|
9
|
+
# @see https://github.com/colszowka/simplecov/issues/420
|
|
10
|
+
# @see https://github.com/colszowka/simplecov/issues/86
|
|
11
|
+
# @see https://jira.codehaus.org/browse/JRUBY-6106
|
|
12
|
+
|
|
13
|
+
unless org.jruby.RubyInstanceConfig.FULL_TRACE_ENABLED
|
|
14
|
+
warn 'Coverage may be inaccurate; set the "--debug" command line option,' \
|
|
15
|
+
' or do JRUBY_OPTS="--debug"' \
|
|
16
|
+
' or set the "debug.fullTrace=true" option in your .jrubyrc'
|
|
12
17
|
end
|
|
13
18
|
end
|
|
14
19
|
module SimpleCov
|
|
@@ -53,9 +58,9 @@ module SimpleCov
|
|
|
53
58
|
# their coverage to zero.
|
|
54
59
|
#
|
|
55
60
|
def add_not_loaded_files(result)
|
|
56
|
-
if
|
|
61
|
+
if track_files
|
|
57
62
|
result = result.dup
|
|
58
|
-
Dir[
|
|
63
|
+
Dir[track_files].each do |file|
|
|
59
64
|
absolute = File.expand_path(file)
|
|
60
65
|
|
|
61
66
|
result[absolute] ||= [0] * File.foreach(absolute).count
|
|
@@ -70,14 +75,22 @@ module SimpleCov
|
|
|
70
75
|
# from cache using SimpleCov::ResultMerger if use_merging is activated (default)
|
|
71
76
|
#
|
|
72
77
|
def result
|
|
73
|
-
|
|
78
|
+
# Ensure the variable is defined to avoid ruby warnings
|
|
79
|
+
@result = nil unless defined?(@result)
|
|
80
|
+
|
|
81
|
+
# Collect our coverage result
|
|
82
|
+
if running && !result?
|
|
83
|
+
@result = SimpleCov::Result.new add_not_loaded_files(Coverage.result)
|
|
84
|
+
end
|
|
85
|
+
|
|
74
86
|
# If we're using merging of results, store the current result
|
|
75
87
|
# first, then merge the results and return those
|
|
76
88
|
if use_merging
|
|
77
|
-
SimpleCov::ResultMerger.store_result(@result) if
|
|
78
|
-
|
|
89
|
+
SimpleCov::ResultMerger.store_result(@result) if result?
|
|
90
|
+
|
|
91
|
+
SimpleCov::ResultMerger.merged_result
|
|
79
92
|
else
|
|
80
|
-
|
|
93
|
+
@result
|
|
81
94
|
end
|
|
82
95
|
ensure
|
|
83
96
|
self.running = false
|
|
@@ -112,7 +125,7 @@ module SimpleCov
|
|
|
112
125
|
grouped[name] = SimpleCov::FileList.new(files.select { |source_file| filter.matches?(source_file) })
|
|
113
126
|
grouped_files += grouped[name]
|
|
114
127
|
end
|
|
115
|
-
if groups.
|
|
128
|
+
if !groups.empty? && !(other_files = files.reject { |source_file| grouped_files.include?(source_file) }).empty?
|
|
116
129
|
grouped["Ungrouped"] = SimpleCov::FileList.new(other_files)
|
|
117
130
|
end
|
|
118
131
|
grouped
|
data/simplecov.gemspec
CHANGED
|
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
|
|
|
14
14
|
|
|
15
15
|
gem.required_ruby_version = ">= 1.8.7"
|
|
16
16
|
|
|
17
|
-
gem.add_dependency "json", "
|
|
17
|
+
gem.add_dependency "json", ">= 1.8", "< 3"
|
|
18
18
|
gem.add_dependency "simplecov-html", "~> 0.10.0"
|
|
19
19
|
gem.add_dependency "docile", "~> 1.1.0"
|
|
20
20
|
|
data/spec/1_8_fallbacks_spec.rb
CHANGED
|
@@ -12,11 +12,11 @@ describe "Ruby 1.8 fallback" do
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
it "return false when calling SimpleCov.start with a block" do
|
|
15
|
-
expect(SimpleCov.start {
|
|
15
|
+
expect(SimpleCov.start { raise "Shouldn't reach this!" }).to be false
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it "return false when calling SimpleCov.configure with a block" do
|
|
19
|
-
expect(SimpleCov.configure {
|
|
19
|
+
expect(SimpleCov.configure { raise "Shouldn't reach this!" }).to be false
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it "allow to define a profile" do
|
data/spec/merge_helpers_spec.rb
CHANGED
|
@@ -9,13 +9,15 @@ describe "merge helpers" do
|
|
|
9
9
|
source_fixture("app/models/user.rb") => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
|
|
10
10
|
source_fixture("app/controllers/sample_controller.rb") => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
|
|
11
11
|
source_fixture("resultset1.rb") => [1, 1, 1, 1],
|
|
12
|
-
|
|
12
|
+
source_fixture("parallel_tests.rb") => [nil, 0, nil, 0],
|
|
13
|
+
}.extend(SimpleCov::HashMergeHelper)
|
|
13
14
|
|
|
14
15
|
@resultset2 = {
|
|
15
16
|
source_fixture("sample.rb") => [1, nil, 1, 1, nil, nil, 1, 1, nil, nil],
|
|
16
17
|
source_fixture("app/models/user.rb") => [nil, 1, 5, 1, nil, nil, 1, 0, nil, nil],
|
|
17
18
|
source_fixture("app/controllers/sample_controller.rb") => [nil, 3, 1, nil, nil, nil, 1, 0, nil, nil],
|
|
18
19
|
source_fixture("resultset2.rb") => [nil, 1, 1, nil],
|
|
20
|
+
source_fixture("parallel_tests.rb") => [nil, nil, 0, 0],
|
|
19
21
|
}
|
|
20
22
|
end
|
|
21
23
|
|
|
@@ -43,6 +45,10 @@ describe "merge helpers" do
|
|
|
43
45
|
it "has proper results for resultset2.rb" do
|
|
44
46
|
expect(subject[source_fixture("resultset2.rb")]).to eq([nil, 1, 1, nil])
|
|
45
47
|
end
|
|
48
|
+
|
|
49
|
+
it "has proper results for parallel_tests.rb" do
|
|
50
|
+
expect(subject[source_fixture("parallel_tests.rb")]).to eq([nil, nil, nil, 0])
|
|
51
|
+
end
|
|
46
52
|
end
|
|
47
53
|
|
|
48
54
|
# See Github issue #6
|
data/spec/return_codes_spec.rb
CHANGED
|
@@ -4,14 +4,11 @@ require "helper"
|
|
|
4
4
|
# See https://github.com/colszowka/simplecov/issues/5
|
|
5
5
|
describe "return codes" do
|
|
6
6
|
context "inside fixtures/frameworks" do
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
after do
|
|
14
|
-
Dir.chdir(@current_dir)
|
|
7
|
+
around do |test|
|
|
8
|
+
Dir.chdir(File.join(File.dirname(__FILE__), "fixtures", "frameworks")) do
|
|
9
|
+
FileUtils.rm_rf("./coverage")
|
|
10
|
+
test.call
|
|
11
|
+
end
|
|
15
12
|
end
|
|
16
13
|
|
|
17
14
|
it "has return code 0 when running testunit_good.rb" do
|
data/spec/source_file_spec.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require "helper"
|
|
2
2
|
|
|
3
3
|
describe SimpleCov::SourceFile do
|
|
4
|
-
COVERAGE_FOR_SAMPLE_RB = [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil, nil, nil, nil, nil, nil, nil]
|
|
4
|
+
COVERAGE_FOR_SAMPLE_RB = [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil, nil, nil, nil, nil, nil, nil].freeze
|
|
5
5
|
context "a source file initialized with some coverage data" do
|
|
6
6
|
subject do
|
|
7
7
|
SimpleCov::SourceFile.new(source_fixture("sample.rb"), COVERAGE_FOR_SAMPLE_RB)
|
metadata
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: simplecov
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.12.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Christoph Olszowka
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2016-07-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: json
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: '1.8'
|
|
20
|
+
- - "<"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '3'
|
|
20
23
|
type: :runtime
|
|
21
24
|
prerelease: false
|
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
26
|
requirements:
|
|
24
|
-
- - "
|
|
27
|
+
- - ">="
|
|
25
28
|
- !ruby/object:Gem::Version
|
|
26
29
|
version: '1.8'
|
|
30
|
+
- - "<"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '3'
|
|
27
33
|
- !ruby/object:Gem::Dependency
|
|
28
34
|
name: simplecov-html
|
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -209,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
209
215
|
version: '0'
|
|
210
216
|
requirements: []
|
|
211
217
|
rubyforge_project:
|
|
212
|
-
rubygems_version: 2.
|
|
218
|
+
rubygems_version: 2.5.1
|
|
213
219
|
signing_key:
|
|
214
220
|
specification_version: 4
|
|
215
221
|
summary: Code coverage for Ruby 1.9+ with a powerful configuration library and automatic
|