simplecov 0.12.0 → 0.13.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 +7 -0
- data/.travis.yml +6 -2
- data/CHANGELOG.md +9 -1
- data/Gemfile +8 -6
- data/README.md +2 -2
- data/Rakefile +9 -4
- data/lib/simplecov/configuration.rb +2 -2
- data/lib/simplecov/defaults.rb +1 -1
- data/lib/simplecov/merge_helpers.rb +5 -2
- data/lib/simplecov/result.rb +6 -1
- data/lib/simplecov/source_file.rb +10 -6
- data/lib/simplecov/version.rb +1 -1
- data/spec/1_8_fallbacks_spec.rb +19 -17
- data/spec/command_guesser_spec.rb +40 -38
- data/spec/file_list_spec.rb +48 -46
- data/spec/filters_spec.rb +73 -71
- data/spec/merge_helpers_spec.rb +95 -83
- data/spec/result_spec.rb +152 -150
- data/spec/source_file_line_spec.rb +109 -107
- data/spec/source_file_spec.rb +56 -54
- metadata +4 -82
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15fa4589e25ee4710bdbcec7485a4d8ec7be7abb
|
4
|
+
data.tar.gz: a1627cf287ce3c70ba2d60e0943f28f90fcdef79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03a052dcae5923fe19e56f6f20fbd390505f03dca386d51eaca4b525252054856ce492e783e6923ad3b89a46719b89556747b8bbac295513b1d245fba3232e79
|
7
|
+
data.tar.gz: e2cd84b984e35dfa0c048f375ed2555f08d4df239d616d7c70289b086b1904394b1344f177ad5d7dd08cfb695fe2c22d5375af8e07da5d773500b034d87d4b1c
|
data/.rubocop.yml
CHANGED
@@ -4,6 +4,9 @@ AllCops:
|
|
4
4
|
- 'tmp/**/*'
|
5
5
|
- 'vendor/bundle/**/*'
|
6
6
|
|
7
|
+
Bundler/OrderedGems:
|
8
|
+
Enabled: false
|
9
|
+
|
7
10
|
Lint/AmbiguousRegexpLiteral:
|
8
11
|
Exclude:
|
9
12
|
- 'features/**/*_steps.rb'
|
@@ -13,6 +16,10 @@ Lint/AmbiguousRegexpLiteral:
|
|
13
16
|
Metrics/AbcSize:
|
14
17
|
Max: 25 # TODO: Lower to 15
|
15
18
|
|
19
|
+
Metrics/BlockLength:
|
20
|
+
Exclude:
|
21
|
+
- 'spec/**/*.rb'
|
22
|
+
|
16
23
|
Metrics/BlockNesting:
|
17
24
|
Max: 2
|
18
25
|
|
data/.travis.yml
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
language: ruby
|
2
2
|
|
3
3
|
before_install:
|
4
|
+
- gem update --system
|
4
5
|
- gem install bundler
|
5
6
|
|
6
7
|
bundler_args: --without development --jobs=3 --retry=3
|
@@ -14,15 +15,18 @@ rvm:
|
|
14
15
|
- 1.9.3
|
15
16
|
- 2.0.0
|
16
17
|
- 2.1.10
|
17
|
-
- 2.2.
|
18
|
-
- 2.3.
|
18
|
+
- 2.2.6
|
19
|
+
- 2.3.3
|
20
|
+
- 2.4.0
|
19
21
|
- ruby-head
|
20
22
|
- jruby-head
|
23
|
+
- jruby-9.1.7.0
|
21
24
|
- rbx-2
|
22
25
|
|
23
26
|
matrix:
|
24
27
|
allow_failures:
|
25
28
|
- rvm: ruby-head
|
26
29
|
- rvm: jruby-head
|
30
|
+
- rvm: jruby-9.1.7.0
|
27
31
|
- rvm: rbx-2
|
28
32
|
fast_finish: true
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,18 @@
|
|
1
|
-
|
1
|
+
0.13.0 2016-01-25 ([changes](https://github.com/colszowka/simplecov/compare/v0.12.0...v0.13.0))
|
2
2
|
==========
|
3
3
|
|
4
4
|
## Enhancements
|
5
5
|
|
6
|
+
* Faster run times when a very large number of files is loaded into SimpleCov. See [#520](https://github.com/colszowka/simplecov/pull/520) (thanks @alyssais)
|
7
|
+
* Only read in source code files that are actually used (faster when files are ignored etc.). See [#540](https://github.com/colszowka/simplecov/pull/540) (tahks @yui-knk)
|
8
|
+
|
6
9
|
## Bugfixes
|
7
10
|
|
11
|
+
* Fix merging of resultsets if a file is missing on one side. See [#513](https://github.com/colszowka/simplecov/pull/513) (thanks @hanazuki)
|
12
|
+
* Fix Ruby 2.4 deprecation warnings by using Integer instead of Fixnum. See [#523](https://github.com/colszowka/simplecov/pull/523) (thanks @nobu)
|
13
|
+
* Force Ruby 2 to json 2. See [dc7417d50](https://github.com/colszowka/simplecov/commit/dc7417d5049b1809cea214314c15dd93a5dd964f) (thanks @amatsuda)
|
14
|
+
* Various other gem dependency fixes for different gems on different ruby versions. (thanks @amatsuda)
|
15
|
+
|
8
16
|
0.12.0 2016-07-02 ([changes](https://github.com/colszowka/simplecov/compare/v0.11.2...v0.12.0))
|
9
17
|
=================
|
10
18
|
|
data/Gemfile
CHANGED
@@ -11,26 +11,28 @@ gem "rake", Gem::Version.new(RUBY_VERSION) < Gem::Version.new("1.9.3") ? "~>10.3
|
|
11
11
|
group :test do
|
12
12
|
gem "rspec", ">= 3.2"
|
13
13
|
# Older versions of some gems required for Ruby 1.8.7 support
|
14
|
-
|
14
|
+
platforms :ruby_18 do
|
15
15
|
gem "activesupport", "~> 3.2.21"
|
16
16
|
gem "i18n", "~> 0.6.11"
|
17
17
|
end
|
18
|
-
|
18
|
+
platforms :ruby_18, :ruby_19 do
|
19
19
|
gem "mime-types", "~> 1.25"
|
20
|
-
gem "
|
20
|
+
gem "addressable", "~> 2.3.0"
|
21
21
|
end
|
22
|
-
|
22
|
+
platforms :ruby_18, :ruby_19, :ruby_20, :ruby_21 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
26
|
gem "aruba", "~> 0.7.4"
|
27
27
|
gem "capybara"
|
28
|
+
gem "nokogiri", RUBY_VERSION < "2.1" ? "~> 1.6.0" : ">= 1.7"
|
28
29
|
gem "cucumber"
|
29
30
|
gem "phantomjs", "~> 1.9"
|
30
31
|
gem "poltergeist"
|
31
|
-
gem "rubocop"
|
32
|
+
gem "rubocop" unless RUBY_VERSION.start_with?("1.")
|
32
33
|
gem "test-unit"
|
33
34
|
end
|
35
|
+
gem "json", RUBY_VERSION.start_with?("1.") ? "~> 1.8" : "~> 2.0"
|
34
36
|
end
|
35
37
|
|
36
38
|
gemspec
|
data/README.md
CHANGED
@@ -101,12 +101,12 @@ Getting started
|
|
101
101
|
|
102
102
|
**Coverage results report, fully browsable locally with sorting and much more:**
|
103
103
|
|
104
|
-

|
105
105
|
|
106
106
|
|
107
107
|
**Source file coverage details view:**
|
108
108
|
|
109
|
-

|
110
110
|
|
111
111
|
## Use it with any framework!
|
112
112
|
|
data/Rakefile
CHANGED
@@ -27,10 +27,15 @@ rescue LoadError
|
|
27
27
|
end
|
28
28
|
|
29
29
|
# Cucumber integration test suite is for impls that work with simplecov only - a.k.a. 1.9+
|
30
|
-
if RUBY_VERSION
|
30
|
+
if RUBY_VERSION.start_with? "1.8"
|
31
|
+
task :default => [:spec]
|
32
|
+
else
|
31
33
|
require "cucumber/rake/task"
|
32
34
|
Cucumber::Rake::Task.new
|
33
|
-
|
34
|
-
|
35
|
-
|
35
|
+
|
36
|
+
if RUBY_VERSION.start_with? "1.9"
|
37
|
+
task :default => [:spec, :cucumber]
|
38
|
+
else
|
39
|
+
task :default => [:spec, :cucumber, :rubocop]
|
40
|
+
end
|
36
41
|
end
|
@@ -192,7 +192,7 @@ module SimpleCov
|
|
192
192
|
end
|
193
193
|
|
194
194
|
#
|
195
|
-
# Defines
|
195
|
+
# Defines the maximum age (in seconds) of a resultset to still be included in merged results.
|
196
196
|
# i.e. If you run cucumber features, then later rake test, if the stored cucumber resultset is
|
197
197
|
# more seconds ago than specified here, it won't be taken into account when merging (and is also
|
198
198
|
# purged from the resultset cache)
|
@@ -204,7 +204,7 @@ module SimpleCov
|
|
204
204
|
# Configure with SimpleCov.merge_timeout(3600) # 1hr
|
205
205
|
#
|
206
206
|
def merge_timeout(seconds = nil)
|
207
|
-
@merge_timeout = seconds if seconds.is_a?(
|
207
|
+
@merge_timeout = seconds if seconds.is_a?(Integer)
|
208
208
|
@merge_timeout ||= 600
|
209
209
|
end
|
210
210
|
|
data/lib/simplecov/defaults.rb
CHANGED
@@ -49,7 +49,7 @@ end
|
|
49
49
|
# Gotta stash this a-s-a-p, see the CommandGuesser class and i.e. #110 for further info
|
50
50
|
SimpleCov::CommandGuesser.original_run_command = "#{$PROGRAM_NAME} #{ARGV.join(' ')}"
|
51
51
|
|
52
|
-
at_exit do
|
52
|
+
at_exit do # rubocop:disable Metrics/BlockLength
|
53
53
|
# If we are in a different process than called start, don't interfere.
|
54
54
|
next if SimpleCov.pid != Process.pid
|
55
55
|
|
@@ -22,11 +22,14 @@ module SimpleCov
|
|
22
22
|
def merge_resultset(hash)
|
23
23
|
new_resultset = {}
|
24
24
|
(keys + hash.keys).each do |filename|
|
25
|
-
new_resultset[filename] =
|
25
|
+
new_resultset[filename] = nil
|
26
26
|
end
|
27
27
|
|
28
28
|
new_resultset.each_key do |filename|
|
29
|
-
|
29
|
+
result1 = self[filename]
|
30
|
+
result2 = hash[filename]
|
31
|
+
new_resultset[filename] =
|
32
|
+
result1 && result2 ? result1.extend(ArrayMergeHelper).merge_resultset(result2) : (result1 || result2).dup
|
30
33
|
end
|
31
34
|
new_resultset
|
32
35
|
end
|
data/lib/simplecov/result.rb
CHANGED
@@ -60,7 +60,7 @@ module SimpleCov
|
|
60
60
|
|
61
61
|
# Returns a hash representation of this Result that can be used for marshalling it into JSON
|
62
62
|
def to_hash
|
63
|
-
{command_name => {"coverage" =>
|
63
|
+
{command_name => {"coverage" => coverage, "timestamp" => created_at.to_i}}
|
64
64
|
end
|
65
65
|
|
66
66
|
# Loads a SimpleCov::Result#to_hash dump
|
@@ -74,6 +74,11 @@ module SimpleCov
|
|
74
74
|
|
75
75
|
private
|
76
76
|
|
77
|
+
def coverage
|
78
|
+
keys = original_result.keys & filenames
|
79
|
+
Hash[keys.zip(original_result.values_at(*keys))]
|
80
|
+
end
|
81
|
+
|
77
82
|
# Applies all configured SimpleCov filters on this result's source files
|
78
83
|
def filter!
|
79
84
|
@files = SimpleCov.filtered(files)
|
@@ -26,8 +26,8 @@ module SimpleCov
|
|
26
26
|
|
27
27
|
def initialize(src, line_number, coverage)
|
28
28
|
raise ArgumentError, "Only String accepted for source" unless src.is_a?(String)
|
29
|
-
raise ArgumentError, "Only
|
30
|
-
raise ArgumentError, "Only
|
29
|
+
raise ArgumentError, "Only Integer accepted for line_number" unless line_number.is_a?(Integer)
|
30
|
+
raise ArgumentError, "Only Integer and nil accepted for coverage" unless coverage.is_a?(Integer) || coverage.nil?
|
31
31
|
@src = src
|
32
32
|
@line_number = line_number
|
33
33
|
@coverage = coverage
|
@@ -74,16 +74,20 @@ module SimpleCov
|
|
74
74
|
attr_reader :filename
|
75
75
|
# The array of coverage data received from the Coverage.result
|
76
76
|
attr_reader :coverage
|
77
|
-
# The source code for this file. Aliased as :source
|
78
|
-
attr_reader :src
|
79
|
-
alias source src
|
80
77
|
|
81
78
|
def initialize(filename, coverage)
|
82
79
|
@filename = filename
|
83
80
|
@coverage = coverage
|
84
|
-
File.open(filename, "rb") { |f| @src = f.readlines }
|
85
81
|
end
|
86
82
|
|
83
|
+
# The source code for this file. Aliased as :source
|
84
|
+
def src
|
85
|
+
# We intentionally read source code lazily to
|
86
|
+
# suppress reading unused source code.
|
87
|
+
@src ||= File.open(filename, "rb", &:readlines)
|
88
|
+
end
|
89
|
+
alias source src
|
90
|
+
|
87
91
|
# Returns all source lines for this file as instances of SimpleCov::SourceFile::Line,
|
88
92
|
# and thus including coverage data. Aliased as :source_lines
|
89
93
|
def lines
|
data/lib/simplecov/version.rb
CHANGED
data/spec/1_8_fallbacks_spec.rb
CHANGED
@@ -6,24 +6,26 @@ require "helper"
|
|
6
6
|
# TODO: This should be expanded upon all methods that could potentially
|
7
7
|
# be called in a test/spec-helper simplecov config block
|
8
8
|
#
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
if RUBY_VERSION.start_with? "1.8"
|
10
|
+
describe "Ruby 1.8 fallback" do
|
11
|
+
it "return false when calling SimpleCov.start" do
|
12
|
+
expect(SimpleCov.start).to be false
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
it "return false when calling SimpleCov.start with a block" do
|
16
|
+
expect(SimpleCov.start { raise "Shouldn't reach this!" }).to be false
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
it "return false when calling SimpleCov.configure with a block" do
|
20
|
+
expect(SimpleCov.configure { raise "Shouldn't reach this!" }).to be false
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
it "allow to define a profile" do
|
24
|
+
expect do
|
25
|
+
SimpleCov.profiles.define "testprofile" do
|
26
|
+
add_filter "/config/"
|
27
|
+
end
|
28
|
+
end.not_to raise_error
|
29
|
+
end
|
28
30
|
end
|
29
|
-
end
|
31
|
+
end
|
@@ -1,46 +1,48 @@
|
|
1
1
|
require "helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
3
|
+
if SimpleCov.usable?
|
4
|
+
describe SimpleCov::CommandGuesser do
|
5
|
+
subject { SimpleCov::CommandGuesser }
|
6
|
+
it 'correctly guesses "Unit Tests" for unit tests' do
|
7
|
+
subject.original_run_command = "/some/path/test/units/foo_bar_test.rb"
|
8
|
+
expect(subject.guess).to eq("Unit Tests")
|
9
|
+
subject.original_run_command = "test/units/foo.rb"
|
10
|
+
expect(subject.guess).to eq("Unit Tests")
|
11
|
+
subject.original_run_command = "test/foo.rb"
|
12
|
+
expect(subject.guess).to eq("Unit Tests")
|
13
|
+
subject.original_run_command = "test/{models,helpers,unit}/**/*_test.rb"
|
14
|
+
expect(subject.guess).to eq("Unit Tests")
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
it 'correctly guesses "Functional Tests" for functional tests' do
|
18
|
+
subject.original_run_command = "/some/path/test/functional/foo_bar_controller_test.rb"
|
19
|
+
expect(subject.guess).to eq("Functional Tests")
|
20
|
+
subject.original_run_command = "test/{controllers,mailers,functional}/**/*_test.rb"
|
21
|
+
expect(subject.guess).to eq("Functional Tests")
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
it 'correctly guesses "Integration Tests" for integration tests' do
|
25
|
+
subject.original_run_command = "/some/path/test/integration/foo_bar_controller_test.rb"
|
26
|
+
expect(subject.guess).to eq("Integration Tests")
|
27
|
+
subject.original_run_command = "test/integration/**/*_test.rb"
|
28
|
+
expect(subject.guess).to eq("Integration Tests")
|
29
|
+
end
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
it 'correctly guesses "Cucumber Features" for cucumber features' do
|
32
|
+
subject.original_run_command = "features"
|
33
|
+
expect(subject.guess).to eq("Cucumber Features")
|
34
|
+
subject.original_run_command = "cucumber"
|
35
|
+
expect(subject.guess).to eq("Cucumber Features")
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
it 'correctly guesses "RSpec" for RSpec' do
|
39
|
+
subject.original_run_command = "/some/path/spec/foo.rb"
|
40
|
+
expect(subject.guess).to eq("RSpec")
|
41
|
+
end
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
it "defaults to RSpec because RSpec constant is defined" do
|
44
|
+
subject.original_run_command = "some_arbitrary_command with arguments"
|
45
|
+
expect(subject.guess).to eq("RSpec")
|
46
|
+
end
|
45
47
|
end
|
46
|
-
end
|
48
|
+
end
|
data/spec/file_list_spec.rb
CHANGED
@@ -1,48 +1,50 @@
|
|
1
1
|
require "helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
3
|
+
if SimpleCov.usable?
|
4
|
+
describe SimpleCov::Result do
|
5
|
+
subject do
|
6
|
+
original_result = {
|
7
|
+
source_fixture("sample.rb") => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil],
|
8
|
+
source_fixture("app/models/user.rb") => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
|
9
|
+
source_fixture("app/controllers/sample_controller.rb") => [nil, 2, 2, 0, nil, nil, 0, nil, nil, nil],
|
10
|
+
}
|
11
|
+
SimpleCov::Result.new(original_result).files
|
12
|
+
end
|
13
|
+
|
14
|
+
it "has 11 covered lines" do
|
15
|
+
expect(subject.covered_lines).to eq(11)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "has 3 missed lines" do
|
19
|
+
expect(subject.missed_lines).to eq(3)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "has 19 never lines" do
|
23
|
+
expect(subject.never_lines).to eq(19)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "has 14 lines of code" do
|
27
|
+
expect(subject.lines_of_code).to eq(14)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "has 3 skipped lines" do
|
31
|
+
expect(subject.skipped_lines).to eq(3)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "has the correct covered percent" do
|
35
|
+
expect(subject.covered_percent).to eq(78.57142857142857)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "has the correct covered percentages" do
|
39
|
+
expect(subject.covered_percentages).to eq([50.0, 80.0, 100.0])
|
40
|
+
end
|
41
|
+
|
42
|
+
it "has the correct least covered file" do
|
43
|
+
expect(subject.least_covered_file).to match(/sample_controller.rb/)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "has the correct covered strength" do
|
47
|
+
expect(subject.covered_strength).to eq(0.9285714285714286)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|