simplecov 0.14.1 → 0.15.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 +5 -5
- data/.rubocop.yml +6 -2
- data/.travis.yml +4 -4
- data/CHANGELOG.md +15 -0
- data/Gemfile +2 -2
- data/MIT-LICENSE +1 -1
- data/README.md +51 -5
- data/doc/editor-integration.md +6 -1
- data/features/config_tracked_files.feature +1 -1
- data/features/config_tracked_files_relevant_lines.feature +31 -0
- data/features/step_definitions/transformers.rb +1 -1
- data/features/support/aruba_freedom_patch.rb +53 -0
- data/features/support/env.rb +5 -5
- data/lib/simplecov.rb +16 -10
- data/lib/simplecov/configuration.rb +5 -9
- data/lib/simplecov/defaults.rb +4 -4
- data/lib/simplecov/file_list.rb +5 -5
- data/lib/simplecov/filter.rb +39 -4
- data/lib/simplecov/formatter/simple_formatter.rb +1 -1
- data/lib/simplecov/lines_classifier.rb +32 -0
- data/lib/simplecov/result_merger.rb +42 -13
- data/lib/simplecov/source_file.rb +6 -1
- data/lib/simplecov/version.rb +1 -23
- data/spec/filters_spec.rb +74 -0
- data/spec/lines_classifier_spec.rb +103 -0
- data/spec/result_merger_spec.rb +89 -6
- data/spec/simplecov_spec.rb +109 -0
- data/spec/source_file_spec.rb +4 -0
- metadata +20 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 316080f1732d39e050a8c0310aa1527717c2216ac5ab7b570dca4076e358a041
|
4
|
+
data.tar.gz: 1417f8a0e41fab72d8b2d86b583dec9c5b47adde77f26dce84ee3646985b0a43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d58eee98ca6d7da2412747c6972560cdb835f110d37041a84816d44b8d433deb9d2b0bf20ce29012f90d2f2978afed2ae1bfdde3540b4d078a69adb2a64623e
|
7
|
+
data.tar.gz: cbbf89810a47ffec5328846f0135e98fac7fc0827d5cda4db59c8b761ce7c307e73f8cdc4e15e8db8e192e28b5c0eed8c15399f52bedacca4517cc76ef0556e5
|
data/.rubocop.yml
CHANGED
@@ -3,6 +3,7 @@ AllCops:
|
|
3
3
|
- 'spec/fixtures/iso-8859.rb'
|
4
4
|
- 'tmp/**/*'
|
5
5
|
- 'vendor/bundle/**/*'
|
6
|
+
TargetRubyVersion: 1.9
|
6
7
|
|
7
8
|
Bundler/OrderedGems:
|
8
9
|
Enabled: false
|
@@ -35,7 +36,7 @@ Metrics/ParameterLists:
|
|
35
36
|
Max: 4
|
36
37
|
CountKeywordArgs: true
|
37
38
|
|
38
|
-
|
39
|
+
Layout/AccessModifierIndentation:
|
39
40
|
EnforcedStyle: outdent
|
40
41
|
|
41
42
|
Style/CollectionMethods:
|
@@ -54,10 +55,13 @@ Style/DoubleNegation:
|
|
54
55
|
Style/HashSyntax:
|
55
56
|
EnforcedStyle: hash_rockets
|
56
57
|
|
58
|
+
Layout/IndentHeredoc:
|
59
|
+
Enabled: false
|
60
|
+
|
57
61
|
Style/RegexpLiteral:
|
58
62
|
Enabled: false
|
59
63
|
|
60
|
-
|
64
|
+
Layout/SpaceInsideHashLiteralBraces:
|
61
65
|
EnforcedStyle: no_space
|
62
66
|
|
63
67
|
Style/SpecialGlobalVars:
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
0.15.0 (2017-08-14) ([changes](https://github.com/colszowka/simplecov/compare/v0.14.1...v0.15.0))
|
2
|
+
=======
|
3
|
+
|
4
|
+
## Enhancements
|
5
|
+
|
6
|
+
* Ability to use regex filters for removing files from the output. See [#589](https://github.com/colszowka/simplecov/pull/589) (thanks @jsteel)
|
7
|
+
|
8
|
+
## Bugfixes
|
9
|
+
|
10
|
+
* Fix merging race condition when running tests in parallel and merging them. See [#570](https://github.com/colszowka/simplecov/pull/570) (thanks @jenseng)
|
11
|
+
* Fix relevant lines for unloaded files - comments, skipped code etc. are correctly classigied as irrelevant. See [#605](https://github.com/colszowka/simplecov/pull/605) (thanks @odlp)
|
12
|
+
* Allow using simplecov with frozen-string-literals enabled. See [#590](https://github.com/colszowka/simplecov/pull/590) (thanks @pat)
|
13
|
+
* Make sure Array Filter can use all other filter types. See [#589](https://github.com/colszowka/simplecov/pull/589) (thanks @jsteel)
|
14
|
+
* Make sure file names use `Simplecov.root` as base avoiding using full absolute project paths. See [#589](https://github.com/colszowka/simplecov/pull/589) (thanks @jsteel)
|
15
|
+
|
1
16
|
0.14.1 2017-03-18 ([changes](https://github.com/colszowka/simplecov/compare/v0.14.0...v0.14.1))
|
2
17
|
========
|
3
18
|
|
data/Gemfile
CHANGED
@@ -23,13 +23,13 @@ group :test do
|
|
23
23
|
gem "rack", "~> 1.6"
|
24
24
|
end
|
25
25
|
platforms :jruby, :ruby_19, :ruby_20, :ruby_21, :ruby_22, :ruby_23, :ruby_24, :ruby_25 do
|
26
|
-
gem "aruba", "~> 0.
|
26
|
+
gem "aruba", "~> 0.14"
|
27
27
|
gem "capybara"
|
28
28
|
gem "nokogiri", RUBY_VERSION < "2.1" ? "~> 1.6.0" : ">= 1.7"
|
29
29
|
gem "cucumber"
|
30
30
|
gem "phantomjs", "~> 2.1"
|
31
31
|
gem "poltergeist"
|
32
|
-
gem "rubocop" unless RUBY_VERSION.start_with?("1.")
|
32
|
+
gem "rubocop", "0.49.1" unless RUBY_VERSION.start_with?("1.")
|
33
33
|
gem "test-unit"
|
34
34
|
end
|
35
35
|
gem "json", RUBY_VERSION.start_with?("1.") ? "~> 1.8" : "~> 2.0"
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -40,7 +40,7 @@ automatically when you launch SimpleCov. If you're curious, you can find it [on
|
|
40
40
|
|
41
41
|
*Questions, Problems, Suggestions, etc.*
|
42
42
|
|
43
|
-
* [Mailing List]
|
43
|
+
* [Mailing List](https://groups.google.com/forum/#!forum/simplecov) "Open mailing list for discussion and announcements on Google Groups"
|
44
44
|
|
45
45
|
Getting started
|
46
46
|
---------------
|
@@ -133,6 +133,17 @@ to use SimpleCov with them. Here's an overview of the known ones:
|
|
133
133
|
|
134
134
|
<table>
|
135
135
|
<tr><th>Framework</th><th>Notes</th><th>Issue</th></tr>
|
136
|
+
<tr>
|
137
|
+
<th>
|
138
|
+
bootsnap
|
139
|
+
</th>
|
140
|
+
<td>
|
141
|
+
<a href="#want-to-use-bootsnap-with-simplecov">See section below.</a>
|
142
|
+
</td>
|
143
|
+
<td>
|
144
|
+
<a href="https://github.com/Shopify/bootsnap/issues/35">Shopify/bootsnap#35</a>
|
145
|
+
</td>
|
146
|
+
</tr>
|
136
147
|
<tr>
|
137
148
|
<th>
|
138
149
|
parallel_tests
|
@@ -262,7 +273,7 @@ report.
|
|
262
273
|
|
263
274
|
### Defining custom filters
|
264
275
|
|
265
|
-
You can currently define a filter using either a String (that will then be Regexp-matched against each source file's path),
|
276
|
+
You can currently define a filter using either a String or Regexp (that will then be Regexp-matched against each source file's path),
|
266
277
|
a block or by passing in your own Filter class.
|
267
278
|
|
268
279
|
#### String filter
|
@@ -275,6 +286,16 @@ end
|
|
275
286
|
|
276
287
|
This simple string filter will remove all files that match "/test/" in their path.
|
277
288
|
|
289
|
+
#### Regex filter
|
290
|
+
|
291
|
+
```ruby
|
292
|
+
SimpleCov.start do
|
293
|
+
add_filter %r{^/test/}
|
294
|
+
end
|
295
|
+
```
|
296
|
+
|
297
|
+
This simple regex filter will remove all files that start with /test/ in their path.
|
298
|
+
|
278
299
|
#### Block filter
|
279
300
|
|
280
301
|
```ruby
|
@@ -305,6 +326,17 @@ Defining your own filters is pretty easy: Just inherit from SimpleCov::Filter an
|
|
305
326
|
the filter, a true return value from this method will result in the removal of the given source_file. The filter_argument method
|
306
327
|
is being set in the SimpleCov::Filter initialize method and thus is set to 5 in this example.
|
307
328
|
|
329
|
+
#### Array filter
|
330
|
+
|
331
|
+
```ruby
|
332
|
+
SimpleCov.start do
|
333
|
+
proc = Proc.new { |source_file| false }
|
334
|
+
add_filter ["string", /regex/, proc, LineFilter.new(5)]
|
335
|
+
end
|
336
|
+
```
|
337
|
+
|
338
|
+
You can pass in an array containing any of the other filter types.
|
339
|
+
|
308
340
|
#### Ignoring/skipping code
|
309
341
|
|
310
342
|
You can exclude code from the coverage report by wrapping it in `# :nocov:`.
|
@@ -570,10 +602,10 @@ being an instance of SimpleCov::Result. Do whatever your wish with that!
|
|
570
602
|
As of SimpleCov 0.9, you can specify multiple result formats:
|
571
603
|
|
572
604
|
```ruby
|
573
|
-
SimpleCov.formatters = [
|
605
|
+
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([
|
574
606
|
SimpleCov::Formatter::HTMLFormatter,
|
575
607
|
SimpleCov::Formatter::CSVFormatter,
|
576
|
-
]
|
608
|
+
])
|
577
609
|
```
|
578
610
|
|
579
611
|
## Available formatters, editor integrations and hosted services
|
@@ -624,6 +656,20 @@ If you're using [Spring](https://github.com/rails/spring) to speed up test suite
|
|
624
656
|
```
|
625
657
|
3. Run `spring rspec <path>` as normal. Remember to run `spring stop` after
|
626
658
|
making important changes to your app or its specs!
|
659
|
+
|
660
|
+
## Want to use bootsnap with SimpleCov?
|
661
|
+
|
662
|
+
As mentioned in [this issue](https://github.com/Shopify/bootsnap/issues/35) iseq
|
663
|
+
loading/dumping doesn't work with coverage. Hence you need to deactivate it when
|
664
|
+
you run coverage so for instance when you use the environment `COVERAGE=true` to
|
665
|
+
decide that you want to gather coverage you can do:
|
666
|
+
|
667
|
+
```ruby
|
668
|
+
Bootsnap.setup(
|
669
|
+
compile_cache_iseq: !ENV["COVERAGE"], # Compile Ruby code into ISeq cache, breaks coverage reporting.
|
670
|
+
# all those other options
|
671
|
+
)
|
672
|
+
```
|
627
673
|
|
628
674
|
## Contributing
|
629
675
|
|
@@ -635,4 +681,4 @@ Thanks to Aaron Patterson for the original idea for this!
|
|
635
681
|
|
636
682
|
## Copyright
|
637
683
|
|
638
|
-
Copyright (c) 2010-
|
684
|
+
Copyright (c) 2010-2017 Christoph Olszowka. See MIT-LICENSE for details.
|
data/doc/editor-integration.md
CHANGED
@@ -7,7 +7,12 @@ Some editors have a graphical integration for the simplecov gem.
|
|
7
7
|
|
8
8
|
Adds an overview of your current test coverage to Atom.
|
9
9
|
|
10
|
+
#### [Sublime Editor: SimpleCov](https://packagecontrol.io/packages/SimpleCov)
|
11
|
+
*by sentience*
|
12
|
+
|
13
|
+
Adds in editor live coverage highlighting, status bar coverage information, and summary coverage information.
|
14
|
+
|
10
15
|
#### [cadre](https://github.com/nyarly/cadre)
|
11
16
|
*by Judson Lester*
|
12
17
|
|
13
|
-
Includes a formatter for Simplecov that emits a Vim script to mark up code files with coverage information.
|
18
|
+
Includes a formatter for Simplecov that emits a Vim script to mark up code files with coverage information.
|
@@ -16,7 +16,7 @@ Feature:
|
|
16
16
|
When I open the coverage report generated with `bundle exec rake test`
|
17
17
|
Then I should see the groups:
|
18
18
|
| name | coverage | files |
|
19
|
-
| All Files |
|
19
|
+
| All Files | 77.94% | 7 |
|
20
20
|
|
21
21
|
And I should see the source files:
|
22
22
|
| name | coverage |
|
@@ -0,0 +1,31 @@
|
|
1
|
+
@rspec
|
2
|
+
Feature:
|
3
|
+
|
4
|
+
Using the setting `tracked_files` should classify whether lines
|
5
|
+
are relevant or not (such as whitespace or comments).
|
6
|
+
|
7
|
+
Scenario:
|
8
|
+
Given SimpleCov for RSpec is configured with:
|
9
|
+
"""
|
10
|
+
require 'simplecov'
|
11
|
+
SimpleCov.start do
|
12
|
+
track_files "lib/**/*.rb"
|
13
|
+
end
|
14
|
+
"""
|
15
|
+
Given a file named "lib/not_loaded.rb" with:
|
16
|
+
"""
|
17
|
+
# A comment line. Plus a whitespace line below:
|
18
|
+
|
19
|
+
# :nocov:
|
20
|
+
def ignore_me
|
21
|
+
end
|
22
|
+
# :nocov:
|
23
|
+
|
24
|
+
def this_is_relevant
|
25
|
+
puts "still relevant"
|
26
|
+
end
|
27
|
+
"""
|
28
|
+
|
29
|
+
When I open the coverage report generated with `bundle exec rspec spec`
|
30
|
+
Then I follow "lib/not_loaded.rb"
|
31
|
+
Then I should see "3 relevant lines" within ".highlighted"
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# Freedom patch because of not working absolute directories, see: https://github.com/cucumber/aruba/issues/478
|
2
|
+
# code taken directly from aruba 0.14.2 - roughly here: https://github.com/cucumber/aruba/blob/master/lib/aruba/api/core.rb#L122-L159
|
3
|
+
# rubocop:disable all
|
4
|
+
module Aruba
|
5
|
+
module Api
|
6
|
+
module Core
|
7
|
+
def expand_path(file_name, dir_string = nil)
|
8
|
+
# only line added, don't ask why but I couldn't get alias_method to work...
|
9
|
+
return file_name if absolute?(file_name)
|
10
|
+
check_for_deprecated_variables if Aruba::VERSION < '1'
|
11
|
+
|
12
|
+
message = %(Filename "#{file_name}" needs to be a string. It cannot be nil or empty either. Please use `expand_path('.')` if you want the current directory to be expanded.)
|
13
|
+
|
14
|
+
fail ArgumentError, message unless file_name.is_a?(String) && !file_name.empty?
|
15
|
+
|
16
|
+
aruba.logger.warn %(`aruba`'s working directory does not exist. Maybe you forgot to run `setup_aruba` before using it's API. This warning will be an error from 1.0.0) unless Aruba.platform.directory? File.join(aruba.config.root_directory, aruba.config.working_directory)
|
17
|
+
|
18
|
+
if RUBY_VERSION < '1.9'
|
19
|
+
prefix = file_name.chars.to_a[0].to_s
|
20
|
+
rest = if file_name.chars.to_a[2..-1].nil?
|
21
|
+
nil
|
22
|
+
else
|
23
|
+
file_name.chars.to_a[2..-1].join
|
24
|
+
end
|
25
|
+
else
|
26
|
+
prefix = file_name[0]
|
27
|
+
rest = file_name[2..-1]
|
28
|
+
end
|
29
|
+
|
30
|
+
if aruba.config.fixtures_path_prefix == prefix
|
31
|
+
path = File.join(*[aruba.fixtures_directory, rest].compact)
|
32
|
+
|
33
|
+
fail ArgumentError, %(Fixture "#{rest}" does not exist in fixtures directory "#{aruba.fixtures_directory}". This was the one we found first on your system from all possible candidates: #{aruba.config.fixtures_directories.map { |p| format('"%s"', p) }.join(', ')}.) unless Aruba.platform.exist? path
|
34
|
+
|
35
|
+
path
|
36
|
+
elsif '~' == prefix
|
37
|
+
path = with_environment do
|
38
|
+
ArubaPath.new(File.expand_path(file_name))
|
39
|
+
end
|
40
|
+
|
41
|
+
fail ArgumentError, 'Expanding "~/" to "/" is not allowed' if path.to_s == '/'
|
42
|
+
fail ArgumentError, %(Expanding "~/" to a relative path "#{path}" is not allowed) unless path.absolute?
|
43
|
+
|
44
|
+
path.to_s
|
45
|
+
else
|
46
|
+
directory = File.join(aruba.root_directory, aruba.current_directory)
|
47
|
+
ArubaPath.new(File.join(*[directory, dir_string, file_name].compact)).expand_path.to_s
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
# rubocop:enable all
|
data/features/support/env.rb
CHANGED
@@ -6,7 +6,8 @@ end
|
|
6
6
|
require "bundler"
|
7
7
|
Bundler.setup
|
8
8
|
require "aruba/cucumber"
|
9
|
-
require "aruba/jruby" if RUBY_ENGINE == "jruby"
|
9
|
+
require "aruba/config/jruby" if RUBY_ENGINE == "jruby"
|
10
|
+
require_relative "aruba_freedom_patch"
|
10
11
|
require "capybara/cucumber"
|
11
12
|
require "phantomjs/poltergeist"
|
12
13
|
|
@@ -34,7 +35,7 @@ Before do
|
|
34
35
|
this_dir = File.dirname(__FILE__)
|
35
36
|
|
36
37
|
# Clean up and create blank state for fake project
|
37
|
-
|
38
|
+
cd(".") do
|
38
39
|
FileUtils.rm_rf "project"
|
39
40
|
FileUtils.cp_r File.join(this_dir, "../../spec/faked_project/"), "project"
|
40
41
|
end
|
@@ -44,7 +45,6 @@ end
|
|
44
45
|
|
45
46
|
# Workaround for https://github.com/cucumber/aruba/pull/125
|
46
47
|
Aruba.configure do |config|
|
47
|
-
config.
|
48
|
-
|
49
|
-
end
|
48
|
+
config.exit_timeout = RUBY_ENGINE == "jruby" ? 60 : 20
|
49
|
+
config.command_runtime_environment = {"JRUBY_OPTS" => "--dev --debug"}
|
50
50
|
end
|
data/lib/simplecov.rb
CHANGED
@@ -55,7 +55,7 @@ module SimpleCov
|
|
55
55
|
|
56
56
|
#
|
57
57
|
# Finds files that were to be tracked but were not loaded and initializes
|
58
|
-
#
|
58
|
+
# the line-by-line coverage to zero (if relevant) or nil (comments / whitespace etc).
|
59
59
|
#
|
60
60
|
def add_not_loaded_files(result)
|
61
61
|
if tracked_files
|
@@ -63,7 +63,7 @@ module SimpleCov
|
|
63
63
|
Dir[tracked_files].each do |file|
|
64
64
|
absolute = File.expand_path(file)
|
65
65
|
|
66
|
-
result[absolute] ||=
|
66
|
+
result[absolute] ||= LinesClassifier.new.classify(File.foreach(absolute))
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -75,23 +75,21 @@ module SimpleCov
|
|
75
75
|
# from cache using SimpleCov::ResultMerger if use_merging is activated (default)
|
76
76
|
#
|
77
77
|
def result
|
78
|
-
|
79
|
-
@result = nil unless defined?(@result)
|
78
|
+
return @result if result?
|
80
79
|
|
81
80
|
# Collect our coverage result
|
82
|
-
if running
|
81
|
+
if running
|
83
82
|
@result = SimpleCov::Result.new add_not_loaded_files(Coverage.result)
|
84
83
|
end
|
85
84
|
|
86
85
|
# If we're using merging of results, store the current result
|
87
|
-
# first, then merge the results and return those
|
86
|
+
# first (if there is one), then merge the results and return those
|
88
87
|
if use_merging
|
89
88
|
SimpleCov::ResultMerger.store_result(@result) if result?
|
90
|
-
|
91
|
-
SimpleCov::ResultMerger.merged_result
|
92
|
-
else
|
93
|
-
@result
|
89
|
+
@result = SimpleCov::ResultMerger.merged_result
|
94
90
|
end
|
91
|
+
|
92
|
+
@result
|
95
93
|
ensure
|
96
94
|
self.running = false
|
97
95
|
end
|
@@ -158,6 +156,13 @@ module SimpleCov
|
|
158
156
|
false
|
159
157
|
end
|
160
158
|
end
|
159
|
+
|
160
|
+
#
|
161
|
+
# Clear out the previously cached .result. Primarily useful in testing
|
162
|
+
#
|
163
|
+
def clear_result
|
164
|
+
@result = nil
|
165
|
+
end
|
161
166
|
end
|
162
167
|
end
|
163
168
|
|
@@ -172,6 +177,7 @@ require "simplecov/result"
|
|
172
177
|
require "simplecov/filter"
|
173
178
|
require "simplecov/formatter"
|
174
179
|
require "simplecov/last_run"
|
180
|
+
require "simplecov/lines_classifier"
|
175
181
|
require "simplecov/raw_coverage"
|
176
182
|
require "simplecov/result_merger"
|
177
183
|
require "simplecov/command_guesser"
|
@@ -291,16 +291,12 @@ module SimpleCov
|
|
291
291
|
# The actual filter processor. Not meant for direct use
|
292
292
|
#
|
293
293
|
def parse_filter(filter_argument = nil, &filter_proc)
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
SimpleCov::
|
298
|
-
elsif filter_proc
|
299
|
-
SimpleCov::BlockFilter.new(filter_proc)
|
300
|
-
elsif filter_argument.is_a?(Array)
|
301
|
-
SimpleCov::ArrayFilter.new(filter_argument)
|
294
|
+
filter = filter_argument || filter_proc
|
295
|
+
|
296
|
+
if filter
|
297
|
+
SimpleCov::Filter.build_filter(filter)
|
302
298
|
else
|
303
|
-
raise ArgumentError, "Please specify either a
|
299
|
+
raise ArgumentError, "Please specify either a filter or a block to filter with"
|
304
300
|
end
|
305
301
|
end
|
306
302
|
end
|