simplecov 0.18.1 → 0.18.5

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
  SHA256:
3
- metadata.gz: 6139c9ec905e1f20dec5bdfd8fef48fe8b9091ce24ae1b55e89b850093cfcf69
4
- data.tar.gz: 3e15d4dbbc0f68b9453241603c0a1beade1b29ca2fbf64190f742f69db307b13
3
+ metadata.gz: 3d8b7307fd45fc7c4079efec764ee740fd7c0d302b8b78e969b11a08a2c94027
4
+ data.tar.gz: 4a39c982bdc16b038c8d4ff88e25498d34b3bf0a1eec6ed99ed2e444a0e5ada7
5
5
  SHA512:
6
- metadata.gz: 3af5aa2cad84980d28f95c606d0e7cc8282d5c81689bdaa637cb29a971ffe2842b7cd91ba2d602a6214f7c917851886ead8a62b50a8e071a12edbddbb7355a45
7
- data.tar.gz: a3afd317b84ae5b11b907384c3ee17436e3a033c956c7ebdc000db0fca852442e4e658b72dc09c07f3c510f659297ab386f07af4fbee1c43b8a81794da595f6a
6
+ metadata.gz: e7ce525f98807869dcfafa47e154aafa8047fe8e41685cab5d051400e615b056ee5629a0e18e0203f01af675761be3a57a413d9d4f8eb6a57b4260f4a6db6986
7
+ data.tar.gz: 3a0cc93b7ade626e432238d9ebc18514cbad27d6ea67fbd995c19a4cd40afe6c86486396531110f5f11e29cf65fad6dc81479ef9fdd68304f982257b05abf103
@@ -1,3 +1,37 @@
1
+ 0.18.5 (2020-02-25)
2
+ ===================
3
+
4
+ Can you guess? Another bugfix release!
5
+
6
+ ## Bugfixes
7
+ * minitest won't crash if SimpleCov isn't loaded - aka don't execute SimpleCov code in the minitest plugin if SimpleCov isn't loaded. Thanks to [@edariedl](https://github.com/edariedl) for the report of the peculiar problem in [#877](https://github.com/colszowka/simplecov/issues/877).
8
+
9
+ 0.18.4 (2020-02-24)
10
+ ===================
11
+
12
+ Another small bugfix release 🙈 Fixes SimpleCov running with rspec-rails, which was broken due to our fixed minitest integration.
13
+
14
+ ## Bugfixes
15
+ * SimpleCov will run again correctly when used with rspec-rails. The excellent bug report [#873](https://github.com/colszowka/simplecov/issues/873) by [@odlp](https://github.com/odlp) perfectly details what went wrong. Thanks to [@adam12](https://github.com/adam12) for the fix [#874](https://github.com/colszowka/simplecov/pull/874).
16
+
17
+
18
+ 0.18.3 (2020-02-23)
19
+ ===========
20
+
21
+ Small bugfix release. It's especially recommended to upgrade simplecov-html as well because of bugs in the 0.12.0 release.
22
+
23
+ ## Bugfixes
24
+ * Fix a regression related to file encodings as special characters were missing. Furthermore we now respect the magic `# encoding: ...` comment and read files in the right encoding. Thanks ([@Tietew](https://github.com/Tietew)) - see [#866](https://github.com/colszowka/simplecov/pull/866)
25
+ * Use `Minitest.after_run` hook to trigger post-run hooks if `Minitest` is present. See [#756](https://github.com/colszowka/simplecov/pull/756) and [#855](https://github.com/colszowka/simplecov/pull/855) thanks ([@adam12](https://github.com/adam12))
26
+
27
+ 0.18.2 (2020-02-12)
28
+ ===================
29
+
30
+ Small release just to allow you to use the new simplecov-html.
31
+
32
+ ## Enhancements
33
+ * Relax simplecov-html requirement so that you're able to use [0.12.0](https://github.com/colszowka/simplecov-html/blob/master/CHANGELOG.md#0120-2020-02-12)
34
+
1
35
  0.18.1 (2020-01-31)
2
36
  ===================
3
37
 
@@ -25,6 +59,7 @@ You can run with branch coverage by putting `enable_coverage :branch` into your
25
59
 
26
60
  ## Noteworthy
27
61
  * `FileList` stopped inheriting from Array, it includes Enumerable so if you didn't use Array specific methods on it in formatters you should be fine
62
+ * We needed to change an internal file format, which we use for merging across processes, to accommodate branch coverage. Sadly CodeClimate chose to use this file to report test coverage. Until a resolution is found the code climate test reporter won't work with SimpleCov for 0.18+, see [this issue on the test reporter](https://github.com/codeclimate/test-reporter/issues/413).
28
63
 
29
64
  0.18.0.beta3 (2020-01-20)
30
65
  ========================
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ # How minitest plugins. See https://github.com/colszowka/simplecov/pull/756 for why we need this.
4
+ # https://github.com/seattlerb/minitest#writing-extensions
5
+ module Minitest
6
+ def self.plugin_simplecov_init(_options)
7
+ if defined?(SimpleCov)
8
+ SimpleCov.external_at_exit = true
9
+
10
+ Minitest.after_run do
11
+ SimpleCov.at_exit_behavior
12
+ end
13
+ end
14
+ end
15
+ end
@@ -27,6 +27,11 @@ module SimpleCov
27
27
  attr_accessor :pid
28
28
  attr_reader :exit_exception
29
29
 
30
+ # Basically, should we take care of at_exit behavior or something else?
31
+ # Used by the minitest plugin. See lib/minitest/simplecov_plugin.rb
32
+ attr_accessor :external_at_exit
33
+ alias external_at_exit? external_at_exit
34
+
30
35
  #
31
36
  # Sets up SimpleCov to run against your project.
32
37
  # You can optionally specify a profile to use as well as configuration with a block:
@@ -189,6 +194,14 @@ module SimpleCov
189
194
  end
190
195
  end
191
196
 
197
+ def at_exit_behavior
198
+ # If we are in a different process than called start, don't interfere.
199
+ return if SimpleCov.pid != Process.pid
200
+
201
+ # If SimpleCov is no longer running then don't run exit tasks
202
+ SimpleCov.run_exit_tasks! if SimpleCov.running
203
+ end
204
+
192
205
  # @api private
193
206
  #
194
207
  # Called from at_exit block
@@ -9,8 +9,8 @@ module SimpleCov
9
9
  #
10
10
  # Combine two coverage based on the given combiner_module.
11
11
  #
12
- # Combiners should always be called throught his interface,
13
- # as it takes care of short circuting of one of the coverages is nil.
12
+ # Combiners should always be called through this interface,
13
+ # as it takes care of short-circuiting of one of the coverages is nil.
14
14
  #
15
15
  # @return [Hash]
16
16
  def combine(combiner_module, coverage_a, coverage_b)
@@ -10,9 +10,9 @@ module SimpleCov
10
10
  module_function
11
11
 
12
12
  #
13
- # Return merged branches or the existed branche if other is missing.
13
+ # Return merged branches or the existed brach if other is missing.
14
14
  #
15
- # Branches inside files are always same if they exists, the difference only in coverage count.
15
+ # Branches inside files are always same if they exist, the difference only in coverage count.
16
16
  # Branch coverage report for any conditional case is built from hash, it's key is a condition and
17
17
  # it's body is a hash << keys from condition and value is coverage rate >>.
18
18
  # ex: branches =>{ [:if, 3, 8, 6, 8, 36] => {[:then, 4, 8, 6, 8, 12] => 1, [:else, 5, 8, 6, 8, 36]=>2}, other conditions...}
@@ -19,7 +19,7 @@ module SimpleCov
19
19
  [
20
20
  covered + file_coverage_statistics.covered,
21
21
  missed + file_coverage_statistics.missed,
22
- # gotta remultiply with loc because files have different strenght and loc
22
+ # gotta remultiply with loc because files have different strength and loc
23
23
  # giving them a different "weight" in total
24
24
  total_strength + (file_coverage_statistics.strength * file_coverage_statistics.total)
25
25
  ]
@@ -35,14 +35,14 @@ module SimpleCov
35
35
  @covered = covered
36
36
  @missed = missed
37
37
  @total = covered + missed
38
- @percent = compute_percent(covered, total)
39
- @strength = compute_strength(total_strength, @total)
38
+ @percent = compute_percent(covered, missed, total)
39
+ @strength = compute_strength(total_strength, total)
40
40
  end
41
41
 
42
42
  private
43
43
 
44
- def compute_percent(covered, total)
45
- return 100.0 if total.zero?
44
+ def compute_percent(covered, missed, total)
45
+ return 100.0 if missed.zero?
46
46
 
47
47
  covered * 100.0 / total
48
48
  end
@@ -22,13 +22,9 @@ end
22
22
  SimpleCov::CommandGuesser.original_run_command = "#{$PROGRAM_NAME} #{ARGV.join(' ')}"
23
23
 
24
24
  at_exit do
25
- # If we are in a different process than called start, don't interfere.
26
- next if SimpleCov.pid != Process.pid
25
+ next if SimpleCov.external_at_exit?
27
26
 
28
- # If SimpleCov is no longer running then don't run exit tasks
29
- next unless SimpleCov.running
30
-
31
- SimpleCov.run_exit_tasks!
27
+ SimpleCov.at_exit_behavior
32
28
  end
33
29
 
34
30
  # Autoload config from ~/.simplecov if present
@@ -25,7 +25,7 @@ module SimpleCov
25
25
  def src
26
26
  # We intentionally read source code lazily to
27
27
  # suppress reading unused source code.
28
- @src ||= File.open(filename, "rb", &:readlines)
28
+ @src ||= load_source
29
29
  end
30
30
  alias source src
31
31
 
@@ -175,6 +175,51 @@ module SimpleCov
175
175
  end
176
176
  end
177
177
 
178
+ def load_source
179
+ lines = []
180
+ # The default encoding is UTF-8
181
+ File.open(filename, "rb:UTF-8") do |file|
182
+ current_line = file.gets
183
+
184
+ if shebang?(current_line)
185
+ lines << current_line
186
+ current_line = file.gets
187
+ end
188
+
189
+ read_lines(file, lines, current_line)
190
+ end
191
+ end
192
+
193
+ SHEBANG_REGEX = /\A#!/.freeze
194
+ def shebang?(line)
195
+ SHEBANG_REGEX.match?(line)
196
+ end
197
+
198
+ def read_lines(file, lines, current_line)
199
+ return lines unless current_line
200
+
201
+ set_encoding_based_on_magic_comment(file, current_line)
202
+ lines.concat([current_line], ensure_remove_undefs(file.readlines))
203
+ end
204
+
205
+ RUBY_FILE_ENCODING_MAGIC_COMMENT_REGEX = /\A#\s*(?:-\*-)?\s*(?:en)?coding:\s*(\S+)\s*(?:-\*-)?\s*\z/.freeze
206
+ def set_encoding_based_on_magic_comment(file, line)
207
+ # Check for encoding magic comment
208
+ # Encoding magic comment must be placed at first line except for shebang
209
+ if (match = RUBY_FILE_ENCODING_MAGIC_COMMENT_REGEX.match(line))
210
+ file.set_encoding(match[1], "UTF-8")
211
+ end
212
+ end
213
+
214
+ def ensure_remove_undefs(file_lines)
215
+ # invalid/undef replace are technically not really necessary but nice to
216
+ # have and work around a JRuby incompatibility. Also moved here from
217
+ # simplecov-html to have encoding shenaningans in one place. See #866
218
+ # also setting these option on `file.set_encoding` doesn't seem to work
219
+ # properly so it has to be done here.
220
+ file_lines.each { |line| line.encode!("UTF-8", invalid: :replace, undef: :replace) }
221
+ end
222
+
178
223
  def build_lines
179
224
  coverage_exceeding_source_warn if coverage_data["lines"].size > src.size
180
225
  lines = src.map.with_index(1) do |src, i|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SimpleCov
4
- VERSION = "0.18.1"
4
+ VERSION = "0.18.5"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplecov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.1
4
+ version: 0.18.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christoph Olszowka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-31 00:00:00.000000000 Z
11
+ date: 2020-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docile
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.11.0
33
+ version: '0.11'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.11.0
40
+ version: '0.11'
41
41
  description: Code coverage for Ruby with a powerful configuration library and automatic
42
42
  merging of coverage across test suites
43
43
  email:
@@ -55,6 +55,7 @@ files:
55
55
  - doc/alternate-formatters.md
56
56
  - doc/commercial-services.md
57
57
  - doc/editor-integration.md
58
+ - lib/minitest/simplecov_plugin.rb
58
59
  - lib/simplecov.rb
59
60
  - lib/simplecov/combine.rb
60
61
  - lib/simplecov/combine/branches_combiner.rb
@@ -96,9 +97,9 @@ licenses:
96
97
  metadata:
97
98
  bug_tracker_uri: https://github.com/colszowka/simplecov/issues
98
99
  changelog_uri: https://github.com/colszowka/simplecov/blob/master/CHANGELOG.md
99
- documentation_uri: https://www.rubydoc.info/gems/simplecov/0.18.1
100
+ documentation_uri: https://www.rubydoc.info/gems/simplecov/0.18.5
100
101
  mailing_list_uri: https://groups.google.com/forum/#!forum/simplecov
101
- source_code_uri: https://github.com/colszowka/simplecov/tree/v0.18.1
102
+ source_code_uri: https://github.com/colszowka/simplecov/tree/v0.18.5
102
103
  post_install_message:
103
104
  rdoc_options: []
104
105
  require_paths: