simplecov 0.11.0 → 0.12.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bcd3fcd0c8e30121cc9f50e81b8b756f1153e8a3
4
- data.tar.gz: 58d53aacce8c59039020aa58c651c6c66b04c414
3
+ metadata.gz: c4ded95468b70d7817ca95004ac38a0b6ad2e388
4
+ data.tar.gz: 2bb87e0871a8daa3955049fa6e808968d479ea48
5
5
  SHA512:
6
- metadata.gz: 8edc40314d68f3964d6cdba4d99a9afb07f15e7bafdc5ecccdeda85ce2d662ff5016ccc0b5e78edf5668ca40c92bf168d2f3b031ca08b541a18f15d717354f69
7
- data.tar.gz: 60b3f714f8701072f44186639a4915aae3b8fdd8341e31ad41b2bde07961917052c012106fccad8b2a54ced75be9f84f7f1f743b3ef64a7b7bd0671c906eea83
6
+ metadata.gz: af959d1c396d33ac1f1f76e6108993d1e0af61e1f9059feb4dcbb598e46eceb51b930370d6e1f5f3711dc498ced9176a72ae125498f1d3b385581bba00c61466
7
+ data.tar.gz: fd27be25b4cca08be020931d330cc2a958559a49c61c8058b6433a55d75252b263502c74445efa21ee7a7683aceee6a4650501fe00a07ee25dbad546aef891f5
data/.rubocop.yml CHANGED
@@ -66,5 +66,12 @@ Style/FileName:
66
66
  Exclude:
67
67
  - 'spec/fixtures/utf-8.rb'
68
68
 
69
- Style/TrailingComma:
70
- EnforcedStyleForMultiline: 'comma'
69
+ Style/TrailingCommaInLiteral:
70
+ EnforcedStyleForMultiline: comma
71
+
72
+ Style/GuardClause:
73
+ Enabled: false
74
+
75
+ Style/MutableConstant:
76
+ Exclude:
77
+ - 'lib/simplecov/version.rb' # required for older versions of rubygems
data/.travis.yml CHANGED
@@ -13,15 +13,16 @@ rvm:
13
13
  - 1.8.7
14
14
  - 1.9.3
15
15
  - 2.0.0
16
- - 2.1
17
- - 2.2
16
+ - 2.1.10
17
+ - 2.2.5
18
+ - 2.3.0
18
19
  - ruby-head
19
- - jruby
20
+ - jruby-head
20
21
  - rbx-2
21
22
 
22
23
  matrix:
23
24
  allow_failures:
24
25
  - rvm: ruby-head
25
- - rvm: jruby
26
+ - rvm: jruby-head
26
27
  - rvm: rbx-2
27
28
  fast_finish: true
data/CHANGELOG.md CHANGED
@@ -1,17 +1,52 @@
1
- Unreleased ([changes](https://github.com/colszowka/simplecov/compare/v0.11.0...master))
1
+ Unreleased ([changes](https://github.com/colszowka/simplecov/compare/v0.12.0...master))
2
+ ==========
3
+
4
+ ## Enhancements
5
+
6
+ ## Bugfixes
7
+
8
+ 0.12.0 2016-07-02 ([changes](https://github.com/colszowka/simplecov/compare/v0.11.2...v0.12.0))
9
+ =================
10
+
11
+ ## Enhancements
12
+
13
+ * Add support for JSON versions 2.x
14
+
15
+ ## Bugfixes
16
+
17
+ * Fix coverage rate of the parallel_tests. See [#441](https://github.com/colszowka/simplecov/pull/441) (thanks @sinsoku)
18
+ * Fix a regression on old rubies that failed to work with the recently introduced frozen VERSION string. See [#461](https://github.com/colszowka/simplecov/pull/461) (thanks @leafle)
19
+
20
+ 0.11.2 2016-02-03 ([changes](https://github.com/colszowka/simplecov/compare/v0.11.1...v0.11.2))
2
21
  =================
3
22
 
4
23
  ## Enhancements
5
24
 
25
+ * Do not globally pollute Array and Hash with `merge_resultset` utility methods. See [#449](https://github.com/colszowka/simplecov/pull/449) (thanks @amatsuda)
26
+ * Do not `mkdir_p` the `coverage_path` on every access of the method (See [#453](https://github.com/colszowka/simplecov/pull/453) (thanks @paddor)
27
+ * Fixes a Ruby warning related to the `track_files` configuration. See [#447](https://github.com/colszowka/simplecov/pull/447) (thanks @craiglittle)
28
+ * Add a group for background jobs to default Rails profile. See [#442](https://github.com/colszowka/simplecov/pull/442) (thanks @stve)
29
+
6
30
  ## Bugfixes
7
31
 
8
- 0.11.0 2015-11-29 ([changes](https://github.com/colszowka/simplecov/compare/v0.10.0...v0.10.11))
32
+ * Fix root_filter evaluates SimpleCov.root before initialization. See [#437](https://github.com/colszowka/simplecov/pull/437) (thanks @tmtm)
33
+
34
+ 0.11.1 2015-12-01 ([changes](https://github.com/colszowka/simplecov/compare/v0.11.0...v0.11.1))
35
+ =================
36
+
37
+ ## Enhancements
38
+
39
+ ## Bugfixes
40
+
41
+ * Fixed regression in `MultiFormatter.[]` with multiple arguments. See [#431](https://github.com/colszowka/simplecov/pull/431) (thanks @dillondrobena)
42
+
43
+ 0.11.0 2015-11-29 ([changes](https://github.com/colszowka/simplecov/compare/v0.10.0...v0.11.0))
9
44
  =================
10
45
 
11
46
  ## Enhancements
12
47
 
13
48
  * Added `SimpleCov.minimum_coverage_by_file` for per-file coverage thresholds. See [#392](https://github.com/colszowka/simplecov/pull/392) (thanks @ptashman)
14
- * Added `track_files` configuration option to specify a glob to always include in coverage results, whether or not those files are required. See [#422](https://github.com/colszowka/simplecov/pull/422) (thanks @hugopeixoto)
49
+ * Added `track_files` configuration option to specify a glob to always include in coverage results, whether or not those files are required. By default, this is enabled in the Rails profile for common Rails directories. See [#422](https://github.com/colszowka/simplecov/pull/422) (thanks @hugopeixoto)
15
50
  * Speed up `root_filter` by an order of magnitude. See [#396](https://github.com/colszowka/simplecov/pull/396) (thanks @raszi)
16
51
 
17
52
  ## Bugfixes
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ source "https://rubygems.org"
6
6
  # Uncomment this to use development version of html formatter from github
7
7
  # gem 'simplecov-html', :github => 'colszowka/simplecov-html'
8
8
 
9
- gem "rake", ">= 10.3"
9
+ gem "rake", Gem::Version.new(RUBY_VERSION) < Gem::Version.new("1.9.3") ? "~>10.3" : ">= 10.3"
10
10
 
11
11
  group :test do
12
12
  gem "rspec", ">= 3.2"
@@ -15,19 +15,21 @@ group :test do
15
15
  gem "activesupport", "~> 3.2.21"
16
16
  gem "i18n", "~> 0.6.11"
17
17
  end
18
- platform :jruby, :ruby_19, :ruby_20, :ruby_21, :ruby_22 do
18
+ platform :ruby_18, :ruby_19 do
19
+ gem "mime-types", "~> 1.25"
20
+ gem "json", "~> 1.8"
21
+ end
22
+ platform :ruby_18, :ruby_19, :ruby_20, :ruby_21 do
23
+ gem "rack", "~> 1.6"
24
+ end
25
+ platform :jruby, :ruby_19, :ruby_20, :ruby_21, :ruby_22, :ruby_23 do
19
26
  gem "aruba", "~> 0.7.4"
20
- gem "capybara", "~> 2.4"
21
-
22
- # Hack until Capybara fixes its gemspec. 3.0 removed 1.9 support.
23
- # See https://github.com/jnicklas/capybara/issues/1615
24
- gem "mime-types", "~> 2.0.0"
25
-
26
- gem "cucumber", "~> 2.0"
27
+ gem "capybara"
28
+ gem "cucumber"
27
29
  gem "phantomjs", "~> 1.9"
28
- gem "poltergeist", "~> 1.1"
29
- gem "rubocop", ">= 0.30"
30
- gem "test-unit", "~> 3.0"
30
+ gem "poltergeist"
31
+ gem "rubocop", "~> 0.41.0"
32
+ gem "test-unit"
31
33
  end
32
34
  end
33
35
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- SimpleCov [![Build Status](https://secure.travis-ci.org/colszowka/simplecov.png)][Continuous Integration] [![Dependency Status](https://gemnasium.com/colszowka/simplecov.png)][Dependencies] [![Code Climate](https://codeclimate.com/github/colszowka/simplecov.png)](https://codeclimate.com/github/colszowka/simplecov) [![Inline docs](http://inch-ci.org/github/colszowka/simplecov.png)](http://inch-ci.org/github/colszowka/simplecov)
1
+ SimpleCov [![Build Status](https://travis-ci.org/colszowka/simplecov.svg)][Continuous Integration] [![Dependency Status](https://gemnasium.com/colszowka/simplecov.svg)][Dependencies] [![Code Climate](https://codeclimate.com/github/colszowka/simplecov.svg)](https://codeclimate.com/github/colszowka/simplecov) [![Inline docs](http://inch-ci.org/github/colszowka/simplecov.svg)](http://inch-ci.org/github/colszowka/simplecov)
2
2
  =========
3
3
  **Code coverage for Ruby**
4
4
 
@@ -6,11 +6,8 @@ SimpleCov [![Build Status](https://secure.travis-ci.org/colszowka/simplecov.png)
6
6
  * [API documentation]
7
7
  * [Changelog]
8
8
  * [Rubygem]
9
- * [Mailing List]
10
9
  * [Continuous Integration]
11
10
 
12
- **Important Notice: There is a bug that affects exit code handling on the 0.8 line of SimpleCov, see [#281](https://github.com/colszowka/simplecov/issues/281). Please use versions `>= 0.9` to avoid this.**
13
-
14
11
  [Coverage]: http://www.ruby-doc.org/stdlib-2.1.0/libdoc/coverage/rdoc/Coverage.html "API doc for Ruby's Coverage library"
15
12
  [Source Code]: https://github.com/colszowka/simplecov "Source Code @ GitHub"
16
13
  [API documentation]: http://rubydoc.info/gems/simplecov/frames "RDoc API Documentation at Rubydoc.info"
@@ -20,10 +17,6 @@ SimpleCov [![Build Status](https://secure.travis-ci.org/colszowka/simplecov.png)
20
17
  [Continuous Integration]: http://travis-ci.org/colszowka/simplecov "SimpleCov is built around the clock by travis-ci.org"
21
18
  [Dependencies]: https://gemnasium.com/colszowka/simplecov "SimpleCov dependencies on Gemnasium"
22
19
  [simplecov-html]: https://github.com/colszowka/simplecov-html "SimpleCov HTML Formatter Source Code @ GitHub"
23
- [Mailing List]: https://groups.google.com/forum/#!forum/simplecov "Open mailing list for discussion and announcements on Google Groups"
24
- [Pledgie]: http://www.pledgie.com/campaigns/18379
25
-
26
- [![You can support the development of SimpleCov via Pledgie - thanks for your help](https://pledgie.com/campaigns/18379.png?skin_name=chrome)][Pledgie]
27
20
 
28
21
  SimpleCov is a code coverage analysis tool for Ruby. It uses [Ruby's built-in Coverage][Coverage] library to gather code
29
22
  coverage data, but makes processing its results much easier by providing a clean API to filter, group, merge, format,
@@ -153,19 +146,6 @@ to use SimpleCov with them. Here's an overview of the known ones:
153
146
  <a href="https://github.com/colszowka/simplecov/pull/185">#185</a>
154
147
  </td>
155
148
  </tr>
156
- <tr>
157
- <th>
158
- Riot
159
- </th>
160
- <td>
161
- A user has reported problems with the coverage report using the riot
162
- framework. If you experience similar trouble please follow up on the
163
- related GitHub issue.
164
- </td>
165
- <td>
166
- <a href="https://github.com/colszowka/simplecov/issues/80">#80</a>
167
- </td>
168
- </tr>
169
149
  <tr>
170
150
  <th>
171
151
  RubyMine
@@ -11,7 +11,7 @@ Given /^SimpleCov for (.*) is configured with:$/ do |framework, config_body|
11
11
  when /Cucumber/i
12
12
  "features/support"
13
13
  else
14
- fail ArgumentError, "Could not identify test framework #{framework}!"
14
+ raise ArgumentError, "Could not identify test framework #{framework}!"
15
15
  end
16
16
  end
17
17
 
@@ -45,6 +45,6 @@ end
45
45
  # Workaround for https://github.com/cucumber/aruba/pull/125
46
46
  Aruba.configure do |config|
47
47
  config.before_cmd do
48
- set_env("JRUBY_OPTS", "-X-C --1.9")
48
+ set_env("JRUBY_OPTS", "--dev --debug")
49
49
  end
50
50
  end
@@ -28,6 +28,7 @@ module SimpleCov
28
28
  #
29
29
  def coverage_dir(dir = nil)
30
30
  return @coverage_dir if defined?(@coverage_dir) && dir.nil?
31
+ @coverage_path = nil # invalidate cache
31
32
  @coverage_dir = (dir || "coverage")
32
33
  end
33
34
 
@@ -37,9 +38,11 @@ module SimpleCov
37
38
  # values. Will create the directory if it's missing
38
39
  #
39
40
  def coverage_path
40
- coverage_path = File.expand_path(coverage_dir, root)
41
- FileUtils.mkdir_p coverage_path
42
- coverage_path
41
+ @coverage_path ||= begin
42
+ coverage_path = File.expand_path(coverage_dir, root)
43
+ FileUtils.mkdir_p coverage_path
44
+ coverage_path
45
+ end
43
46
  end
44
47
 
45
48
  #
@@ -47,8 +50,9 @@ module SimpleCov
47
50
  # or not they were explicitly required. Without this, un-required files
48
51
  # will not be present in the final report.
49
52
  #
50
- def track_files(glob)
51
- @track_files_glob = glob
53
+ def track_files(glob = nil)
54
+ return @track_files if defined?(@track_files) && glob.nil?
55
+ @track_files = glob
52
56
  end
53
57
 
54
58
  #
@@ -81,7 +85,7 @@ module SimpleCov
81
85
  def formatter(formatter = nil)
82
86
  return @formatter if defined?(@formatter) && formatter.nil?
83
87
  @formatter = formatter
84
- fail "No formatter configured. Please specify a formatter using SimpleCov.formatter = SimpleCov::Formatter::SimpleFormatter" unless @formatter
88
+ raise "No formatter configured. Please specify a formatter using SimpleCov.formatter = SimpleCov::Formatter::SimpleFormatter" unless @formatter
85
89
  @formatter
86
90
  end
87
91
 
@@ -114,7 +118,7 @@ module SimpleCov
114
118
  return @nocov_token if defined?(@nocov_token) && nocov_token.nil?
115
119
  @nocov_token = (nocov_token || "nocov")
116
120
  end
117
- alias_method :skip_token, :nocov_token
121
+ alias skip_token nocov_token
118
122
 
119
123
  #
120
124
  # Returns the configured groups. Add groups using SimpleCov.add_group
@@ -285,7 +289,7 @@ module SimpleCov
285
289
  elsif filter_argument.is_a?(Array)
286
290
  SimpleCov::ArrayFilter.new(filter_argument)
287
291
  else
288
- fail ArgumentError, "Please specify either a string or a block to filter with"
292
+ raise ArgumentError, "Please specify either a string or a block to filter with"
289
293
  end
290
294
  end
291
295
  end
@@ -4,8 +4,9 @@ require "pathname"
4
4
 
5
5
  SimpleCov.profiles.define "root_filter" do
6
6
  # Exclude all files outside of simplecov root
7
- root_filter = /\A#{Regexp.escape(SimpleCov.root)}/io
7
+ root_filter = nil
8
8
  add_filter do |src|
9
+ root_filter ||= /\A#{Regexp.escape(SimpleCov.root)}/io
9
10
  !(src.filename =~ root_filter)
10
11
  end
11
12
  end
@@ -31,6 +32,7 @@ SimpleCov.profiles.define "rails" do
31
32
  add_group "Models", "app/models"
32
33
  add_group "Mailers", "app/mailers"
33
34
  add_group "Helpers", "app/helpers"
35
+ add_group "Jobs", %w(app/jobs app/workers)
34
36
  add_group "Libraries", "lib"
35
37
 
36
38
  track_files "{app,lib}/**/*.rb"
@@ -51,15 +53,16 @@ at_exit do
51
53
  # If we are in a different process than called start, don't interfere.
52
54
  next if SimpleCov.pid != Process.pid
53
55
 
54
- if $! # was an exception thrown?
55
- # if it was a SystemExit, use the accompanying status
56
- # otherwise set a non-zero status representing termination by some other exception
57
- # (see github issue 41)
58
- @exit_status = $!.is_a?(SystemExit) ? $!.status : SimpleCov::ExitCodes::EXCEPTION
59
- else
60
- # Store the exit status of the test run since it goes away after calling the at_exit proc...
61
- @exit_status = SimpleCov::ExitCodes::SUCCESS
62
- end
56
+ @exit_status = if $! # was an exception thrown?
57
+ # if it was a SystemExit, use the accompanying status
58
+ # otherwise set a non-zero status representing termination by
59
+ # some other exception (see github issue 41)
60
+ $!.is_a?(SystemExit) ? $!.status : SimpleCov::ExitCodes::EXCEPTION
61
+ else
62
+ # Store the exit status of the test run since it goes away
63
+ # after calling the at_exit proc...
64
+ SimpleCov::ExitCodes::SUCCESS
65
+ end
63
66
 
64
67
  SimpleCov.at_exit.call
65
68
 
@@ -17,7 +17,7 @@ module SimpleCov
17
17
  end
18
18
 
19
19
  def matches?(_)
20
- fail "The base filter class is not intended for direct use"
20
+ raise "The base filter class is not intended for direct use"
21
21
  end
22
22
 
23
23
  def passes?(source_file)
@@ -25,7 +25,7 @@ module SimpleCov
25
25
 
26
26
  def self.[](*args)
27
27
  warn "#{Kernel.caller.first}: [DEPRECATION] ::[] is deprecated. Use ::new instead."
28
- new(*args)
28
+ new(Array([*args]))
29
29
  end
30
30
  end
31
31
  end
@@ -11,7 +11,7 @@ if defined?(JRUBY_VERSION) && JRUBY_VERSION.to_f < 1.7
11
11
  # This monkey patches Coverage to address those issues
12
12
  module Coverage
13
13
  class << self
14
- alias_method :__broken_result__, :result
14
+ alias __broken_result__ result
15
15
 
16
16
  def result # rubocop:disable Metrics/MethodLength
17
17
  fixed = {}
@@ -4,13 +4,12 @@ module SimpleCov
4
4
  def merge_resultset(array)
5
5
  new_array = dup
6
6
  array.each_with_index do |element, i|
7
- if element.nil? && new_array[i].nil?
8
- new_array[i] = nil
9
- else
10
- local_value = element || 0
11
- other_value = new_array[i] || 0
12
- new_array[i] = local_value + other_value
13
- end
7
+ pair = [element, new_array[i]]
8
+ new_array[i] = if pair.any?(&:nil?) && pair.map(&:to_i).all?(&:zero?)
9
+ nil
10
+ else
11
+ element.to_i + new_array[i].to_i
12
+ end
14
13
  end
15
14
  new_array
16
15
  end
@@ -27,12 +26,9 @@ module SimpleCov
27
26
  end
28
27
 
29
28
  new_resultset.each_key do |filename|
30
- new_resultset[filename] = (self[filename] || []).merge_resultset(hash[filename] || [])
29
+ new_resultset[filename] = (self[filename] || []).extend(SimpleCov::ArrayMergeHelper).merge_resultset(hash[filename] || [])
31
30
  end
32
31
  new_resultset
33
32
  end
34
33
  end
35
34
  end
36
-
37
- Array.send :include, SimpleCov::ArrayMergeHelper
38
- Hash.send :include, SimpleCov::HashMergeHelper
@@ -15,7 +15,7 @@ module SimpleCov
15
15
  #
16
16
  def define(name, &blk)
17
17
  name = name.to_sym
18
- fail "SimpleCov Profile '#{name}' is already defined" unless self[name].nil?
18
+ raise "SimpleCov Profile '#{name}' is already defined" unless self[name].nil?
19
19
  self[name] = blk
20
20
  end
21
21
 
@@ -24,7 +24,7 @@ module SimpleCov
24
24
  #
25
25
  def load(name)
26
26
  name = name.to_sym
27
- fail "Could not find SimpleCov Profile called '#{name}'" unless key?(name)
27
+ raise "Could not find SimpleCov Profile called '#{name}'" unless key?(name)
28
28
  SimpleCov.configure(&self[name])
29
29
  end
30
30
  end
@@ -12,7 +12,7 @@ module SimpleCov
12
12
  attr_reader :original_result
13
13
  # Returns all files that are applicable to this result (sans filters!) as instances of SimpleCov::SourceFile. Aliased as :source_files
14
14
  attr_reader :files
15
- alias_method :source_files, :files
15
+ alias source_files files
16
16
  # Explicitly set the Time this result has been created
17
17
  attr_writer :created_at
18
18
  # Explicitly set the command name that was used for this coverage result. Defaults to SimpleCov.command_name
@@ -24,6 +24,7 @@ module SimpleCov
24
24
  # Initialize a new SimpleCov::Result from given Coverage.result (a Hash of filenames each containing an array of
25
25
  # coverage data)
26
26
  def initialize(original_result)
27
+ original_result = original_result.dup.extend(SimpleCov::HashMergeHelper) unless original_result.is_a? SimpleCov::HashMergeHelper
27
28
  @original_result = original_result.freeze
28
29
  @files = SimpleCov::FileList.new(original_result.map do |filename, coverage|
29
30
  SimpleCov::SourceFile.new(filename, coverage) if File.file?(filename)
@@ -20,14 +20,14 @@ module SimpleCov
20
20
  attr_reader :skipped
21
21
 
22
22
  # Lets grab some fancy aliases, shall we?
23
- alias_method :source, :src
24
- alias_method :line, :line_number
25
- alias_method :number, :line_number
23
+ alias source src
24
+ alias line line_number
25
+ alias number line_number
26
26
 
27
27
  def initialize(src, line_number, coverage)
28
- fail ArgumentError, "Only String accepted for source" unless src.is_a?(String)
29
- fail ArgumentError, "Only Fixnum accepted for line_number" unless line_number.is_a?(Fixnum)
30
- fail ArgumentError, "Only Fixnum and nil accepted for coverage" unless coverage.is_a?(Fixnum) || coverage.nil?
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?
31
31
  @src = src
32
32
  @line_number = line_number
33
33
  @coverage = coverage
@@ -76,7 +76,7 @@ module SimpleCov
76
76
  attr_reader :coverage
77
77
  # The source code for this file. Aliased as :source
78
78
  attr_reader :src
79
- alias_method :source, :src
79
+ alias source src
80
80
 
81
81
  def initialize(filename, coverage)
82
82
  @filename = filename
@@ -102,7 +102,7 @@ module SimpleCov
102
102
  process_skipped_lines!
103
103
  @lines
104
104
  end
105
- alias_method :source_lines, :lines
105
+ alias source_lines lines
106
106
 
107
107
  # Access SimpleCov::SourceFile::Line source lines by line number
108
108
  def line(number)
@@ -116,7 +116,7 @@ module SimpleCov
116
116
  if relevant_lines.zero?
117
117
  0.0
118
118
  else
119
- Float((covered_lines.count) * 100.0 / relevant_lines.to_f)
119
+ Float(covered_lines.count * 100.0 / relevant_lines.to_f)
120
120
  end
121
121
  end
122
122
 
@@ -172,8 +172,8 @@ module SimpleCov
172
172
  lines.each do |line|
173
173
  if line.src =~ /^([\s]*)#([\s]*)(\:#{SimpleCov.nocov_token}\:)/
174
174
  skipping = !skipping
175
- else
176
- line.skipped! if skipping
175
+ elsif skipping
176
+ line.skipped!
177
177
  end
178
178
  end
179
179
  end
@@ -1,22 +1,25 @@
1
1
  module SimpleCov
2
- VERSION = "0.11.0"
3
- def VERSION.to_a
2
+ version = "0.12.0"
3
+
4
+ def version.to_a
4
5
  split(".").map(&:to_i)
5
6
  end
6
7
 
7
- def VERSION.major
8
+ def version.major
8
9
  to_a[0]
9
10
  end
10
11
 
11
- def VERSION.minor
12
+ def version.minor
12
13
  to_a[1]
13
14
  end
14
15
 
15
- def VERSION.patch
16
+ def version.patch
16
17
  to_a[2]
17
18
  end
18
19
 
19
- def VERSION.pre
20
+ def version.pre
20
21
  to_a[3]
21
22
  end
23
+
24
+ VERSION = version
22
25
  end
data/lib/simplecov.rb CHANGED
@@ -2,13 +2,18 @@
2
2
  # Code coverage for ruby 1.9. Please check out README for a full introduction.
3
3
  #
4
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
5
+ if defined?(JRUBY_VERSION) && defined?(JRuby)
6
+
7
+ # @see https://github.com/jruby/jruby/issues/1196
8
+ # @see https://github.com/metricfu/metric_fu/pull/226
9
+ # @see https://github.com/colszowka/simplecov/issues/420
10
+ # @see https://github.com/colszowka/simplecov/issues/86
11
+ # @see https://jira.codehaus.org/browse/JRUBY-6106
12
+
13
+ unless org.jruby.RubyInstanceConfig.FULL_TRACE_ENABLED
14
+ warn 'Coverage may be inaccurate; set the "--debug" command line option,' \
15
+ ' or do JRUBY_OPTS="--debug"' \
16
+ ' or set the "debug.fullTrace=true" option in your .jrubyrc'
12
17
  end
13
18
  end
14
19
  module SimpleCov
@@ -53,9 +58,9 @@ module SimpleCov
53
58
  # their coverage to zero.
54
59
  #
55
60
  def add_not_loaded_files(result)
56
- if @track_files_glob
61
+ if track_files
57
62
  result = result.dup
58
- Dir[@track_files_glob].each do |file|
63
+ Dir[track_files].each do |file|
59
64
  absolute = File.expand_path(file)
60
65
 
61
66
  result[absolute] ||= [0] * File.foreach(absolute).count
@@ -70,14 +75,22 @@ module SimpleCov
70
75
  # from cache using SimpleCov::ResultMerger if use_merging is activated (default)
71
76
  #
72
77
  def result
73
- @result ||= SimpleCov::Result.new(add_not_loaded_files(Coverage.result)) if running
78
+ # Ensure the variable is defined to avoid ruby warnings
79
+ @result = nil unless defined?(@result)
80
+
81
+ # Collect our coverage result
82
+ if running && !result?
83
+ @result = SimpleCov::Result.new add_not_loaded_files(Coverage.result)
84
+ end
85
+
74
86
  # If we're using merging of results, store the current result
75
87
  # first, then merge the results and return those
76
88
  if use_merging
77
- SimpleCov::ResultMerger.store_result(@result) if @result
78
- return SimpleCov::ResultMerger.merged_result
89
+ SimpleCov::ResultMerger.store_result(@result) if result?
90
+
91
+ SimpleCov::ResultMerger.merged_result
79
92
  else
80
- return @result if defined? @result
93
+ @result
81
94
  end
82
95
  ensure
83
96
  self.running = false
@@ -112,7 +125,7 @@ module SimpleCov
112
125
  grouped[name] = SimpleCov::FileList.new(files.select { |source_file| filter.matches?(source_file) })
113
126
  grouped_files += grouped[name]
114
127
  end
115
- if groups.length > 0 && (other_files = files.reject { |source_file| grouped_files.include?(source_file) }).length > 0
128
+ if !groups.empty? && !(other_files = files.reject { |source_file| grouped_files.include?(source_file) }).empty?
116
129
  grouped["Ungrouped"] = SimpleCov::FileList.new(other_files)
117
130
  end
118
131
  grouped
data/simplecov.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
14
14
 
15
15
  gem.required_ruby_version = ">= 1.8.7"
16
16
 
17
- gem.add_dependency "json", "~> 1.8"
17
+ gem.add_dependency "json", ">= 1.8", "< 3"
18
18
  gem.add_dependency "simplecov-html", "~> 0.10.0"
19
19
  gem.add_dependency "docile", "~> 1.1.0"
20
20
 
@@ -12,11 +12,11 @@ describe "Ruby 1.8 fallback" do
12
12
  end
13
13
 
14
14
  it "return false when calling SimpleCov.start with a block" do
15
- expect(SimpleCov.start { fail "Shouldn't reach this!" }).to be false
15
+ expect(SimpleCov.start { raise "Shouldn't reach this!" }).to be false
16
16
  end
17
17
 
18
18
  it "return false when calling SimpleCov.configure with a block" do
19
- expect(SimpleCov.configure { fail "Shouldn't reach this!" }).to be false
19
+ expect(SimpleCov.configure { raise "Shouldn't reach this!" }).to be false
20
20
  end
21
21
 
22
22
  it "allow to define a profile" do
@@ -14,7 +14,7 @@ class SomeClass
14
14
  if item == label
15
15
  return true
16
16
  else
17
- fail "Item does not match label"
17
+ raise "Item does not match label"
18
18
  end
19
19
  rescue
20
20
  false
@@ -2,6 +2,7 @@ require "spec_helper"
2
2
 
3
3
  describe "forking" do
4
4
  it do
5
- Process.waitpid(Kernel.fork {})
5
+ # TODO: The defined?(RUBY_ENGINE) check can be dropped for simplecov 1.0.0
6
+ Process.waitpid(Kernel.fork {}) unless defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
6
7
  end
7
8
  end
@@ -12,4 +12,4 @@ code = %{
12
12
  File.open(file, "w") { |f| f.print code }
13
13
  load file
14
14
  File.unlink file
15
- fail unless kill_the_buddha(3) == 27
15
+ raise unless kill_the_buddha(3) == 27
@@ -9,13 +9,15 @@ describe "merge helpers" do
9
9
  source_fixture("app/models/user.rb") => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
10
10
  source_fixture("app/controllers/sample_controller.rb") => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil],
11
11
  source_fixture("resultset1.rb") => [1, 1, 1, 1],
12
- }
12
+ source_fixture("parallel_tests.rb") => [nil, 0, nil, 0],
13
+ }.extend(SimpleCov::HashMergeHelper)
13
14
 
14
15
  @resultset2 = {
15
16
  source_fixture("sample.rb") => [1, nil, 1, 1, nil, nil, 1, 1, nil, nil],
16
17
  source_fixture("app/models/user.rb") => [nil, 1, 5, 1, nil, nil, 1, 0, nil, nil],
17
18
  source_fixture("app/controllers/sample_controller.rb") => [nil, 3, 1, nil, nil, nil, 1, 0, nil, nil],
18
19
  source_fixture("resultset2.rb") => [nil, 1, 1, nil],
20
+ source_fixture("parallel_tests.rb") => [nil, nil, 0, 0],
19
21
  }
20
22
  end
21
23
 
@@ -43,6 +45,10 @@ describe "merge helpers" do
43
45
  it "has proper results for resultset2.rb" do
44
46
  expect(subject[source_fixture("resultset2.rb")]).to eq([nil, 1, 1, nil])
45
47
  end
48
+
49
+ it "has proper results for parallel_tests.rb" do
50
+ expect(subject[source_fixture("parallel_tests.rb")]).to eq([nil, nil, nil, 0])
51
+ end
46
52
  end
47
53
 
48
54
  # See Github issue #6
@@ -0,0 +1,20 @@
1
+ require "helper"
2
+
3
+ require "simplecov/formatter/multi_formatter"
4
+
5
+ describe SimpleCov::Formatter::MultiFormatter do
6
+ describe ".[]" do
7
+ # Regression test for https://github.com/colszowka/simplecov/issues/428
8
+ it "constructs a formatter with multiple children" do
9
+ # Silence deprecation warnings.
10
+ allow(described_class).to receive(:warn)
11
+
12
+ children = [
13
+ SimpleCov::Formatter::SimpleFormatter,
14
+ SimpleCov::Formatter::SimpleFormatter,
15
+ ]
16
+
17
+ expect(described_class[*children].new.formatters).to eq(children)
18
+ end
19
+ end
20
+ end
@@ -4,14 +4,11 @@ require "helper"
4
4
  # See https://github.com/colszowka/simplecov/issues/5
5
5
  describe "return codes" do
6
6
  context "inside fixtures/frameworks" do
7
- before do
8
- @current_dir = Dir.getwd
9
- Dir.chdir(File.join(File.dirname(__FILE__), "fixtures", "frameworks"))
10
- FileUtils.rm_rf("./coverage")
11
- end
12
-
13
- after do
14
- Dir.chdir(@current_dir)
7
+ around do |test|
8
+ Dir.chdir(File.join(File.dirname(__FILE__), "fixtures", "frameworks")) do
9
+ FileUtils.rm_rf("./coverage")
10
+ test.call
11
+ end
15
12
  end
16
13
 
17
14
  it "has return code 0 when running testunit_good.rb" do
@@ -1,7 +1,7 @@
1
1
  require "helper"
2
2
 
3
3
  describe SimpleCov::SourceFile do
4
- COVERAGE_FOR_SAMPLE_RB = [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil, nil, nil, nil, nil, nil, nil]
4
+ COVERAGE_FOR_SAMPLE_RB = [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil, nil, nil, nil, nil, nil, nil].freeze
5
5
  context "a source file initialized with some coverage data" do
6
6
  subject do
7
7
  SimpleCov::SourceFile.new(source_fixture("sample.rb"), COVERAGE_FOR_SAMPLE_RB)
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplecov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christoph Olszowka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-29 00:00:00.000000000 Z
11
+ date: 2016-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.8'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '3'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '1.8'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '3'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: simplecov-html
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -184,6 +190,7 @@ files:
184
190
  - spec/fixtures/utf-8.rb
185
191
  - spec/helper.rb
186
192
  - spec/merge_helpers_spec.rb
193
+ - spec/multi_formatter_spec.rb
187
194
  - spec/result_spec.rb
188
195
  - spec/return_codes_spec.rb
189
196
  - spec/source_file_line_spec.rb
@@ -208,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
215
  version: '0'
209
216
  requirements: []
210
217
  rubyforge_project:
211
- rubygems_version: 2.4.5
218
+ rubygems_version: 2.5.1
212
219
  signing_key:
213
220
  specification_version: 4
214
221
  summary: Code coverage for Ruby 1.9+ with a powerful configuration library and automatic
@@ -287,6 +294,7 @@ test_files:
287
294
  - spec/fixtures/utf-8.rb
288
295
  - spec/helper.rb
289
296
  - spec/merge_helpers_spec.rb
297
+ - spec/multi_formatter_spec.rb
290
298
  - spec/result_spec.rb
291
299
  - spec/return_codes_spec.rb
292
300
  - spec/source_file_line_spec.rb