simplecov 0.9.2 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/.gitignore +0 -1
- data/.rubocop.yml +69 -0
- data/CHANGELOG.md +39 -22
- data/Gemfile +16 -15
- data/MIT-LICENSE +1 -1
- data/README.md +183 -178
- data/Rakefile +16 -7
- data/doc/alternate-formatters.md +36 -0
- data/doc/commercial-services.md +20 -0
- data/doc/editor-integration.md +13 -0
- data/features/rspec_basic.feature +3 -2
- data/features/rspec_groups_and_filters_complex.feature +2 -0
- data/features/rspec_groups_using_filter_class.feature +3 -2
- data/features/step_definitions/html_steps.rb +6 -7
- data/features/step_definitions/simplecov_steps.rb +18 -16
- data/features/step_definitions/transformers.rb +2 -2
- data/features/step_definitions/web_steps.rb +4 -4
- data/features/support/env.rb +17 -15
- data/lib/simplecov.rb +35 -24
- data/lib/simplecov/command_guesser.rb +33 -34
- data/lib/simplecov/configuration.rb +238 -234
- data/lib/simplecov/defaults.rb +37 -36
- data/lib/simplecov/exit_codes.rb +7 -5
- data/lib/simplecov/file_list.rb +38 -36
- data/lib/simplecov/filter.rb +12 -2
- data/lib/simplecov/formatter.rb +2 -2
- data/lib/simplecov/formatter/simple_formatter.rb +1 -1
- data/lib/simplecov/jruby_fix.rb +4 -4
- data/lib/simplecov/last_run.rb +15 -13
- data/lib/simplecov/merge_helpers.rb +26 -27
- data/lib/simplecov/no_defaults.rb +2 -2
- data/lib/simplecov/profiles.rb +21 -19
- data/lib/simplecov/railtie.rb +1 -1
- data/lib/simplecov/railties/tasks.rake +7 -7
- data/lib/simplecov/result.rb +5 -5
- data/lib/simplecov/result_merger.rb +65 -62
- data/lib/simplecov/source_file.rb +23 -24
- data/lib/simplecov/version.rb +20 -1
- data/simplecov.gemspec +14 -12
- data/test/faked_project/Gemfile +5 -5
- data/test/faked_project/Rakefile +4 -4
- data/test/faked_project/features/step_definitions/my_steps.rb +3 -4
- data/test/faked_project/features/support/env.rb +5 -5
- data/test/faked_project/lib/faked_project.rb +1 -1
- data/test/faked_project/lib/faked_project/some_class.rb +3 -4
- data/test/faked_project/spec/faked_spec.rb +2 -2
- data/test/faked_project/spec/forking_spec.rb +7 -0
- data/test/faked_project/spec/meta_magic_spec.rb +1 -1
- data/test/faked_project/spec/some_class_spec.rb +3 -3
- data/test/faked_project/spec/spec_helper.rb +4 -8
- data/test/faked_project/test/faked_test.rb +2 -2
- data/test/faked_project/test/meta_magic_test.rb +1 -1
- data/test/faked_project/test/some_class_test.rb +3 -3
- data/test/faked_project/test/test_helper.rb +5 -9
- data/test/fixtures/app/controllers/sample_controller.rb +1 -1
- data/test/fixtures/app/models/user.rb +1 -1
- data/test/fixtures/deleted_source_sample.rb +3 -3
- data/test/fixtures/frameworks/rspec_bad.rb +4 -4
- data/test/fixtures/frameworks/rspec_good.rb +4 -4
- data/test/fixtures/frameworks/testunit_bad.rb +3 -3
- data/test/fixtures/frameworks/testunit_good.rb +3 -3
- data/test/fixtures/resultset2.rb +0 -1
- data/test/fixtures/sample.rb +1 -1
- data/test/fixtures/utf-8.rb +1 -1
- data/test/helper.rb +8 -8
- data/test/test_1_8_fallbacks.rb +6 -6
- data/test/test_command_guesser.rb +7 -7
- data/test/test_deleted_source.rb +2 -2
- data/test/test_file_list.rb +8 -6
- data/test/test_filters.rb +29 -13
- data/test/test_merge_helpers.rb +26 -23
- data/test/test_result.rb +32 -23
- data/test/test_return_codes.rb +3 -3
- data/test/test_source_file.rb +4 -4
- data/test/test_source_file_line.rb +13 -13
- metadata +145 -63
- data/lib/simplecov/json.rb +0 -27
data/Rakefile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "rubygems"
|
4
|
+
require "bundler/setup"
|
5
5
|
Bundler::GemHelper.install_tasks
|
6
6
|
|
7
7
|
# See https://github.com/colszowka/simplecov/issues/171
|
@@ -12,19 +12,28 @@ end
|
|
12
12
|
# Enforce proper permissions on each build
|
13
13
|
Rake::Task[:build].prerequisites.unshift :fix_permissions
|
14
14
|
|
15
|
-
require
|
15
|
+
require "rake/testtask"
|
16
16
|
Rake::TestTask.new(:test) do |test|
|
17
|
-
test.libs <<
|
18
|
-
test.test_files = FileList[
|
17
|
+
test.libs << "lib" << "test"
|
18
|
+
test.test_files = FileList["test/test_*.rb"]
|
19
19
|
test.verbose = true
|
20
20
|
test.warning = true
|
21
21
|
end
|
22
22
|
|
23
|
+
begin
|
24
|
+
require "rubocop/rake_task"
|
25
|
+
RuboCop::RakeTask.new
|
26
|
+
rescue LoadError
|
27
|
+
task :rubocop do
|
28
|
+
$stderr.puts "Rubocop is disabled"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
23
32
|
# Cucumber integration test suite is for impls that work with simplecov only - a.k.a. 1.9+
|
24
33
|
if RUBY_VERSION >= "1.9"
|
25
|
-
require
|
34
|
+
require "cucumber/rake/task"
|
26
35
|
Cucumber::Rake::Task.new
|
27
|
-
task :default => [:test, :cucumber]
|
36
|
+
task :default => [:test, :cucumber, :rubocop]
|
28
37
|
else
|
29
38
|
task :default => [:test]
|
30
39
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
## Alternate coverage report formatters
|
2
|
+
|
3
|
+
The community around simplecov provides a whole bunch of alternate formatters beyond the official
|
4
|
+
[simplecov-html](https://github.com/colszowka/simplecov-html) gem.
|
5
|
+
|
6
|
+
If you have built or found one that is missing here, please send a Pull Request for this document!
|
7
|
+
|
8
|
+
#### [simplecov-badge](https://github.com/matthew342/simplecov-badge)
|
9
|
+
*by Matt Hale*
|
10
|
+
|
11
|
+
A formatter that generates a coverage badge for use in your project's readme using ImageMagick.
|
12
|
+
|
13
|
+
#### [simplecov-cobertura](https://github.com/dashingrocket/simplecov-cobertura)
|
14
|
+
*by Jesse Bowes*
|
15
|
+
|
16
|
+
A formatter that generates Cobertura XML.
|
17
|
+
|
18
|
+
#### [simplecov-csv](https://github.com/fguillen/simplecov-csv)
|
19
|
+
*by Fernando Guillen*
|
20
|
+
|
21
|
+
CSV formatter for SimpleCov
|
22
|
+
|
23
|
+
#### [simplecov-json](https://github.com/vicentllongo/simplecov-json)
|
24
|
+
*by Vicent Llongo*
|
25
|
+
|
26
|
+
JSON formatter for SimpleCov
|
27
|
+
|
28
|
+
#### [simplecov-rcov](https://github.com/fguillen/simplecov-rcov)
|
29
|
+
*by Fernando Guillen*
|
30
|
+
|
31
|
+
"The target of this formatter is to cheat on Hudson so I can use the Ruby metrics plugin with SimpleCov."
|
32
|
+
|
33
|
+
#### [simplecov-single_file_reporter](https://github.com/grosser/simplecov-single_file_reporter)
|
34
|
+
*by [Michael Grosser](http://grosser.it)*
|
35
|
+
|
36
|
+
A formatter that prints the coverage of the file under test when you run a single test file.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
## Commercial Services with SimpleCov integration
|
2
|
+
|
3
|
+
There is a bunch of services that offer integration with your existing CI pipeline and SimpleCov coverage
|
4
|
+
reports. Please note these are not associated with the SimpleCov project itself, so please report problems with
|
5
|
+
these integrations with their respective owners.
|
6
|
+
|
7
|
+
#### [codeclimate](https://github.com/codeclimate/ruby-test-reporter)
|
8
|
+
*by [Code Climate](https://codeclimate.com/)*
|
9
|
+
|
10
|
+
Upload coverage reports to [codeclimate.com](https://codeclimate.com/), a hosted software quality analysis and that also includes coverage reporting.
|
11
|
+
|
12
|
+
#### [codecov](https://github.com/codecov/codecov-ruby)
|
13
|
+
*by [Codecov](https://codecov.io/)*
|
14
|
+
|
15
|
+
Upload coverage reports to [codecov.io](https://codecov.io/), a hosted coverage reporting solution.
|
16
|
+
|
17
|
+
#### [coveralls](https://github.com/lemurheavy/coveralls-ruby)
|
18
|
+
*by [Coveralls](https://coveralls.io/)*
|
19
|
+
|
20
|
+
Upload coverage reports to [coveralls.io](https://coveralls.io/), a hosted coverage reporting solution.
|
@@ -0,0 +1,13 @@
|
|
1
|
+
## Editor integration
|
2
|
+
|
3
|
+
Some editors have a graphical integration for the simplecov gem.
|
4
|
+
|
5
|
+
#### [Atom Editor: coverage](https://atom.io/packages/coverage)
|
6
|
+
*by Philip Giuliani*
|
7
|
+
|
8
|
+
Adds an overview of your current test coverage to Atom.
|
9
|
+
|
10
|
+
#### [cadre](https://github.com/nyarly/cadre)
|
11
|
+
*by Judson Lester*
|
12
|
+
|
13
|
+
Includes a formatter for Simplecov that emits a Vim script to mark up code files with coverage information.
|
@@ -14,14 +14,15 @@ Feature:
|
|
14
14
|
When I open the coverage report generated with `bundle exec rspec spec`
|
15
15
|
Then I should see the groups:
|
16
16
|
| name | coverage | files |
|
17
|
-
| All Files | 91.
|
17
|
+
| All Files | 91.8% | 7 |
|
18
18
|
|
19
19
|
And I should see the source files:
|
20
20
|
| name | coverage |
|
21
21
|
| lib/faked_project.rb | 100.0 % |
|
22
|
-
| lib/faked_project/some_class.rb | 80.0 %
|
22
|
+
| lib/faked_project/some_class.rb | 80.0 % |
|
23
23
|
| lib/faked_project/framework_specific.rb | 75.0 % |
|
24
24
|
| lib/faked_project/meta_magic.rb | 100.0 % |
|
25
|
+
| spec/forking_spec.rb | 100.0 % |
|
25
26
|
| spec/meta_magic_spec.rb | 100.0 % |
|
26
27
|
| spec/some_class_spec.rb | 100.0 % |
|
27
28
|
|
@@ -15,6 +15,7 @@ Feature: Sophisticated grouping and filtering on RSpec
|
|
15
15
|
src_file.filename =~ /MaGiC/i
|
16
16
|
end
|
17
17
|
add_group 'By string', 'project/meta_magic'
|
18
|
+
add_group 'By array', ['project/meta_magic']
|
18
19
|
|
19
20
|
add_filter 'faked_project.rb'
|
20
21
|
# Remove all files that include "describe" in their source
|
@@ -29,6 +30,7 @@ Feature: Sophisticated grouping and filtering on RSpec
|
|
29
30
|
| All Files | 100.0% | 1 |
|
30
31
|
| By block | 100.0% | 1 |
|
31
32
|
| By string | 100.0% | 1 |
|
33
|
+
| By array | 100.0% | 1 |
|
32
34
|
|
33
35
|
And I should see the source files:
|
34
36
|
| name | coverage |
|
@@ -24,10 +24,10 @@ Feature: Grouping on RSpec using a custom filter class
|
|
24
24
|
When I open the coverage report generated with `bundle exec rspec spec`
|
25
25
|
Then I should see the groups:
|
26
26
|
| name | coverage | files |
|
27
|
-
| All Files | 91.
|
27
|
+
| All Files | 91.8% | 7 |
|
28
28
|
| By filter class | 78.26% | 2 |
|
29
29
|
| By string | 100.0% | 1 |
|
30
|
-
| Ungrouped | 100.0% |
|
30
|
+
| Ungrouped | 100.0% | 4 |
|
31
31
|
|
32
32
|
And I should see the source files:
|
33
33
|
| name | coverage |
|
@@ -35,6 +35,7 @@ Feature: Grouping on RSpec using a custom filter class
|
|
35
35
|
| lib/faked_project/some_class.rb | 80.0 % |
|
36
36
|
| lib/faked_project.rb | 100.0 % |
|
37
37
|
| lib/faked_project/meta_magic.rb | 100.0 % |
|
38
|
+
| spec/forking_spec.rb | 100.0 % |
|
38
39
|
| spec/meta_magic_spec.rb | 100.0 % |
|
39
40
|
| spec/some_class_spec.rb | 100.0 % |
|
40
41
|
|
@@ -1,15 +1,14 @@
|
|
1
1
|
module GroupHelpers
|
2
2
|
def available_groups
|
3
|
-
all(
|
3
|
+
all("#content .file_list_container")
|
4
4
|
end
|
5
5
|
|
6
6
|
def available_source_files
|
7
|
-
all(
|
7
|
+
all(".source_files .source_table")
|
8
8
|
end
|
9
9
|
end
|
10
10
|
World(GroupHelpers)
|
11
11
|
|
12
|
-
|
13
12
|
Then /^I should see the groups:$/ do |table|
|
14
13
|
expected_groups = table.hashes
|
15
14
|
# Given group names should be the same number than those rendered in report
|
@@ -18,8 +17,8 @@ Then /^I should see the groups:$/ do |table|
|
|
18
17
|
# Verify each of the expected groups has a file list container and corresponding title and coverage number
|
19
18
|
# as well as the correct number of links to files.
|
20
19
|
expected_groups.each do |group|
|
21
|
-
with_scope "#content ##{group[
|
22
|
-
file_count_in_group = page.all(
|
20
|
+
with_scope "#content ##{group['name'].gsub(/[^a-z]/i, '')}.file_list_container" do
|
21
|
+
file_count_in_group = page.all("a.src_link").count
|
23
22
|
expect(file_count_in_group).to eq(group["files"].to_i)
|
24
23
|
|
25
24
|
with_scope "h2" do
|
@@ -35,9 +34,9 @@ Then /^I should see the source files:$/ do |table|
|
|
35
34
|
expect(expected_files.length).to eq(available_source_files.count)
|
36
35
|
|
37
36
|
# Find all filenames and their coverage present in coverage report
|
38
|
-
files = available_source_files.map {|f| {"name" => f.find(
|
37
|
+
files = available_source_files.map { |f| {"name" => f.find("h3").text, "coverage" => f.find("h4 > span").text} }
|
39
38
|
|
40
|
-
expect(files.sort_by {|hsh| hsh["name"] }).to eq(expected_files.sort_by {|hsh| hsh["name"] })
|
39
|
+
expect(files.sort_by { |hsh| hsh["name"] }).to eq(expected_files.sort_by { |hsh| hsh["name"] })
|
41
40
|
end
|
42
41
|
|
43
42
|
Then /^there should be (\d+) skipped lines in the source files$/ do |expected_count|
|
@@ -2,7 +2,8 @@
|
|
2
2
|
# The test project is using separate config files to avoid specifying all of
|
3
3
|
# test/spec_helper in the features every time.
|
4
4
|
Given /^SimpleCov for (.*) is configured with:$/ do |framework, config_body|
|
5
|
-
framework_dir =
|
5
|
+
framework_dir = begin
|
6
|
+
case framework
|
6
7
|
when /RSpec/i
|
7
8
|
"spec"
|
8
9
|
when /Test\/Unit/i
|
@@ -10,53 +11,54 @@ Given /^SimpleCov for (.*) is configured with:$/ do |framework, config_body|
|
|
10
11
|
when /Cucumber/i
|
11
12
|
"features/support"
|
12
13
|
else
|
13
|
-
|
14
|
+
fail ArgumentError, "Could not identify test framework #{framework}!"
|
15
|
+
end
|
14
16
|
end
|
15
17
|
|
16
|
-
steps %
|
18
|
+
steps %(
|
17
19
|
Given a file named "#{framework_dir}/simplecov_config.rb" with:
|
18
20
|
"""
|
19
21
|
#{config_body}
|
20
22
|
"""
|
21
|
-
|
23
|
+
)
|
22
24
|
end
|
23
25
|
|
24
26
|
When /^I open the coverage report generated with `([^`]+)`$/ do |command|
|
25
|
-
steps %
|
27
|
+
steps %(
|
26
28
|
When I successfully run `#{command}`
|
27
29
|
Then a coverage report should have been generated
|
28
30
|
When I open the coverage report
|
29
|
-
|
31
|
+
)
|
30
32
|
end
|
31
33
|
|
32
34
|
Then /^a coverage report should have been generated(?: in "([^"]*)")?$/ do |coverage_dir|
|
33
|
-
coverage_dir ||=
|
34
|
-
steps %
|
35
|
+
coverage_dir ||= "coverage"
|
36
|
+
steps %(
|
35
37
|
Then the output should contain "Coverage report generated"
|
36
38
|
And a directory named "#{coverage_dir}" should exist
|
37
39
|
And the following files should exist:
|
38
40
|
| #{coverage_dir}/index.html |
|
39
41
|
| #{coverage_dir}/.resultset.json |
|
40
|
-
|
42
|
+
)
|
41
43
|
end
|
42
44
|
|
43
45
|
Then /^no coverage report should have been generated(?: in "([^"]*)")?$/ do |coverage_dir|
|
44
|
-
coverage_dir ||=
|
45
|
-
steps %
|
46
|
+
coverage_dir ||= "coverage"
|
47
|
+
steps %(
|
46
48
|
Then the output should not contain "Coverage report generated"
|
47
49
|
And a directory named "#{coverage_dir}" should not exist
|
48
50
|
And the following files should not exist:
|
49
51
|
| #{coverage_dir}/index.html |
|
50
52
|
| #{coverage_dir}/.resultset.json |
|
51
|
-
|
53
|
+
)
|
52
54
|
end
|
53
55
|
|
54
56
|
Then /^the report should be based upon:$/ do |table|
|
55
57
|
frameworks = table.raw.flatten
|
56
|
-
steps %
|
57
|
-
Then the output should contain "Coverage report generated for #{frameworks.join(
|
58
|
-
And I should see "using #{frameworks.join(
|
59
|
-
|
58
|
+
steps %(
|
59
|
+
Then the output should contain "Coverage report generated for #{frameworks.join(', ')}"
|
60
|
+
And I should see "using #{frameworks.join(', ')}" within "#footer"
|
61
|
+
)
|
60
62
|
end
|
61
63
|
|
62
64
|
# This is neccessary to ensure timing-dependant tests like the merge timeout
|
@@ -6,8 +6,8 @@
|
|
6
6
|
# This is due to the fact that coverage will not include the first loaded spec/test file.
|
7
7
|
# To get predictable coverage results, we need to know which one that is...
|
8
8
|
#
|
9
|
-
Transform "bundle exec rspec spec" do |
|
9
|
+
Transform "bundle exec rspec spec" do |_|
|
10
10
|
files = nil # Avoid shadowing
|
11
|
-
in_current_dir { files = Dir[
|
11
|
+
in_current_dir { files = Dir["spec/**/*_spec.rb"] }
|
12
12
|
"bundle exec rspec #{files.sort.join(' ')}"
|
13
13
|
end
|
@@ -6,7 +6,7 @@ end
|
|
6
6
|
World(WithinHelpers)
|
7
7
|
|
8
8
|
When /^I open the coverage report$/ do
|
9
|
-
visit
|
9
|
+
visit "/"
|
10
10
|
end
|
11
11
|
|
12
12
|
Given /^(?:|I )am on (.+)$/ do |path|
|
@@ -38,7 +38,7 @@ end
|
|
38
38
|
Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
|
39
39
|
regexp = Regexp.new(regexp)
|
40
40
|
with_scope(selector) do
|
41
|
-
expect(page).to have_xpath(
|
41
|
+
expect(page).to have_xpath("//*", :text => regexp)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -51,12 +51,12 @@ end
|
|
51
51
|
Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
|
52
52
|
regexp = Regexp.new(regexp)
|
53
53
|
with_scope(selector) do
|
54
|
-
expect(page).to have_no_xpath(
|
54
|
+
expect(page).to have_no_xpath("//*", :text => regexp)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
Then /^show me the page$/ do
|
59
|
-
save_and_open_page
|
59
|
+
save_and_open_page # rubocop:disable Lint/Debugger
|
60
60
|
end
|
61
61
|
|
62
62
|
Then /^print the page$/ do
|
data/features/support/env.rb
CHANGED
@@ -3,35 +3,37 @@ if RUBY_VERSION < "1.9"
|
|
3
3
|
exit 0
|
4
4
|
end
|
5
5
|
|
6
|
-
require
|
6
|
+
require "bundler"
|
7
7
|
Bundler.setup
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
8
|
+
require "aruba/cucumber"
|
9
|
+
require "aruba/jruby" if RUBY_ENGINE == "jruby"
|
10
|
+
require "capybara/cucumber"
|
11
|
+
require "minitest/autorun"
|
12
|
+
require "phantomjs/poltergeist"
|
13
13
|
|
14
14
|
# Fake rack app for capybara that just returns the latest coverage report from aruba temp project dir
|
15
15
|
Capybara.app = lambda { |env|
|
16
|
-
request_path = env[
|
17
|
-
request_path =
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
request_path = env["REQUEST_PATH"] || "/"
|
17
|
+
request_path = "/index.html" if request_path == "/"
|
18
|
+
[
|
19
|
+
200,
|
20
|
+
{"Content-Type" => "text/html"},
|
21
|
+
[File.read(File.join(File.dirname(__FILE__), "../../tmp/aruba/project/coverage", request_path))],
|
22
|
+
]
|
21
23
|
}
|
22
24
|
|
23
25
|
Capybara.default_driver = Capybara.javascript_driver = :poltergeist
|
24
26
|
|
25
27
|
Before do
|
26
28
|
# JRuby takes it's time... See https://github.com/cucumber/aruba/issues/134
|
27
|
-
@aruba_timeout_seconds = RUBY_ENGINE ==
|
29
|
+
@aruba_timeout_seconds = RUBY_ENGINE == "jruby" ? 60 : 20
|
28
30
|
|
29
31
|
this_dir = File.dirname(__FILE__)
|
30
32
|
|
31
33
|
# Clean up and create blank state for fake project
|
32
34
|
in_current_dir do
|
33
|
-
FileUtils.rm_rf
|
34
|
-
FileUtils.cp_r File.join(this_dir,
|
35
|
+
FileUtils.rm_rf "project"
|
36
|
+
FileUtils.cp_r File.join(this_dir, "../../test/faked_project/"), "project"
|
35
37
|
end
|
36
38
|
|
37
39
|
step 'I cd to "project"'
|
@@ -40,6 +42,6 @@ end
|
|
40
42
|
# Workaround for https://github.com/cucumber/aruba/pull/125
|
41
43
|
Aruba.configure do |config|
|
42
44
|
config.before_cmd do
|
43
|
-
set_env(
|
45
|
+
set_env("JRUBY_OPTS", "-X-C --1.9")
|
44
46
|
end
|
45
47
|
end
|
data/lib/simplecov.rb
CHANGED
@@ -1,9 +1,20 @@
|
|
1
1
|
#
|
2
2
|
# Code coverage for ruby 1.9. Please check out README for a full introduction.
|
3
3
|
#
|
4
|
+
# Coverage may be inaccurate under JRUBY.
|
5
|
+
if defined?(JRUBY_VERSION)
|
6
|
+
if ENV["JRUBY_OPTS"].to_s !~ /-Xcli.debug=true/
|
7
|
+
warn "Coverage may be inaccurate; Try setting JRUBY_OPTS=\"-Xcli.debug=true --debug\""
|
8
|
+
# see https://github.com/metricfu/metric_fu/pull/226
|
9
|
+
# https://github.com/jruby/jruby/issues/1196
|
10
|
+
# https://jira.codehaus.org/browse/JRUBY-6106
|
11
|
+
# https://github.com/colszowka/simplecov/issues/86
|
12
|
+
end
|
13
|
+
end
|
4
14
|
module SimpleCov
|
5
15
|
class << self
|
6
16
|
attr_accessor :running
|
17
|
+
attr_accessor :pid
|
7
18
|
|
8
19
|
#
|
9
20
|
# Sets up SimpleCov to run against your project.
|
@@ -22,12 +33,13 @@ module SimpleCov
|
|
22
33
|
#
|
23
34
|
# Please check out the RDoc for SimpleCov::Configuration to find about available config options
|
24
35
|
#
|
25
|
-
def start(profile=nil, &block)
|
36
|
+
def start(profile = nil, &block)
|
26
37
|
if SimpleCov.usable?
|
27
38
|
load_profile(profile) if profile
|
28
39
|
configure(&block) if block_given?
|
29
40
|
@result = nil
|
30
41
|
self.running = true
|
42
|
+
self.pid = Process.pid
|
31
43
|
Coverage.start
|
32
44
|
else
|
33
45
|
warn "WARNING: SimpleCov is activated, but you're not running Ruby 1.9+ - no coverage analysis will happen"
|
@@ -59,7 +71,7 @@ module SimpleCov
|
|
59
71
|
# Otherwise, returns the result
|
60
72
|
#
|
61
73
|
def result?
|
62
|
-
defined?
|
74
|
+
defined?(@result) && @result
|
63
75
|
end
|
64
76
|
|
65
77
|
#
|
@@ -68,7 +80,7 @@ module SimpleCov
|
|
68
80
|
def filtered(files)
|
69
81
|
result = files.clone
|
70
82
|
filters.each do |filter|
|
71
|
-
result = result.reject {|source_file| filter.matches?(source_file) }
|
83
|
+
result = result.reject { |source_file| filter.matches?(source_file) }
|
72
84
|
end
|
73
85
|
SimpleCov::FileList.new result
|
74
86
|
end
|
@@ -80,10 +92,10 @@ module SimpleCov
|
|
80
92
|
grouped = {}
|
81
93
|
grouped_files = []
|
82
94
|
groups.each do |name, filter|
|
83
|
-
grouped[name] = SimpleCov::FileList.new(files.select {|source_file| filter.matches?(source_file)})
|
95
|
+
grouped[name] = SimpleCov::FileList.new(files.select { |source_file| filter.matches?(source_file) })
|
84
96
|
grouped_files += grouped[name]
|
85
97
|
end
|
86
|
-
if groups.length > 0
|
98
|
+
if groups.length > 0 && (other_files = files.reject { |source_file| grouped_files.include?(source_file) }).length > 0
|
87
99
|
grouped["Ungrouped"] = SimpleCov::FileList.new(other_files)
|
88
100
|
end
|
89
101
|
grouped
|
@@ -106,11 +118,11 @@ module SimpleCov
|
|
106
118
|
# provides coverage support
|
107
119
|
#
|
108
120
|
def usable?
|
109
|
-
return @usable if defined?
|
121
|
+
return @usable if defined?(@usable) && !@usable.nil?
|
110
122
|
|
111
123
|
@usable = begin
|
112
|
-
require
|
113
|
-
require
|
124
|
+
require "coverage"
|
125
|
+
require "simplecov/jruby_fix"
|
114
126
|
true
|
115
127
|
rescue LoadError
|
116
128
|
false
|
@@ -120,24 +132,23 @@ module SimpleCov
|
|
120
132
|
end
|
121
133
|
|
122
134
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__)))
|
123
|
-
require
|
135
|
+
require "simplecov/configuration"
|
124
136
|
SimpleCov.send :extend, SimpleCov::Configuration
|
125
|
-
require
|
126
|
-
require
|
127
|
-
require
|
128
|
-
require
|
129
|
-
require
|
130
|
-
require
|
131
|
-
require
|
132
|
-
require
|
133
|
-
require
|
134
|
-
require
|
135
|
-
require
|
136
|
-
require
|
137
|
-
require 'simplecov/version'
|
137
|
+
require "simplecov/exit_codes"
|
138
|
+
require "simplecov/profiles"
|
139
|
+
require "simplecov/source_file"
|
140
|
+
require "simplecov/file_list"
|
141
|
+
require "simplecov/result"
|
142
|
+
require "simplecov/filter"
|
143
|
+
require "simplecov/formatter"
|
144
|
+
require "simplecov/last_run"
|
145
|
+
require "simplecov/merge_helpers"
|
146
|
+
require "simplecov/result_merger"
|
147
|
+
require "simplecov/command_guesser"
|
148
|
+
require "simplecov/version"
|
138
149
|
|
139
150
|
# Load default config
|
140
|
-
require
|
151
|
+
require "simplecov/defaults" unless ENV["SIMPLECOV_NO_DEFAULTS"]
|
141
152
|
|
142
153
|
# Load Rails integration (only for Rails 3, see #113)
|
143
|
-
require
|
154
|
+
require "simplecov/railtie" if defined? Rails::Railtie
|