simplecov 0.15.0 → 0.16.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/CHANGELOG.md +26 -2
- data/CONTRIBUTING.md +12 -9
- data/ISSUE_TEMPLATE.md +23 -0
- data/README.md +42 -16
- data/doc/alternate-formatters.md +16 -1
- data/lib/simplecov/command_guesser.rb +2 -0
- data/lib/simplecov/configuration.rb +2 -0
- data/lib/simplecov/defaults.rb +9 -80
- data/lib/simplecov/exit_codes.rb +2 -0
- data/lib/simplecov/file_list.rb +2 -0
- data/lib/simplecov/filter.rb +3 -1
- data/lib/simplecov/formatter/multi_formatter.rb +2 -0
- data/lib/simplecov/formatter/simple_formatter.rb +2 -0
- data/lib/simplecov/formatter.rb +2 -0
- data/lib/simplecov/jruby_fix.rb +2 -0
- data/lib/simplecov/last_run.rb +2 -0
- data/lib/simplecov/lines_classifier.rb +19 -3
- data/lib/simplecov/load_global_config.rb +2 -0
- data/lib/simplecov/no_defaults.rb +2 -0
- data/lib/simplecov/profiles/bundler_filter.rb +5 -0
- data/lib/simplecov/profiles/rails.rb +18 -0
- data/lib/simplecov/profiles/root_filter.rb +10 -0
- data/lib/simplecov/profiles/test_frameworks.rb +8 -0
- data/lib/simplecov/profiles.rb +2 -0
- data/lib/simplecov/railtie.rb +2 -0
- data/lib/simplecov/railties/tasks.rake +2 -0
- data/lib/simplecov/raw_coverage.rb +2 -0
- data/lib/simplecov/result.rb +2 -0
- data/lib/simplecov/result_merger.rb +2 -0
- data/lib/simplecov/source_file.rb +3 -1
- data/lib/simplecov/version.rb +3 -1
- data/lib/simplecov.rb +91 -0
- metadata +22 -117
- data/.gitignore +0 -31
- data/.rspec +0 -3
- data/.rubocop.yml +0 -88
- data/.travis.yml +0 -29
- data/.yardopts +0 -1
- data/Gemfile +0 -38
- data/MIT-LICENSE +0 -20
- data/Rakefile +0 -41
- data/cucumber.yml +0 -13
- data/features/config_autoload.feature +0 -46
- data/features/config_command_name.feature +0 -45
- data/features/config_coverage_dir.feature +0 -33
- data/features/config_deactivate_merging.feature +0 -42
- data/features/config_formatters.feature +0 -77
- data/features/config_merge_timeout.feature +0 -39
- data/features/config_nocov_token.feature +0 -79
- data/features/config_profiles.feature +0 -44
- data/features/config_project_name.feature +0 -27
- data/features/config_styles.feature +0 -121
- data/features/config_tracked_files.feature +0 -29
- data/features/config_tracked_files_relevant_lines.feature +0 -31
- data/features/cucumber_basic.feature +0 -29
- data/features/maximum_coverage_drop.feature +0 -89
- data/features/merging_test_unit_and_rspec.feature +0 -44
- data/features/minimum_coverage.feature +0 -59
- data/features/refuse_coverage_drop.feature +0 -95
- data/features/rspec_basic.feature +0 -32
- data/features/rspec_fails_on_initialization.feature +0 -14
- data/features/rspec_groups_and_filters_basic.feature +0 -29
- data/features/rspec_groups_and_filters_complex.feature +0 -37
- data/features/rspec_groups_using_filter_class.feature +0 -41
- data/features/rspec_without_simplecov.feature +0 -20
- data/features/skipping_code_blocks_manually.feature +0 -70
- data/features/step_definitions/html_steps.rb +0 -44
- data/features/step_definitions/simplecov_steps.rb +0 -68
- data/features/step_definitions/transformers.rb +0 -13
- data/features/step_definitions/web_steps.rb +0 -64
- data/features/support/aruba_freedom_patch.rb +0 -53
- data/features/support/env.rb +0 -50
- data/features/test_unit_basic.feature +0 -34
- data/features/test_unit_groups_and_filters_basic.feature +0 -29
- data/features/test_unit_groups_and_filters_complex.feature +0 -35
- data/features/test_unit_groups_using_filter_class.feature +0 -40
- data/features/test_unit_without_simplecov.feature +0 -20
- data/features/unicode_compatiblity.feature +0 -67
- data/simplecov.gemspec +0 -27
- data/spec/1_8_fallbacks_spec.rb +0 -31
- data/spec/command_guesser_spec.rb +0 -48
- data/spec/config_loader_spec.rb +0 -14
- data/spec/configuration_spec.rb +0 -35
- data/spec/deleted_source_spec.rb +0 -12
- data/spec/faked_project/Gemfile +0 -6
- data/spec/faked_project/Rakefile +0 -8
- data/spec/faked_project/cucumber.yml +0 -13
- data/spec/faked_project/features/step_definitions/my_steps.rb +0 -22
- data/spec/faked_project/features/support/env.rb +0 -12
- data/spec/faked_project/features/test_stuff.feature +0 -6
- data/spec/faked_project/lib/faked_project/framework_specific.rb +0 -18
- data/spec/faked_project/lib/faked_project/meta_magic.rb +0 -24
- data/spec/faked_project/lib/faked_project/some_class.rb +0 -28
- data/spec/faked_project/lib/faked_project/untested_class.rb +0 -11
- data/spec/faked_project/lib/faked_project.rb +0 -11
- data/spec/faked_project/spec/faked_spec.rb +0 -11
- data/spec/faked_project/spec/forking_spec.rb +0 -8
- data/spec/faked_project/spec/meta_magic_spec.rb +0 -15
- data/spec/faked_project/spec/some_class_spec.rb +0 -13
- data/spec/faked_project/spec/spec_helper.rb +0 -11
- data/spec/faked_project/test/faked_test.rb +0 -11
- data/spec/faked_project/test/meta_magic_test.rb +0 -13
- data/spec/faked_project/test/some_class_test.rb +0 -15
- data/spec/faked_project/test/test_helper.rb +0 -12
- data/spec/file_list_spec.rb +0 -50
- data/spec/filters_spec.rb +0 -172
- data/spec/fixtures/app/controllers/sample_controller.rb +0 -10
- data/spec/fixtures/app/models/user.rb +0 -10
- data/spec/fixtures/deleted_source_sample.rb +0 -15
- data/spec/fixtures/frameworks/rspec_bad.rb +0 -9
- data/spec/fixtures/frameworks/rspec_good.rb +0 -9
- data/spec/fixtures/frameworks/testunit_bad.rb +0 -9
- data/spec/fixtures/frameworks/testunit_good.rb +0 -9
- data/spec/fixtures/iso-8859.rb +0 -3
- data/spec/fixtures/never.rb +0 -2
- data/spec/fixtures/resultset1.rb +0 -4
- data/spec/fixtures/resultset2.rb +0 -4
- data/spec/fixtures/sample.rb +0 -16
- data/spec/fixtures/skipped.rb +0 -4
- data/spec/fixtures/skipped_and_executed.rb +0 -8
- data/spec/fixtures/utf-8.rb +0 -3
- data/spec/helper.rb +0 -26
- data/spec/last_run_spec.rb +0 -48
- data/spec/lines_classifier_spec.rb +0 -103
- data/spec/multi_formatter_spec.rb +0 -20
- data/spec/raw_coverage_spec.rb +0 -92
- data/spec/result_merger_spec.rb +0 -171
- data/spec/result_spec.rb +0 -209
- data/spec/return_codes_spec.rb +0 -34
- data/spec/simplecov_spec.rb +0 -109
- data/spec/source_file_line_spec.rb +0 -155
- data/spec/source_file_spec.rb +0 -145
- data/spec/support/fail_rspec_on_ruby_warning.rb +0 -75
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 47d20d0dc990b18c8ac6bcc24755bb66521230c3
|
|
4
|
+
data.tar.gz: 22c23ddd73f1052aa525905f82f7545f63207ee7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 320807d6f5176f76cb38f7fcbc6eb1e59b2e0cffcd4eb28bcf804f0eaf824b5a44926345f0516ae40a091ec866ad8e8aff43aed8536b5812bffabe5b6d2bc005
|
|
7
|
+
data.tar.gz: cf2c3e9a80d843f3970b3a0ac9ab5e21e81a18ea1ae306cebe74bc7f77bf6263115a1b6405547d26f608a574ab7a8d1da901d9d9a8524edee0e5a19241cd932d
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
0.16.0 (2018-03-15)
|
|
2
|
+
==========
|
|
3
|
+
|
|
4
|
+
## Enhancements
|
|
5
|
+
|
|
6
|
+
* Relax version constraint on `docile`, per SemVer
|
|
7
|
+
* exception that occurred on exit is available as `exit_exception`! See [#639](https://github.com/colszowka/simplecov/pull/639) (thanks @thomas07vt)
|
|
8
|
+
* Performance: processing results now runs from 2.5x to 3.75x faster. See [#662](https://github.com/colszowka/simplecov/pull/662) (thanks @BMorearty & @eregon)
|
|
9
|
+
* Decrease gem size by only shipping lib and docs
|
|
10
|
+
|
|
11
|
+
## Bugfixes
|
|
12
|
+
|
|
13
|
+
* (breaking) Stop handling string filters as regular expressions, use the dedicated regex filter if you need that behaviour. See [#616](https://github.com/colszowka/simplecov/pull/616) (thanks @yujinakayama)
|
|
14
|
+
* Avoid overwriting the last coverage results on unsuccessful test runs. See [#625](https://github.com/colszowka/simplecov/pull/625) (thanks @thomas07vt)
|
|
15
|
+
* Don't crash on invalid UTF-8 byte sequences. (thanks @BMorearty)
|
|
16
|
+
|
|
17
|
+
0.15.1 (2017-09-11) ([changes](https://github.com/colszowka/simplecov/compare/v0.15.0...v0.15.1))
|
|
18
|
+
=======
|
|
19
|
+
|
|
20
|
+
## Bugfixes
|
|
21
|
+
|
|
22
|
+
* Filter directories outside SimpleCov.root that have it as a prefix. See [#617](https://github.com/colszowka/simplecov/pull/617) (thanks @jenseng)
|
|
23
|
+
* Fix standard rails profile rails filter (didn't work). See [#618](https://github.com/colszowka/simplecov/pull/618) (thanks @jenseng again!)
|
|
24
|
+
|
|
1
25
|
0.15.0 (2017-08-14) ([changes](https://github.com/colszowka/simplecov/compare/v0.14.1...v0.15.0))
|
|
2
26
|
=======
|
|
3
27
|
|
|
@@ -8,7 +32,7 @@
|
|
|
8
32
|
## Bugfixes
|
|
9
33
|
|
|
10
34
|
* 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
|
|
35
|
+
* Fix relevant lines for unloaded files - comments, skipped code etc. are correctly classified as irrelevant. See [#605](https://github.com/colszowka/simplecov/pull/605) (thanks @odlp)
|
|
12
36
|
* Allow using simplecov with frozen-string-literals enabled. See [#590](https://github.com/colszowka/simplecov/pull/590) (thanks @pat)
|
|
13
37
|
* Make sure Array Filter can use all other filter types. See [#589](https://github.com/colszowka/simplecov/pull/589) (thanks @jsteel)
|
|
14
38
|
* 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)
|
|
@@ -271,7 +295,7 @@ has been added.
|
|
|
271
295
|
* Average hits per line for groups of files is now computed correctly.
|
|
272
296
|
See [#192](http://github.com/colszowka/simplecov/pull/192) and
|
|
273
297
|
[#179](http://github.com/colszowka/simplecov/issues/179) (thanks to @graysonwright)
|
|
274
|
-
*
|
|
298
|
+
* Compatibility with BINARY internal encoding.
|
|
275
299
|
See [#194](https://github.com/colszowka/simplecov/pull/194) and
|
|
276
300
|
[#127](https://github.com/colszowka/simplecov/issues/127) (thanks to @justfalter)
|
|
277
301
|
* Special characters in `SimpleCov.root` are now correctly escaped before being used as a RegExp.
|
data/CONTRIBUTING.md
CHANGED
|
@@ -2,19 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
You can report issues at https://github.com/colszowka/simplecov/issues
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Before you go ahead please search existing issues for your problem, chances are someone else already reported it.
|
|
6
6
|
|
|
7
|
+
To make sure that we can help you quickly please include and check the following information:
|
|
8
|
+
|
|
9
|
+
* Include how you run your tests and which testing framework or frameworks you are running.
|
|
10
|
+
- please ensure you are requiring and starting SimpleCov before requiring any application code.
|
|
11
|
+
- If running via rake, please ensure you are requiring SimpleCov at the top of your Rakefile
|
|
12
|
+
For example, if running via RSpec, this would be at the top of your spec_helper.
|
|
13
|
+
- Have you tried using a [`.simplecov` file](https://github.com/colszowka/simplecov#using-simplecov-for-centralized-config)?
|
|
7
14
|
* Include the SimpleCov version you are running in your report.
|
|
8
15
|
* If you are not running the latest version (please check), and you cannot update it,
|
|
9
16
|
please specify in your report why you can't update to the latest version.
|
|
10
17
|
* Include your `ruby -e "puts RUBY_DESCRIPTION"`.
|
|
11
18
|
* Please also specify the gem versions of Rails (if applicable).
|
|
12
19
|
* Include any other coverage gems you may be using and their versions.
|
|
13
|
-
* Include how you run your tests and which testing framework or frameworks you are running.
|
|
14
|
-
- If running via rake, please ensure you are requiring SimpleCov at the top of your Rakefile
|
|
15
|
-
- Otherwise, please ensure you are requiring and starting SimpleCov before requiring any application code.
|
|
16
|
-
For example, if running via RSpec, this would be at the top of your spec_helper.
|
|
17
|
-
- Have you tried using a [`.simplecov` file](https://github.com/colszowka/simplecov#using-simplecov-for-centralized-config)?
|
|
18
20
|
|
|
19
21
|
Include as much sample code as you can to help us reproduce the issue. (Inline, repo link, or gist, are fine. A failing test would help the most.)
|
|
20
22
|
|
|
@@ -37,12 +39,13 @@ If you want to contribute, please:
|
|
|
37
39
|
* Make your feature addition or bug fix.
|
|
38
40
|
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
|
39
41
|
* **Bonus Points** go out to anyone who also updates `CHANGELOG.md` :)
|
|
40
|
-
* Send me a pull request on
|
|
42
|
+
* Send me a pull request on GitHub.
|
|
41
43
|
|
|
42
44
|
## Running Individual Tests
|
|
43
45
|
|
|
44
|
-
This project uses
|
|
46
|
+
This project uses RSpec and Cucumber. Individual tests can be run like this:
|
|
45
47
|
|
|
46
48
|
```bash
|
|
47
|
-
|
|
49
|
+
bundle exec rspec path/to/test.rb
|
|
50
|
+
bundle exec cucumber path/to/test.feature
|
|
48
51
|
```
|
data/ISSUE_TEMPLATE.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Howdy! Thanks for reporting an issue <3
|
|
2
|
+
|
|
3
|
+
Before you go ahead please search existing issues for your problem, chances are someone else already reported it.
|
|
4
|
+
|
|
5
|
+
To make sure that we can help you quickly please include and check the following information:
|
|
6
|
+
|
|
7
|
+
* Include how you run your tests and which testing framework or frameworks you are running.
|
|
8
|
+
- please ensure you are requiring and starting SimpleCov before requiring any application code.
|
|
9
|
+
- If running via rake, please ensure you are requiring SimpleCov at the top of your Rakefile
|
|
10
|
+
For example, if running via RSpec, this would be at the top of your spec_helper.
|
|
11
|
+
- Have you tried using a [`.simplecov` file](https://github.com/colszowka/simplecov#using-simplecov-for-centralized-config)?
|
|
12
|
+
* Include the SimpleCov version you are running in your report.
|
|
13
|
+
* If you are not running the latest version (please check), and you cannot update it,
|
|
14
|
+
please specify in your report why you can't update to the latest version.
|
|
15
|
+
* Include your `ruby -e "puts RUBY_DESCRIPTION"`.
|
|
16
|
+
* Please also specify the gem versions of Rails (if applicable).
|
|
17
|
+
* Include any other coverage gems you may be using and their versions.
|
|
18
|
+
|
|
19
|
+
Include as much sample code as you can to help us reproduce the issue. (Inline, repo link, or gist, are fine. A failing test would help the most.)
|
|
20
|
+
|
|
21
|
+
This is extremely important for narrowing down the cause of your problem.
|
|
22
|
+
|
|
23
|
+
Thanks!
|
data/README.md
CHANGED
|
@@ -28,7 +28,7 @@ etc. SimpleCov automatically takes care of this by caching and merging results w
|
|
|
28
28
|
report actually includes coverage across your test suites and thereby gives you a better picture of blank spots.
|
|
29
29
|
|
|
30
30
|
The official formatter of SimpleCov is packaged as a separate gem called [simplecov-html], but will be installed and configured
|
|
31
|
-
automatically when you launch SimpleCov. If you're curious, you can find it [on
|
|
31
|
+
automatically when you launch SimpleCov. If you're curious, you can find it [on GitHub, too][simplecov-html].
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
## Contact
|
|
@@ -47,10 +47,10 @@ Getting started
|
|
|
47
47
|
1. Add SimpleCov to your `Gemfile` and `bundle install`:
|
|
48
48
|
|
|
49
49
|
```ruby
|
|
50
|
-
gem 'simplecov', :
|
|
50
|
+
gem 'simplecov', require: false, group: :test
|
|
51
51
|
```
|
|
52
52
|
2. Load and launch SimpleCov **at the very top** of your `test/test_helper.rb`
|
|
53
|
-
(*or `spec_helper.rb`, cucumber `env.rb`, or whatever your preferred test
|
|
53
|
+
(*or `spec_helper.rb`, `rails_helper`, cucumber `env.rb`, or whatever your preferred test
|
|
54
54
|
framework uses*):
|
|
55
55
|
|
|
56
56
|
```ruby
|
|
@@ -246,7 +246,7 @@ If you use SimpleCov to merge multiple test suite results (e.g. Test/Unit and Cu
|
|
|
246
246
|
set up all your config options twice, once in `test_helper.rb` and once in `env.rb`.
|
|
247
247
|
|
|
248
248
|
To avoid this, you can place a file called `.simplecov` in your project root. You can then just leave the `require 'simplecov'` in each
|
|
249
|
-
test setup helper and move the `SimpleCov.start` code with all your custom config options into `.simplecov`:
|
|
249
|
+
test setup helper (**at the top**) and move the `SimpleCov.start` code with all your custom config options into `.simplecov`:
|
|
250
250
|
|
|
251
251
|
```ruby
|
|
252
252
|
# test/test_helper.rb
|
|
@@ -260,6 +260,7 @@ SimpleCov.start 'rails' do
|
|
|
260
260
|
# any custom configs like groups and filters can be here at a central place
|
|
261
261
|
end
|
|
262
262
|
```
|
|
263
|
+
|
|
263
264
|
Using `.simplecov` rather than separately requiring SimpleCov multiple times is recommended if you are merging multiple test frameworks like Cucumber and RSpec that rely on each other, as invoking SimpleCov multiple times can cause coverage information to be lost.
|
|
264
265
|
|
|
265
266
|
## Filters
|
|
@@ -349,8 +350,7 @@ end
|
|
|
349
350
|
# :nocov:
|
|
350
351
|
```
|
|
351
352
|
|
|
352
|
-
The name of the token can be changed to your liking. [Learn more about the nocov feature.]
|
|
353
|
-
[nocov]: https://github.com/colszowka/simplecov/blob/master/features/config_nocov_token.feature
|
|
353
|
+
The name of the token can be changed to your liking. [Learn more about the nocov feature.]( https://github.com/colszowka/simplecov/blob/master/features/config_nocov_token.feature)
|
|
354
354
|
|
|
355
355
|
**Note:** You shouldn't have to use the nocov token to skip private methods that are being included in your coverage. If you appropriately test the public interface of your classes and objects you should automatically get full coverage of your private methods.
|
|
356
356
|
|
|
@@ -620,7 +620,7 @@ Only Ruby 1.9+ ships with the coverage library that SimpleCov depends upon and t
|
|
|
620
620
|
SimpleCov is also built against Ruby 1.8 in [Continuous Integration], but this happens only to ensure that SimpleCov
|
|
621
621
|
does not make your test suite crash right now.
|
|
622
622
|
|
|
623
|
-
SimpleCov is built in [Continuous Integration] on Ruby 1.9.3, 2.0.0, 2.1, 2.2, 2.3, 2.4 as well as JRuby 9.1.
|
|
623
|
+
SimpleCov is built in [Continuous Integration] on Ruby 1.9.3, 2.0.0, 2.1, 2.2, 2.3, 2.4, 2.5 as well as JRuby 9.1.
|
|
624
624
|
|
|
625
625
|
## Want to find dead code in production?
|
|
626
626
|
|
|
@@ -633,14 +633,8 @@ If you're using [Spring](https://github.com/rails/spring) to speed up test suite
|
|
|
633
633
|
1. Change the following settings in `test.rb`.
|
|
634
634
|
|
|
635
635
|
```ruby
|
|
636
|
-
# For Rails
|
|
637
|
-
#
|
|
638
|
-
config.serve_static_files = false
|
|
639
|
-
config.eager_load = false
|
|
640
|
-
|
|
641
|
-
# For Rails 5, use the following configuration:
|
|
642
|
-
# Disable Rails's static asset server (Apache or nginx will already do this)
|
|
643
|
-
config.public_file_server.enabled = false
|
|
636
|
+
# For Rails
|
|
637
|
+
# Do not eager load code on boot
|
|
644
638
|
config.eager_load = false
|
|
645
639
|
```
|
|
646
640
|
2. Add your SimpleCov config, as you normally would, to your `spec_helper.rb`
|
|
@@ -656,7 +650,7 @@ If you're using [Spring](https://github.com/rails/spring) to speed up test suite
|
|
|
656
650
|
```
|
|
657
651
|
3. Run `spring rspec <path>` as normal. Remember to run `spring stop` after
|
|
658
652
|
making important changes to your app or its specs!
|
|
659
|
-
|
|
653
|
+
|
|
660
654
|
## Want to use bootsnap with SimpleCov?
|
|
661
655
|
|
|
662
656
|
As mentioned in [this issue](https://github.com/Shopify/bootsnap/issues/35) iseq
|
|
@@ -671,6 +665,38 @@ Bootsnap.setup(
|
|
|
671
665
|
)
|
|
672
666
|
```
|
|
673
667
|
|
|
668
|
+
## Troubleshooting
|
|
669
|
+
|
|
670
|
+
The **most common problem is that simplecov isn't required and started before everything else**. In order to track coverage for your whole application **simplecov needs to be the first one** so that it (and the underlying coverage library) can subsequently track loaded files and their usage.
|
|
671
|
+
|
|
672
|
+
If you are missing coverage for some code a simple trick is to put a puts statement in there and right after `SimpleCov.start` so you can see if the file really was loaded after simplecov was started.
|
|
673
|
+
|
|
674
|
+
```ruby
|
|
675
|
+
# my_code.rb
|
|
676
|
+
class MyCode
|
|
677
|
+
|
|
678
|
+
puts "MyCode is being loaded!"
|
|
679
|
+
|
|
680
|
+
def my_method
|
|
681
|
+
# ...
|
|
682
|
+
end
|
|
683
|
+
end
|
|
684
|
+
|
|
685
|
+
# spec_helper.rb/rails_helper.rb/test_helper.rb/.simplecov whatever
|
|
686
|
+
|
|
687
|
+
SimpleCov.start
|
|
688
|
+
puts "SimpleCov started successfully!"
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
Now when you run your test suite and you see:
|
|
692
|
+
|
|
693
|
+
```
|
|
694
|
+
SimpleCov started successfully!
|
|
695
|
+
MyCode is being loaded!
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
then it's good otherwise you likely have a problem :)
|
|
699
|
+
|
|
674
700
|
## Contributing
|
|
675
701
|
|
|
676
702
|
See the [contributing guide](https://github.com/colszowka/simplecov/blob/master/CONTRIBUTING.md).
|
data/doc/alternate-formatters.md
CHANGED
|
@@ -20,11 +20,21 @@ A formatter that generates Cobertura XML.
|
|
|
20
20
|
|
|
21
21
|
CSV formatter for SimpleCov
|
|
22
22
|
|
|
23
|
+
#### [simplecov-erb](https://github.com/kpaulisse/simplecov-erb)
|
|
24
|
+
*by [Kevin Paulisse](https://github.com/kpaulisse)*
|
|
25
|
+
|
|
26
|
+
Flexible formatter that generates the output from an ERB template.
|
|
27
|
+
|
|
23
28
|
#### [simplecov-json](https://github.com/vicentllongo/simplecov-json)
|
|
24
29
|
*by Vicent Llongo*
|
|
25
30
|
|
|
26
31
|
JSON formatter for SimpleCov
|
|
27
32
|
|
|
33
|
+
#### [simplecov-lcov](https://github.com/fortissimo1997/simplecov-lcov)
|
|
34
|
+
*by fortissimo1997*
|
|
35
|
+
|
|
36
|
+
lcov formatter for SimpleCov
|
|
37
|
+
|
|
28
38
|
#### [simplecov-rcov](https://github.com/fguillen/simplecov-rcov)
|
|
29
39
|
*by Fernando Guillen*
|
|
30
40
|
|
|
@@ -33,4 +43,9 @@ JSON formatter for SimpleCov
|
|
|
33
43
|
#### [simplecov-single_file_reporter](https://github.com/grosser/simplecov-single_file_reporter)
|
|
34
44
|
*by [Michael Grosser](http://grosser.it)*
|
|
35
45
|
|
|
36
|
-
A formatter that prints the coverage of the file under test when you run a single test file.
|
|
46
|
+
A formatter that prints the coverage of the file under test when you run a single test file.
|
|
47
|
+
|
|
48
|
+
#### [simplecov-t_wada](https://github.com/ysksn/simplecov-t_wada)
|
|
49
|
+
*by [Yosuke Kabuto](https://github.com/ysksn)*
|
|
50
|
+
|
|
51
|
+
t_wada AA formatter for SimpleCov
|
data/lib/simplecov/defaults.rb
CHANGED
|
@@ -1,43 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# Load default formatter gem
|
|
2
4
|
require "simplecov-html"
|
|
3
5
|
require "pathname"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
add_filter do |src|
|
|
9
|
-
root_filter ||= /\A#{Regexp.escape(SimpleCov.root)}/io
|
|
10
|
-
src.filename !~ root_filter
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
SimpleCov.profiles.define "test_frameworks" do
|
|
15
|
-
add_filter "/test/"
|
|
16
|
-
add_filter "/features/"
|
|
17
|
-
add_filter "/spec/"
|
|
18
|
-
add_filter "/autotest/"
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
SimpleCov.profiles.define "bundler_filter" do
|
|
22
|
-
add_filter "/vendor/bundle/"
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
SimpleCov.profiles.define "rails" do
|
|
26
|
-
load_profile "test_frameworks"
|
|
27
|
-
|
|
28
|
-
add_filter %r{^/config/}
|
|
29
|
-
add_filter %r{/^/db/}
|
|
30
|
-
|
|
31
|
-
add_group "Controllers", "app/controllers"
|
|
32
|
-
add_group "Channels", "app/channels" if defined?(ActionCable)
|
|
33
|
-
add_group "Models", "app/models"
|
|
34
|
-
add_group "Mailers", "app/mailers"
|
|
35
|
-
add_group "Helpers", "app/helpers"
|
|
36
|
-
add_group "Jobs", %w[app/jobs app/workers]
|
|
37
|
-
add_group "Libraries", "lib"
|
|
38
|
-
|
|
39
|
-
track_files "{app,lib}/**/*.rb"
|
|
40
|
-
end
|
|
6
|
+
require "simplecov/profiles/root_filter"
|
|
7
|
+
require "simplecov/profiles/test_frameworks"
|
|
8
|
+
require "simplecov/profiles/bundler_filter"
|
|
9
|
+
require "simplecov/profiles/rails"
|
|
41
10
|
|
|
42
11
|
# Default configuration
|
|
43
12
|
SimpleCov.configure do
|
|
@@ -50,52 +19,12 @@ end
|
|
|
50
19
|
# Gotta stash this a-s-a-p, see the CommandGuesser class and i.e. #110 for further info
|
|
51
20
|
SimpleCov::CommandGuesser.original_run_command = "#{$PROGRAM_NAME} #{ARGV.join(' ')}"
|
|
52
21
|
|
|
53
|
-
at_exit do
|
|
22
|
+
at_exit do
|
|
54
23
|
# If we are in a different process than called start, don't interfere.
|
|
55
24
|
next if SimpleCov.pid != Process.pid
|
|
56
25
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
# otherwise set a non-zero status representing termination by
|
|
60
|
-
# some other exception (see github issue 41)
|
|
61
|
-
$!.is_a?(SystemExit) ? $!.status : SimpleCov::ExitCodes::EXCEPTION
|
|
62
|
-
else
|
|
63
|
-
# Store the exit status of the test run since it goes away
|
|
64
|
-
# after calling the at_exit proc...
|
|
65
|
-
SimpleCov::ExitCodes::SUCCESS
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
SimpleCov.at_exit.call
|
|
69
|
-
|
|
70
|
-
if SimpleCov.result? # Result has been computed
|
|
71
|
-
covered_percent = SimpleCov.result.covered_percent.round(2)
|
|
72
|
-
covered_percentages = SimpleCov.result.covered_percentages.map { |p| p.round(2) }
|
|
73
|
-
|
|
74
|
-
if @exit_status == SimpleCov::ExitCodes::SUCCESS # No other errors
|
|
75
|
-
if covered_percent < SimpleCov.minimum_coverage # rubocop:disable Metrics/BlockNesting
|
|
76
|
-
$stderr.printf("Coverage (%.2f%%) is below the expected minimum coverage (%.2f%%).\n", covered_percent, SimpleCov.minimum_coverage)
|
|
77
|
-
@exit_status = SimpleCov::ExitCodes::MINIMUM_COVERAGE
|
|
78
|
-
elsif covered_percentages.any? { |p| p < SimpleCov.minimum_coverage_by_file } # rubocop:disable Metrics/BlockNesting
|
|
79
|
-
$stderr.printf("File (%s) is only (%.2f%%) covered. This is below the expected minimum coverage per file of (%.2f%%).\n", SimpleCov.result.least_covered_file, covered_percentages.min, SimpleCov.minimum_coverage_by_file)
|
|
80
|
-
@exit_status = SimpleCov::ExitCodes::MINIMUM_COVERAGE
|
|
81
|
-
elsif (last_run = SimpleCov::LastRun.read) # rubocop:disable Metrics/BlockNesting
|
|
82
|
-
coverage_diff = last_run["result"]["covered_percent"] - covered_percent
|
|
83
|
-
if coverage_diff > SimpleCov.maximum_coverage_drop # rubocop:disable Metrics/BlockNesting
|
|
84
|
-
$stderr.printf("Coverage has dropped by %.2f%% since the last time (maximum allowed: %.2f%%).\n", coverage_diff, SimpleCov.maximum_coverage_drop)
|
|
85
|
-
@exit_status = SimpleCov::ExitCodes::MAXIMUM_COVERAGE_DROP
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
# Don't overwrite last_run file if refuse_coverage_drop option is enabled and the coverage has dropped
|
|
91
|
-
unless @exit_status == SimpleCov::ExitCodes::MAXIMUM_COVERAGE_DROP
|
|
92
|
-
SimpleCov::LastRun.write(:result => {:covered_percent => covered_percent})
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
# Force exit with stored status (see github issue #5)
|
|
97
|
-
# unless it's nil or 0 (see github issue #281)
|
|
98
|
-
Kernel.exit @exit_status if @exit_status && @exit_status > 0
|
|
26
|
+
SimpleCov.set_exit_exception
|
|
27
|
+
SimpleCov.run_exit_tasks!
|
|
99
28
|
end
|
|
100
29
|
|
|
101
30
|
# Autoload config from ~/.simplecov if present
|
data/lib/simplecov/exit_codes.rb
CHANGED
data/lib/simplecov/file_list.rb
CHANGED
data/lib/simplecov/filter.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module SimpleCov
|
|
2
4
|
#
|
|
3
5
|
# Base filter class. Inherit from this to create custom filters,
|
|
@@ -49,7 +51,7 @@ module SimpleCov
|
|
|
49
51
|
# Returns true when the given source file's filename matches the
|
|
50
52
|
# string configured when initializing this Filter with StringFilter.new('somestring)
|
|
51
53
|
def matches?(source_file)
|
|
52
|
-
|
|
54
|
+
source_file.project_filename.include?(filter_argument)
|
|
53
55
|
end
|
|
54
56
|
end
|
|
55
57
|
|
data/lib/simplecov/formatter.rb
CHANGED
data/lib/simplecov/jruby_fix.rb
CHANGED
data/lib/simplecov/last_run.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module SimpleCov
|
|
2
4
|
# Classifies whether lines are relevant for code coverage analysis.
|
|
3
5
|
# Comments & whitespace lines, and :nocov: token blocks, are considered not relevant.
|
|
@@ -11,17 +13,31 @@ module SimpleCov
|
|
|
11
13
|
WHITESPACE_OR_COMMENT_LINE = Regexp.union(WHITESPACE_LINE, COMMENT_LINE)
|
|
12
14
|
|
|
13
15
|
def self.no_cov_line
|
|
14
|
-
/^(\s*)#(\s*)(\:#{SimpleCov.nocov_token}\:)/
|
|
16
|
+
/^(\s*)#(\s*)(\:#{SimpleCov.nocov_token}\:)/o
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.no_cov_line?(line)
|
|
20
|
+
line =~ no_cov_line
|
|
21
|
+
rescue ArgumentError
|
|
22
|
+
# E.g., line contains an invalid byte sequence in UTF-8
|
|
23
|
+
false
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.whitespace_line?(line)
|
|
27
|
+
line =~ WHITESPACE_OR_COMMENT_LINE
|
|
28
|
+
rescue ArgumentError
|
|
29
|
+
# E.g., line contains an invalid byte sequence in UTF-8
|
|
30
|
+
false
|
|
15
31
|
end
|
|
16
32
|
|
|
17
33
|
def classify(lines)
|
|
18
34
|
skipping = false
|
|
19
35
|
|
|
20
36
|
lines.map do |line|
|
|
21
|
-
if
|
|
37
|
+
if self.class.no_cov_line?(line)
|
|
22
38
|
skipping = !skipping
|
|
23
39
|
NOT_RELEVANT
|
|
24
|
-
elsif skipping || line
|
|
40
|
+
elsif skipping || self.class.whitespace_line?(line)
|
|
25
41
|
NOT_RELEVANT
|
|
26
42
|
else
|
|
27
43
|
RELEVANT
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
SimpleCov.profiles.define "rails" do
|
|
4
|
+
load_profile "test_frameworks"
|
|
5
|
+
|
|
6
|
+
add_filter %r{^/config/}
|
|
7
|
+
add_filter %r{^/db/}
|
|
8
|
+
|
|
9
|
+
add_group "Controllers", "app/controllers"
|
|
10
|
+
add_group "Channels", "app/channels" if defined?(ActionCable)
|
|
11
|
+
add_group "Models", "app/models"
|
|
12
|
+
add_group "Mailers", "app/mailers"
|
|
13
|
+
add_group "Helpers", "app/helpers"
|
|
14
|
+
add_group "Jobs", %w[app/jobs app/workers]
|
|
15
|
+
add_group "Libraries", "lib/"
|
|
16
|
+
|
|
17
|
+
track_files "{app,lib}/**/*.rb"
|
|
18
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
SimpleCov.profiles.define "root_filter" do
|
|
4
|
+
# Exclude all files outside of simplecov root
|
|
5
|
+
root_filter = nil
|
|
6
|
+
add_filter do |src|
|
|
7
|
+
root_filter ||= /\A#{Regexp.escape(SimpleCov.root + File::SEPARATOR)}/io
|
|
8
|
+
src.filename !~ root_filter
|
|
9
|
+
end
|
|
10
|
+
end
|
data/lib/simplecov/profiles.rb
CHANGED
data/lib/simplecov/railtie.rb
CHANGED
data/lib/simplecov/result.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module SimpleCov
|
|
2
4
|
#
|
|
3
5
|
# Representation of a source file including it's coverage data, source code,
|
|
@@ -180,7 +182,7 @@ module SimpleCov
|
|
|
180
182
|
skipping = false
|
|
181
183
|
|
|
182
184
|
lines.each do |line|
|
|
183
|
-
if
|
|
185
|
+
if SimpleCov::LinesClassifier.no_cov_line?(line.src)
|
|
184
186
|
skipping = !skipping
|
|
185
187
|
line.skipped!
|
|
186
188
|
elsif skipping
|
data/lib/simplecov/version.rb
CHANGED