simplecov 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4ded95468b70d7817ca95004ac38a0b6ad2e388
4
- data.tar.gz: 2bb87e0871a8daa3955049fa6e808968d479ea48
3
+ metadata.gz: 15fa4589e25ee4710bdbcec7485a4d8ec7be7abb
4
+ data.tar.gz: a1627cf287ce3c70ba2d60e0943f28f90fcdef79
5
5
  SHA512:
6
- metadata.gz: af959d1c396d33ac1f1f76e6108993d1e0af61e1f9059feb4dcbb598e46eceb51b930370d6e1f5f3711dc498ced9176a72ae125498f1d3b385581bba00c61466
7
- data.tar.gz: fd27be25b4cca08be020931d330cc2a958559a49c61c8058b6433a55d75252b263502c74445efa21ee7a7683aceee6a4650501fe00a07ee25dbad546aef891f5
6
+ metadata.gz: 03a052dcae5923fe19e56f6f20fbd390505f03dca386d51eaca4b525252054856ce492e783e6923ad3b89a46719b89556747b8bbac295513b1d245fba3232e79
7
+ data.tar.gz: e2cd84b984e35dfa0c048f375ed2555f08d4df239d616d7c70289b086b1904394b1344f177ad5d7dd08cfb695fe2c22d5375af8e07da5d773500b034d87d4b1c
@@ -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
 
@@ -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.5
18
- - 2.3.0
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
@@ -1,10 +1,18 @@
1
- Unreleased ([changes](https://github.com/colszowka/simplecov/compare/v0.12.0...master))
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
- platform :ruby_18 do
14
+ platforms :ruby_18 do
15
15
  gem "activesupport", "~> 3.2.21"
16
16
  gem "i18n", "~> 0.6.11"
17
17
  end
18
- platform :ruby_18, :ruby_19 do
18
+ platforms :ruby_18, :ruby_19 do
19
19
  gem "mime-types", "~> 1.25"
20
- gem "json", "~> 1.8"
20
+ gem "addressable", "~> 2.3.0"
21
21
  end
22
- platform :ruby_18, :ruby_19, :ruby_20, :ruby_21 do
22
+ platforms :ruby_18, :ruby_19, :ruby_20, :ruby_21 do
23
23
  gem "rack", "~> 1.6"
24
24
  end
25
- platform :jruby, :ruby_19, :ruby_20, :ruby_21, :ruby_22, :ruby_23 do
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", "~> 0.41.0"
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
- ![SimpleCov coverage report](http://colszowka.github.com/simplecov/devise_result-0.5.3.png)
104
+ ![SimpleCov coverage report](https://cloud.githubusercontent.com/assets/137793/17071162/db6f253e-502d-11e6-9d84-e40c3d75f333.png)
105
105
 
106
106
 
107
107
  **Source file coverage details view:**
108
108
 
109
- ![SimpleCov source file detail view](http://colszowka.github.com/simplecov/devise_source_file-0.5.3.png)
109
+ ![SimpleCov source file detail view](https://cloud.githubusercontent.com/assets/137793/17071163/db6f9f0a-502d-11e6-816c-edb2c66fad8d.png)
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 >= "1.9"
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
- task :default => [:spec, :cucumber, :rubocop]
34
- else
35
- task :default => [:spec]
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 them maximum age (in seconds) of a resultset to still be included in merged results.
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?(Fixnum)
207
+ @merge_timeout = seconds if seconds.is_a?(Integer)
208
208
  @merge_timeout ||= 600
209
209
  end
210
210
 
@@ -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
- new_resultset[filename] = (self[filename] || []).extend(SimpleCov::ArrayMergeHelper).merge_resultset(hash[filename] || [])
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
@@ -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" => original_result.reject { |filename, _| !filenames.include?(filename) }, "timestamp" => created_at.to_i}}
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 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?
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
@@ -1,5 +1,5 @@
1
1
  module SimpleCov
2
- version = "0.12.0"
2
+ version = "0.13.0"
3
3
 
4
4
  def version.to_a
5
5
  split(".").map(&:to_i)
@@ -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
- describe "Ruby 1.8 fallback" do
10
- it "return false when calling SimpleCov.start" do
11
- expect(SimpleCov.start).to be false
12
- end
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
- it "return false when calling SimpleCov.start with a block" do
15
- expect(SimpleCov.start { raise "Shouldn't reach this!" }).to be false
16
- end
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
- it "return false when calling SimpleCov.configure with a block" do
19
- expect(SimpleCov.configure { raise "Shouldn't reach this!" }).to be false
20
- end
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
- it "allow to define a profile" do
23
- expect do
24
- SimpleCov.profiles.define "testprofile" do
25
- add_filter "/config/"
26
- end
27
- end.not_to raise_error
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 if RUBY_VERSION.start_with? "1.8"
31
+ end
@@ -1,46 +1,48 @@
1
1
  require "helper"
2
2
 
3
- describe SimpleCov::CommandGuesser do
4
- subject { SimpleCov::CommandGuesser }
5
- it 'correctly guesses "Unit Tests" for unit tests' do
6
- subject.original_run_command = "/some/path/test/units/foo_bar_test.rb"
7
- expect(subject.guess).to eq("Unit Tests")
8
- subject.original_run_command = "test/units/foo.rb"
9
- expect(subject.guess).to eq("Unit Tests")
10
- subject.original_run_command = "test/foo.rb"
11
- expect(subject.guess).to eq("Unit Tests")
12
- subject.original_run_command = "test/{models,helpers,unit}/**/*_test.rb"
13
- expect(subject.guess).to eq("Unit Tests")
14
- end
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
- it 'correctly guesses "Functional Tests" for functional tests' do
17
- subject.original_run_command = "/some/path/test/functional/foo_bar_controller_test.rb"
18
- expect(subject.guess).to eq("Functional Tests")
19
- subject.original_run_command = "test/{controllers,mailers,functional}/**/*_test.rb"
20
- expect(subject.guess).to eq("Functional Tests")
21
- end
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
- it 'correctly guesses "Integration Tests" for integration tests' do
24
- subject.original_run_command = "/some/path/test/integration/foo_bar_controller_test.rb"
25
- expect(subject.guess).to eq("Integration Tests")
26
- subject.original_run_command = "test/integration/**/*_test.rb"
27
- expect(subject.guess).to eq("Integration Tests")
28
- end
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
- it 'correctly guesses "Cucumber Features" for cucumber features' do
31
- subject.original_run_command = "features"
32
- expect(subject.guess).to eq("Cucumber Features")
33
- subject.original_run_command = "cucumber"
34
- expect(subject.guess).to eq("Cucumber Features")
35
- end
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
- it 'correctly guesses "RSpec" for RSpec' do
38
- subject.original_run_command = "/some/path/spec/foo.rb"
39
- expect(subject.guess).to eq("RSpec")
40
- end
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
- it "defaults to RSpec because RSpec constant is defined" do
43
- subject.original_run_command = "some_arbitrary_command with arguments"
44
- expect(subject.guess).to eq("RSpec")
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 if SimpleCov.usable?
48
+ end
@@ -1,48 +1,50 @@
1
1
  require "helper"
2
2
 
3
- describe SimpleCov::Result do
4
- subject do
5
- original_result = {
6
- source_fixture("sample.rb") => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil],
7
- source_fixture("app/models/user.rb") => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
8
- source_fixture("app/controllers/sample_controller.rb") => [nil, 2, 2, 0, nil, nil, 0, nil, nil, nil],
9
- }
10
- SimpleCov::Result.new(original_result).files
11
- end
12
-
13
- it "has 11 covered lines" do
14
- expect(subject.covered_lines).to eq(11)
15
- end
16
-
17
- it "has 3 missed lines" do
18
- expect(subject.missed_lines).to eq(3)
19
- end
20
-
21
- it "has 19 never lines" do
22
- expect(subject.never_lines).to eq(19)
23
- end
24
-
25
- it "has 14 lines of code" do
26
- expect(subject.lines_of_code).to eq(14)
27
- end
28
-
29
- it "has 3 skipped lines" do
30
- expect(subject.skipped_lines).to eq(3)
31
- end
32
-
33
- it "has the correct covered percent" do
34
- expect(subject.covered_percent).to eq(78.57142857142857)
35
- end
36
-
37
- it "has the correct covered percentages" do
38
- expect(subject.covered_percentages).to eq([50.0, 80.0, 100.0])
39
- end
40
-
41
- it "has the correct least covered file" do
42
- expect(subject.least_covered_file).to match(/sample_controller.rb/)
43
- end
44
-
45
- it "has the correct covered strength" do
46
- expect(subject.covered_strength).to eq(0.9285714285714286)
47
- end
48
- end if SimpleCov.usable?
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